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
app = dash.Dash(__name__)
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['tracker'] = stock_info_in_time_period_df.index
stock_info_in_time_period_df = pd.DataFrame(columns=stock_list, index=["średnia", "cena", "dywidenda", "wolatylność"])
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)
@ -141,30 +140,11 @@ app.layout = html.Div(
]),
dash_table.DataTable(
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_cell={
'backgroundColor': 'rgb(50, 50, 50)',
'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',
@ -195,6 +175,7 @@ app.layout = html.Div(
)
# Callback for scraping company description
@app.callback(Output('company-desritpion', 'children'), [Input('table_selector', 'value')])
def update_graph(selected_dropdown_value):
@ -203,14 +184,15 @@ def update_graph(selected_dropdown_value):
soup = BeautifulSoup(page.content, 'html.parser')
comp_name = soup.find(id="Main").h3.text
description = soup.find_all('section', class_='quote-sub-section')[0].p.text
return dcc.Markdown('''
# [{comp_name}]({url})
{description}
'''.format(comp_name=comp_name, description=description, url=url))
'''.format(comp_name=comp_name,description=description,url=url))
# Callback for downloading file
@app.callback(
@ -271,17 +253,21 @@ def common_table_callback(callback_data_time_period, callback_data_table_selecto
from_time = round_to_nearest_weekday(from_time)
to_time = round_to_nearest_weekday(to_time)
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)
stock_info_in_time_period_df['cena'] = fullTableDf['Close'].loc[fullTableDf.index.max()]
time_period = selected_stock_in_table_df['Close'].loc[from_time:to_time]
full_table_in_time_period = fullTableDf.loc[from_time:to_time]
mean = full_table_in_time_period.mean(axis=0)
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)
std = time_period.std(axis=0)
average_gauge = make_gauge('średnia', 0, mean, 400)
volatility_gauge = make_gauge('wolatylność', 0, std, 400)
# TODO: oblicz stock_info_in_time_period_df tutuaj !!!
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_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_data
return stock_price_table_data, stock_price_table_columns, average_gauge, volatility_gauge, stock_info_in_time_period_df.T.to_dict(
'records')
average_gauge = make_gauge('średnia', 0, 0, 400)