Compare commits

..

No commits in common. "master" and "comp-descriptions" have entirely different histories.

View File

@ -65,8 +65,7 @@ to_time = None
# Initialize the app # Initialize the app
app = dash.Dash(__name__) app = dash.Dash(__name__)
app.config.suppress_callback_exceptions = True app.config.suppress_callback_exceptions = True
stock_info_in_time_period_df = pd.DataFrame(index=stock_list, columns=["tracker", "średnia", "cena"]) stock_info_in_time_period_df = pd.DataFrame(columns=stock_list, index=["średnia", "cena", "dywidenda", "wolatylność"])
stock_info_in_time_period_df['tracker'] = stock_info_in_time_period_df.index
mean_prices_and_dividends = fullTableDf[['Close', 'Dividends']].mean(axis=0).unstack(level=0) mean_prices_and_dividends = fullTableDf[['Close', 'Dividends']].mean(axis=0).unstack(level=0)
mean_prices_and_dividends_and_market_cap = pd.concat([mean_prices_and_dividends, market_cap], axis=1) mean_prices_and_dividends_and_market_cap = pd.concat([mean_prices_and_dividends, market_cap], axis=1)
@ -141,30 +140,11 @@ app.layout = html.Div(
]), ]),
dash_table.DataTable( dash_table.DataTable(
id='info_in_time_period', id='info_in_time_period',
columns=[{"name": i, "id": i} for i in stock_info_in_time_period_df.columns],
style_header={'backgroundColor': 'rgb(30, 30, 30)'}, style_header={'backgroundColor': 'rgb(30, 30, 30)'},
style_cell={ style_cell={
'backgroundColor': 'rgb(50, 50, 50)', 'backgroundColor': 'rgb(50, 50, 50)',
'color': 'white' 'color': 'white'
}, },
style_data_conditional=[
{
'if': {
'filter_query': '{cena} > {średnia}',
'column_id': 'tracker'
},
'backgroundColor': 'green',
'color': 'black'
},
{
'if': {
'filter_query': '{cena} <= {średnia}',
'column_id': 'tracker'
},
'backgroundColor': 'red',
'color': 'black'
},
]
) )
]), ]),
html.Div(className='eight columns div-for-charts bg-grey', html.Div(className='eight columns div-for-charts bg-grey',
@ -195,6 +175,7 @@ app.layout = html.Div(
) )
# Callback for scraping company description # Callback for scraping company description
@app.callback(Output('company-desritpion', 'children'), [Input('table_selector', 'value')]) @app.callback(Output('company-desritpion', 'children'), [Input('table_selector', 'value')])
def update_graph(selected_dropdown_value): def update_graph(selected_dropdown_value):
@ -209,7 +190,8 @@ def update_graph(selected_dropdown_value):
# [{comp_name}]({url}) # [{comp_name}]({url})
{description} {description}
'''.format(comp_name=comp_name, description=description, url=url)) '''.format(comp_name=comp_name,description=description,url=url))
# Callback for downloading file # Callback for downloading file
@ -271,17 +253,21 @@ def common_table_callback(callback_data_time_period, callback_data_table_selecto
from_time = round_to_nearest_weekday(from_time) from_time = round_to_nearest_weekday(from_time)
to_time = round_to_nearest_weekday(to_time) to_time = round_to_nearest_weekday(to_time)
if change_time_period or selected_stock_in_table_changed: if change_time_period or selected_stock_in_table_changed:
stock_info_in_time_period_df['średnia'] = fullTableDf['Close'].loc[from_time:to_time].mean(axis=0) full_table_in_time_period = fullTableDf.loc[from_time:to_time]
stock_info_in_time_period_df['cena'] = fullTableDf['Close'].loc[fullTableDf.index.max()] mean = full_table_in_time_period.mean(axis=0)
time_period = selected_stock_in_table_df['Close'].loc[from_time:to_time] mean = mean.xs('Close', level=0)
std = full_table_in_time_period.std(axis=0)
std = std.xs('Close', level=0)
time_period = selected_stock_in_table_df.loc[from_time:to_time]
mean = time_period.mean(axis=0) mean = time_period.mean(axis=0)
std = time_period.std(axis=0) std = time_period.std(axis=0)
average_gauge = make_gauge('średnia', 0, mean, 400) # TODO: oblicz stock_info_in_time_period_df tutuaj !!!
volatility_gauge = make_gauge('wolatylność', 0, std, 400) average_gauge = make_gauge('średnia', 0, mean['Close'], 400)
volatility_gauge = make_gauge('wolatylność', 0, std['Close'], 400)
stock_price_table_data = selected_stock_in_table_df.to_dict('records') stock_price_table_data = selected_stock_in_table_df.to_dict('records')
stock_price_table_columns = [{"name": i, "id": i} for i in selected_stock_in_table_df.columns] stock_price_table_columns = [{"name": i, "id": i} for i in selected_stock_in_table_df.columns]
stock_info_in_time_period_data = stock_info_in_time_period_df.to_dict('records') return stock_price_table_data, stock_price_table_columns, average_gauge, volatility_gauge, stock_info_in_time_period_df.T.to_dict(
return stock_price_table_data, stock_price_table_columns, average_gauge, volatility_gauge, stock_info_in_time_period_data 'records')
average_gauge = make_gauge('średnia', 0, 0, 400) average_gauge = make_gauge('średnia', 0, 0, 400)