-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapp.py
76 lines (63 loc) · 2.43 KB
/
app.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
# Created by: Long Hoang
# Created on: 2022-05-19
# Description: Stock Insight App
import json
import logging
import matplotlib as plt
import numpy as np
import yfinance as yf
import streamlit as st
import pandas as pd
import altair as alt
from PIL import Image
import datetime
import time
from datetime import date, timedelta
from utils import feeder, logger, ploter
from apps import sidebar, header
from vars import contants, messages as msg
from strategy import indicators
#!! Load image to the web app
# icon = Image.open('icon.jpg')
# st.image(icon, use_column_width=True)
#!! Set layout wide
st.set_page_config(page_title=contants.page_title, layout=contants.page_layout)
#!! Activate Logger
logger = logger.Log.active()
#!!B-----------------------------------------------------------------------------------------------------------------------------------
#!! Application Executor
#!! INPUT: NONE
def main():
try:
#!! Get user input
inputs = sidebar.add()
if inputs[contants.F8] != contants.noGO:
#!! Get stock infor
candle_df, renko_df = feeder.get_yfdata(inputs)
if candle_df.empty:
st.error(msg.E001)
else:
# header.add(inputs[vars.Symbol])
# st.write("Historical Data")
# db.tableau(candle_df, height=650)
# db.candlestick(candle_df, title=inputs[vars.Symbol])
# input_renko = inputs
# input_renko[vars.Interval] = '1h'
# input_renko[vars.Period] = '1y'
# input_renko[vars.xPeriod] = True
# hour_df, raw_df = devf.get_yfdata(input_renko)
# renko_chart = devf.renko_convertion(renko_df, hour_df)
# db.renko(renko_chart)
renko = indicators.renko(renko_df)
ploter.tableau(renko)
st.write('Data source: **Yahoo Finance**')
except Exception as e:
logger.write(e)
#!!E-----------------------------------------------------------------------------------------------------------------------------------
#!! run web app
if __name__ == '__main__':
main()
#!!B------------------------------------------------------------------------------------------------------------------------------------
#!!
#!! INPUT:
#!!E------------------------------------------------------------------------------------------------------------------------------------