netflypsb commited on
Commit
7181b7f
·
verified ·
1 Parent(s): 6fd0501

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -4
app.py CHANGED
@@ -20,16 +20,17 @@ def identify_signals(data):
20
  def collect_signals(data):
21
  signals = pd.DataFrame()
22
  signals['Date'] = data.index
23
- signals['Price'] = data['Close']
24
- signals['Signal'] = None # Initialize all to None
25
 
 
 
26
  buy_indices = data[data['Buy Signal']].index
27
  sell_indices = data[data['Sell Signal']].index
28
 
29
  signals.loc[signals['Date'].isin(buy_indices), 'Signal'] = 'Buy'
30
  signals.loc[signals['Date'].isin(sell_indices), 'Signal'] = 'Sell'
31
 
32
- signals = signals.dropna(subset=['Signal'])
33
 
34
  return signals
35
 
@@ -58,7 +59,6 @@ def main():
58
  5. **Review the Outputs:** The chart and the signals table provide visual and data-driven insights respectively.
59
  """)
60
 
61
- # Sidebar for user inputs
62
  with st.sidebar:
63
  ticker = st.text_input("Enter the ticker symbol, e.g., 'AAPL'")
64
  start_date = st.date_input("Select the start date")
 
20
  def collect_signals(data):
21
  signals = pd.DataFrame()
22
  signals['Date'] = data.index
23
+ signals['Price'] = data['Close'] # This will now display the price at which the signal was triggered
 
24
 
25
+ # Initialize all signals to None and update based on the data's indices
26
+ signals['Signal'] = None
27
  buy_indices = data[data['Buy Signal']].index
28
  sell_indices = data[data['Sell Signal']].index
29
 
30
  signals.loc[signals['Date'].isin(buy_indices), 'Signal'] = 'Buy'
31
  signals.loc[signals['Date'].isin(sell_indices), 'Signal'] = 'Sell'
32
 
33
+ signals = signals.dropna(subset=['Signal']) # Ensure that only rows with signals are kept
34
 
35
  return signals
36
 
 
59
  5. **Review the Outputs:** The chart and the signals table provide visual and data-driven insights respectively.
60
  """)
61
 
 
62
  with st.sidebar:
63
  ticker = st.text_input("Enter the ticker symbol, e.g., 'AAPL'")
64
  start_date = st.date_input("Select the start date")