Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- def update_main_ohlc_fig(selected_stock,stock_data,):
- stock_index = stocks.index(selected_stock)
- open_values = np.array(list(stock_data['volume'][f'stock{stock_index}_volume_df']['open'].values()))
- close_values = np.array(list(stock_data['volume'][f'stock{stock_index}_volume_df']['close'].values()))
- pos = open_values < close_values
- neg = open_values > close_values
- x_new_volume = np.array(list(stock_data['volume'][f'stock{stock_index}_volume_df']['time'].values()))
- volume_diff_values = np.array(list(stock_data['volume'][f'stock{stock_index}_volume_df']['volume_diff'].values()))
- new_volume_pos_x_axis = x_new_volume[pos] if not np.all(pos == False) else None
- new_volume_pos_y_axis = volume_diff_values[pos] if not np.all(pos == False) else None
- new_volume_neg_x_axis = x_new_volume[neg] if not np.all(neg == False) else None
- new_volume_neg_y_axis = volume_diff_values[neg] if not np.all(neg == False) else None
- latest_price = stock_data['last_price'][f'stock{stock_index}_last_price_df'][stocks[stock_index]+'_price']
- latest_price_change = stock_data['last_price_change'][f'stock{stock_index}_last_price_change_df'][stocks[stock_index]+'_price_change']
- main_fig_ohlc_tracer = {'x':list(stock_data['ohlc'][f'stock{stock_index}_ohlc_df']['time'].values()),
- 'open':list(stock_data['ohlc'][f'stock{stock_index}_ohlc_df']['open'].values()),
- 'high':list(stock_data['ohlc'][f'stock{stock_index}_ohlc_df']['high'].values()),
- 'low':list(stock_data['ohlc'][f'stock{stock_index}_ohlc_df']['low'].values()),
- 'close':list(stock_data['ohlc'][f'stock{stock_index}_ohlc_df']['close'].values())}
- main_fig_ma5_tracer = { 'x':list(stock_data['ma5'][f'stock{stock_index}_ma5_df']['time'].values()),
- 'y':list(stock_data['ma5'][f'stock{stock_index}_ma5_df']['MA5'].values())}
- main_fig_ma10_tracer = {'x':list(stock_data['ma10'][f'stock{stock_index}_ma10_df']['time'].values()),
- 'y':list(stock_data['ma10'][f'stock{stock_index}_ma10_df']['MA10'].values())}
- new_ma20_data = {'x':list(stock_data['ma20'][f'stock{stock_index}_ma20_df']['time'].values()),
- 'y':list(stock_data['ma20'][f'stock{stock_index}_ma20_df']['MA20'].values())}
- main_fig_volume_diff_pos_tracer = {'x':new_volume_pos_x_axis,
- 'y':new_volume_pos_y_axis}
- main_fig_volume_diff_neg_tracer = {'x':new_volume_neg_x_axis,
- 'y':new_volume_neg_y_axis}
- main_fig_rsi_tracer = {'x':new_volume_neg_x_axis,
- 'y':new_volume_neg_y_axis}
- return [main_fig_ohlc_tracer, main_fig_ma5_tracer, main_fig_ma10_tracer, new_ma20_data, main_fig_volume_diff_pos_tracer ,main_fig_volume_diff_neg_tracer, main_fig_rsi_tracer],\
- latest_price, latest_price_change,{'color': '#18b800' if latest_price_change[stock_index] == '+' else '#ff3503','fontSize': '20px'}
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement