Geek7 commited on
Commit
ff1d16b
·
verified ·
1 Parent(s): dd448e5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -1
app.py CHANGED
@@ -12,6 +12,12 @@ def fetch_alpha_vantage_data(api_key):
12
  alpha_vantage_data = response.json()
13
  return alpha_vantage_data
14
 
 
 
 
 
 
 
15
  def main():
16
  st.title("Stock Trend Predictor")
17
 
@@ -27,11 +33,14 @@ def main():
27
  df.index = pd.to_datetime(df.index)
28
  df = df.dropna(axis=0)
29
 
 
 
 
30
  # Create predictor
31
  my_market_predictor = Pandas_Market_Predictor(df)
32
 
33
  # Predict Trend
34
- indicators = ["Indicator1", "Indicator2"]
35
  trend = my_market_predictor.Trend_Detection(indicators, 10)
36
 
37
  # Display results
 
12
  alpha_vantage_data = response.json()
13
  return alpha_vantage_data
14
 
15
+ def calculate_indicators(data):
16
+ # Example: Simple condition for doji and inside
17
+ data['Doji'] = abs(data['4. close'] - data['1. open']) <= 0.01 * (data['2. high'] - data['3. low'])
18
+ data['Inside'] = (data['2. high'] < data['3. high']) & (data['2. low'] > data['3. low'])
19
+ return data
20
+
21
  def main():
22
  st.title("Stock Trend Predictor")
23
 
 
33
  df.index = pd.to_datetime(df.index)
34
  df = df.dropna(axis=0)
35
 
36
+ # Calculate indicators
37
+ df = calculate_indicators(df)
38
+
39
  # Create predictor
40
  my_market_predictor = Pandas_Market_Predictor(df)
41
 
42
  # Predict Trend
43
+ indicators = ["Doji", "Inside"]
44
  trend = my_market_predictor.Trend_Detection(indicators, 10)
45
 
46
  # Display results