riteshcp commited on
Commit
8b1dbf3
·
verified ·
1 Parent(s): 155836b

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
app.py CHANGED
@@ -79,7 +79,7 @@ def plot_charts(data, symbol, interval):
79
  subplot_titles = ('Price & Volume', 'RSI', 'MACD', 'On-Balance Volume (OBV)')
80
  row_heights = [0.35, 0.15, 0.15, 0.35]
81
  else:
82
- rows = 5 # Added two extra rows for OBV and Bollinger Bands
83
  subplot_titles = ('Price & Volume', 'RSI', 'MACD', 'Bollinger Bands', 'On-Balance Volume (OBV)')
84
  row_heights = [0.3, 0.15, 0.15, 0.2, 0.2]
85
 
@@ -204,6 +204,7 @@ def main():
204
  else:
205
  daily_change = 0.0 # Not enough data to calculate change
206
 
 
207
  col1, col2, col3, col4, col5 = st.columns(5)
208
  col1.metric("Current Price", f"₹{current_price:.2f}", f"{daily_change:.2f}%")
209
 
@@ -245,7 +246,6 @@ def main():
245
 
246
  # SMA Signals
247
  if 'SMA_20' in data.columns and 'SMA_50' in data.columns:
248
- current_price = data['Close'][-1]
249
  sma_20 = data['SMA_20'][-1]
250
  sma_50 = data['SMA_50'][-1]
251
 
@@ -255,16 +255,16 @@ def main():
255
  signals.append("Price is below major moving averages - Bearish")
256
 
257
  # OBV Signals
258
- if 'OBV' in data.columns:
259
  obv = data['OBV'][-1]
260
- obv_prev = data['OBV'][-2] if len(data) >= 2 else obv
261
  if obv > obv_prev:
262
  signals.append("OBV is increasing - Positive volume trend")
263
  elif obv < obv_prev:
264
  signals.append("OBV is decreasing - Negative volume trend")
265
 
266
  # Bollinger Bands Signals
267
- if rows == 5:
268
  price = data['Close'][-1]
269
  bb_upper = data['BB_upper'][-1]
270
  bb_lower = data['BB_lower'][-1]
 
79
  subplot_titles = ('Price & Volume', 'RSI', 'MACD', 'On-Balance Volume (OBV)')
80
  row_heights = [0.35, 0.15, 0.15, 0.35]
81
  else:
82
+ rows = 5 # Added two extra rows for Bollinger Bands and OBV
83
  subplot_titles = ('Price & Volume', 'RSI', 'MACD', 'Bollinger Bands', 'On-Balance Volume (OBV)')
84
  row_heights = [0.3, 0.15, 0.15, 0.2, 0.2]
85
 
 
204
  else:
205
  daily_change = 0.0 # Not enough data to calculate change
206
 
207
+ # Initialize five columns, but OBV may not always be present
208
  col1, col2, col3, col4, col5 = st.columns(5)
209
  col1.metric("Current Price", f"₹{current_price:.2f}", f"{daily_change:.2f}%")
210
 
 
246
 
247
  # SMA Signals
248
  if 'SMA_20' in data.columns and 'SMA_50' in data.columns:
 
249
  sma_20 = data['SMA_20'][-1]
250
  sma_50 = data['SMA_50'][-1]
251
 
 
255
  signals.append("Price is below major moving averages - Bearish")
256
 
257
  # OBV Signals
258
+ if 'OBV' in data.columns and len(data) >= 2:
259
  obv = data['OBV'][-1]
260
+ obv_prev = data['OBV'][-2]
261
  if obv > obv_prev:
262
  signals.append("OBV is increasing - Positive volume trend")
263
  elif obv < obv_prev:
264
  signals.append("OBV is decreasing - Negative volume trend")
265
 
266
  # Bollinger Bands Signals
267
+ if interval not in minute_intervals:
268
  price = data['Close'][-1]
269
  bb_upper = data['BB_upper'][-1]
270
  bb_lower = data['BB_lower'][-1]