-
Notifications
You must be signed in to change notification settings - Fork 0
/
index.py
49 lines (43 loc) · 1.24 KB
/
index.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
import dash_core_components as dcc
import dash_html_components as html
import yaml
import dash
from app import app
from apps import livetable, historical, profits
with open("config.yaml", 'r') as configfile:
cfg = yaml.load(configfile)
symbols = []
csvfile = 'historical.csv'
for k,v in cfg['positions'].items():
symbols.append(k)
def get_options():
options = []
for symbol in symbols:
options.append({'label': symbol, 'value': symbol})
return options
app.layout = html.Div([
dcc.Location(id='url', refresh=True),
html.Div(id='page-content'),
dcc.Interval(
id='live-interval',
interval=5000, # in milliseconds
n_intervals=0
),
dcc.Interval(
id='interval-component',
interval=10000, # in milliseconds
n_intervals=0
),
])
@app.callback(dash.dependencies.Output('page-content', 'children'),
[dash.dependencies.Input('url', 'pathname')])
def display_page(pathname):
#log.info(f'Page {pathname} requested')
if pathname == '/historical':
return historical.layout
elif pathname == '/profits':
return profits.layout
else:
return livetable.layout
if __name__ == '__main__':
app.run_server(debug=True, port=8050)