omniverse1 commited on
Commit
8b0d75b
·
verified ·
1 Parent(s): 3d7d95e

Update utils.py

Browse files
Files changed (1) hide show
  1. utils.py +31 -0
utils.py CHANGED
@@ -210,3 +210,34 @@ def create_prediction_chart(data, predictions):
210
  fig.add_trace(go.Scatter(x=predictions['dates'], y=lower_band, name='Lower Band', line=dict(color='lightcoral', width=1), fill='tonexty', fillcolor='rgba(255,182,193,0.2)'))
211
  fig.update_layout(title=f'Price Prediction - Next {len(predictions["dates"])} Days', xaxis_title='Date', yaxis_title='Price (IDR)', hovermode='x unified', height=500)
212
  return fig
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
210
  fig.add_trace(go.Scatter(x=predictions['dates'], y=lower_band, name='Lower Band', line=dict(color='lightcoral', width=1), fill='tonexty', fillcolor='rgba(255,182,193,0.2)'))
211
  fig.update_layout(title=f'Price Prediction - Next {len(predictions["dates"])} Days', xaxis_title='Date', yaxis_title='Price (IDR)', hovermode='x unified', height=500)
212
  return fig
213
+
214
+ def create_technical_chart(data, indicators):
215
+ fig = make_subplots(
216
+ rows=2,
217
+ cols=2,
218
+ subplot_titles=('Bollinger Bands', 'Volume', 'Price vs MA', 'RSI Analysis'),
219
+ specs=[[{"secondary_y": False}, {"secondary_y": False}], [{"secondary_y": False}, {"secondary_y": False}]]
220
+ )
221
+
222
+ fig.add_trace(go.Scatter(x=data.index, y=data['Close'], name='Price', line=dict(color='black')), row=1, col=1)
223
+ fig.add_trace(go.Scatter(x=data.index, y=indicators['bollinger']['upper'], name='Upper Band', line=dict(color='red', width=1)), row=1, col=1)
224
+ fig.add_trace(go.Scatter(x=data.index, y=indicators['bollinger']['lower'], name='Lower Band', line=dict(color='green', width=1), fill='tonexty', fillcolor='rgba(0,255,0,0.1)'), row=1, col=1)
225
+
226
+ fig.add_trace(go.Bar(x=data.index, y=data['Volume'], name='Volume', marker_color='lightblue'), row=1, col=2)
227
+
228
+ fig.add_trace(go.Scatter(x=data.index, y=data['Close'], name='Price', line=dict(color='gray')), row=2, col=1)
229
+ fig.add_trace(go.Scatter(x=data.index, y=indicators['moving_averages']['sma_20_values'], name='SMA 20', line=dict(color='orange', dash='dash')), row=2, col=1)
230
+ fig.add_trace(go.Scatter(x=data.index, y=indicators['moving_averages']['sma_50_values'], name='SMA 50', line=dict(color='blue', dash='dash')), row=2, col=1)
231
+
232
+ fig.add_trace(go.Scatter(x=data.index, y=indicators['rsi']['values'], name='RSI', line=dict(color='purple')), row=2, col=2)
233
+ fig.add_hline(y=70, line_dash="dash", line_color="red", row=2, col=2)
234
+ fig.add_hline(y=30, line_dash="dash", line_color="green", row=2, col=2)
235
+
236
+ fig.update_layout(
237
+ title='Technical Indicators Overview',
238
+ height=800,
239
+ showlegend=False,
240
+ hovermode='x unified'
241
+ )
242
+ return fig
243
+