-
Notifications
You must be signed in to change notification settings - Fork 1
/
stonks_dash_app.py
executable file
·144 lines (130 loc) · 3.96 KB
/
stonks_dash_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
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
# -*- coding: utf-8 -*-
"""
stonks_dash_app.py
Description: Base script for Stonks web based dashboard. This will be the
main script for all visualizations and widgets for tuning.
"""
import dash
import dash_core_components as dcc
import dash_html_components as html
import dash_bootstrap_components as dbc
import pandas as pd
import plotly.graph_objects as go
from scipy.signal import find_peaks
from dash.dependencies import Input, Output
import numpy as np
import stonks_visualize as sv
app = dash.Dash(external_stylesheets=[dbc.themes.SLATE])
def draw_yield_graph():
return html.Div([
dbc.Card(
dbc.CardBody([
dcc.Graph(
figure=sv.generate_yield_graph('T', 'tsx', './').update_layout(
template='plotly_dark',
plot_bgcolor= 'rgba(0, 0, 0, 0)',
paper_bgcolor= 'rgba(0, 0, 0, 0)',
),
config={
'displayModeBar': False
}
)
])
),
])
def draw_price_graph():
return html.Div([
dbc.Card(
dbc.CardBody([
dcc.Graph(
figure=sv.generate_price_graph('T', 'tsx', './').update_layout(
template='plotly_dark',
plot_bgcolor= 'rgba(0, 0, 0, 0)',
paper_bgcolor= 'rgba(0, 0, 0, 0)',
),
config={
'displayModeBar': False
}
)
])
),
])
# Text field
def drawText():
return html.Div([
dbc.Card(
dbc.CardBody([
html.Div([
html.H2("Text"),
], style={'textAlign': 'center'})
])
),
])
app.layout = html.Div([
html.H1(
children='Stonks - Stock Recommendation Platform',
style={
'textAlign': 'center',
}
),
dbc.Row([dbc.Col([html.Label('Choose your Exchange')]),
dbc.Col([dcc.RadioItems(
id='in_market',
options=[
{'label': 'TSX', 'value': 'tsx'},
{'label': 'NYSE', 'value':'nyse'},
{'label': 'NASDAQ', 'value': 'nasdaq'}
],
value='tsx',
)]),
dbc.Col([html.Label('Enter your ticker')]),
dbc.Col([dcc.Input(
id='in_tick',
value='T',
type = 'text'
)]),
]),
dbc.Card(
dbc.CardBody([
dbc.Row([
dbc.Col([
sv.generate_ticker_card('T', 'tsx')
], width=3),
dbc.Col([
sv.generate_ticker_card('T', 'nyse')
], width=3),
dbc.Col([
sv.generate_ticker_card('AAPL', 'nasdaq')
], width=3),
dbc.Col([
sv.generate_ticker_card('ATD.B', 'tsx')
], width=3),
], align='center'),
html.Br(),
dbc.Row([
dbc.Col([
draw_yield_graph()
], width=3),
dbc.Col([
draw_price_graph()
], width=3),
dbc.Col([
draw_yield_graph()
], width=6),
], align='center'),
html.Br(),
dbc.Row([
dbc.Col([
draw_yield_graph()
], width=9),
dbc.Col([
draw_yield_graph()
], width=3),
], align='center'),
]), color = 'dark'
)
])
# Run app and display result inline in the notebook
# app.run_server(mode='external')
if __name__ == '__main__':
app.run_server(debug=True)