Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import pandas_datareader.data as web
- import datetime
- import dash
- import dash_core_components as dcc
- import dash_html_components as html
- from dash.dependencies import Input, Output
- import pandas as pd
- import datetime
- TAB_STYLE = {
- 'width': 'inherit',
- 'border': 'none',
- 'boxShadow': 'inset 0px -1px 0px 0px lightgrey',
- 'background': 'white',
- 'paddingTop': 0,
- 'paddingBottom': 0,
- 'height': '42px',
- }
- SELECTED_STYLE = {
- 'width': 'inherit',
- 'boxShadow': 'none',
- 'borderLeft': 'none',
- 'borderRight': 'none',
- 'borderTop': 'none',
- 'borderBottom': '2px #004A96 solid',
- 'background': 'white',
- 'paddingTop': 0,
- 'paddingBottom': 0,
- 'height': '42px',
- }
- colors={
- 'background':'D3B592',
- 'text':'#7FDBFF'
- }
- external_stylesheets = ['https://codepen.io/chriddyp/pen/bWLwgP.css']
- app = dash.Dash()
- app.layout = html.Div(style={'backgroundColor': colors['background']},children=[
- html.H1(children='STOCK DASHBOARD',
- style={'textAlign': 'left', 'colour': colors['text']}),
- dcc.Interval(id='refresh', interval=200,),
- dcc.Input(id='input', value='', type='text', placeholder="stock code"),
- dcc.Tabs(id="tabs", value='tab-1', children=[
- dcc.Tab(label='SNAPSHOT', value='tab-2', style=TAB_STYLE,selected_style=SELECTED_STYLE,),
- dcc.Tab(label='KEY STATS', value='tab-3',style=TAB_STYLE,selected_style=SELECTED_STYLE,),
- dcc.Tab(label='FINANCIALS', value='tab-4',style=TAB_STYLE,selected_style=SELECTED_STYLE,children=[
- dcc.Dropdown(id='subtab3', options=[{'label': 'Balance Sheet', 'value': 'A'},
- {'label': 'Income Statement', 'value': 'B'},
- {'label': 'Cash Flow', 'value': 'C'}],
- )]),
- dcc.Tab(label='PERFORMANCE', value='tab-5',style=TAB_STYLE,selected_style=SELECTED_STYLE,),
- dcc.Tab(label='VALUE ANALYSIS', value='tab-6',style=TAB_STYLE,selected_style=SELECTED_STYLE,),
- dcc.Tab(label='FUNDUMANTAL ANALYSIS', value='tab-7',style=TAB_STYLE,selected_style=SELECTED_STYLE,),
- dcc.Tab(label='SENTIMENT ANALYSIS', value='tab-8',style=TAB_STYLE,selected_style=SELECTED_STYLE,),
- dcc.Tab(label='MOMENTUM ANALYSIS', value='tab-9',style=TAB_STYLE,selected_style=SELECTED_STYLE,),
- dcc.Tab(label='SCORE', value='tab-10', style=TAB_STYLE,selected_style=SELECTED_STYLE,),
- dcc.Tab(label='DATA', value='tab-11', style=TAB_STYLE,selected_style=SELECTED_STYLE,),
- ]),
- html.Div(id='tabs-content')])
- @app.callback(
- Output('tabs-content','children'),
- [Input('input','value')]
- )
- def update_value(input_data):
- start = datetime.datetime(2015, 1, 1)
- end = datetime.datetime.now()
- df = web.DataReader(input_data, 'yahoo', start, end)
- df.reset_index(inplace=True)
- df.set_index("Date", inplace=True)
- return html.Div([html.H3('PRICE CHART'),
- dcc.Graph(id='example-graph', figure={'data': [{'x': df.index, 'y': df.Close, 'type': 'line', 'name': input_data},],'layout': {'title': input_data}})])
- if __name__ == '__main__':
- app.run_server(debug=True)
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement