AISparking commited on
Commit
77d4950
·
verified ·
1 Parent(s): 7f31a7f

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -28,12 +28,12 @@ def safe_execute(func):
28
  return wrapper
29
 
30
  @safe_execute
31
- def get_stock_data(symbol, market):
32
  if market == 'HK':
33
  symbol = f'{symbol}.HK'
34
 
35
  end_date = datetime.now()
36
- start_date = end_date - timedelta(days=3*365)
37
 
38
  df = yf.download(symbol, start=start_date, end=end_date)
39
  if df.empty:
@@ -218,15 +218,16 @@ st.title('Advanced Stock Technical Analysis')
218
  with st.sidebar:
219
  st.header('Input Parameters')
220
  market = st.selectbox('Select Market', ['HK','US'])
221
- symbol = st.text_input('Enter Stock Symbol:')
222
 
223
  # Add analysis timeframe option
224
- timeframe = st.selectbox('Select Timeframe', ['1y', '2y', '3y'])
 
225
 
226
  if st.sidebar.button('Analyze'):
227
  if symbol:
228
  with st.spinner('Fetching and analyzing data...'):
229
- df = get_stock_data(symbol, market)
230
 
231
  if df is not None:
232
  df = calculate_all_indicators(df)
@@ -473,5 +474,4 @@ with st.sidebar:
473
  st.warning("⚠️ Disclaimer: This is for AI Research and Learning purposes only. DO NOT make any investment decisions according to the displayed information and analysis result.")
474
 
475
  st.markdown("---")
476
- st.write("https://www.facebook.com/AIsparking")
477
-
 
28
  return wrapper
29
 
30
  @safe_execute
31
+ def get_stock_data(symbol, market, nYear):
32
  if market == 'HK':
33
  symbol = f'{symbol}.HK'
34
 
35
  end_date = datetime.now()
36
+ start_date = end_date - timedelta(days=nYear*365)
37
 
38
  df = yf.download(symbol, start=start_date, end=end_date)
39
  if df.empty:
 
218
  with st.sidebar:
219
  st.header('Input Parameters')
220
  market = st.selectbox('Select Market', ['HK','US'])
221
+ symbol = st.text_input('Enter Stock Symbol (e.g. 0700 for HK):')
222
 
223
  # Add analysis timeframe option
224
+ timeframe = st.selectbox('Select Timeframe', ['1y','2y','3y','5y','8y','10y'])
225
+ nYear = int(timeframe.split("y")[0])
226
 
227
  if st.sidebar.button('Analyze'):
228
  if symbol:
229
  with st.spinner('Fetching and analyzing data...'):
230
+ df = get_stock_data(symbol, market,nYear)
231
 
232
  if df is not None:
233
  df = calculate_all_indicators(df)
 
474
  st.warning("⚠️ Disclaimer: This is for AI Research and Learning purposes only. DO NOT make any investment decisions according to the displayed information and analysis result.")
475
 
476
  st.markdown("---")
477
+ st.write("https://www.facebook.com/AIsparking")