wnstnb commited on
Commit
193ef12
ยท
1 Parent(s): 062c7cc

remove refresh culprit and add em qol

Browse files
Files changed (1) hide show
  1. app.py +46 -31
app.py CHANGED
@@ -8,6 +8,11 @@ from datetime import datetime, time, timedelta
8
  import pytz
9
  import holidays
10
 
 
 
 
 
 
11
  # Function to convert UTC to PST
12
  def convert_to_pst(utc_time):
13
  utc_timezone = pytz.timezone('UTC')
@@ -38,13 +43,13 @@ def convert_to_datetime(time_str, pst_now):
38
 
39
  # Function to determine the emoji for each time
40
  @st.cache_data
41
- def get_time_emojis(times, pst_now):
42
  pst_now_time = pst_now.time()
43
  us_holidays = get_us_holidays()
44
  emojis = []
45
 
46
- for t in times:
47
- time_obj = convert_to_datetime(t, pst_now)
48
 
49
  # Check if the time is less than or equal to the current time in PST
50
  if time_obj.time() <= pst_now_time:
@@ -64,10 +69,6 @@ def get_time_emojis(times, pst_now):
64
  times_list = ['06:30', '07:00', '07:30', '08:00']
65
  emojis_list = get_time_emojis(times_list, pst_now)
66
 
67
- st.set_page_config(
68
- page_title="Gameday $SPX",
69
- page_icon="๐ŸŽฎ"
70
- )
71
 
72
  st.title('๐ŸŽฎ Gameday Model for $SPX')
73
  st.markdown('**PLEASE NOTE:** Model should be run at or after market open. Documentation on the model and its features [can be found here.](https://huggingface.co/spaces/boomsss/gamedayspx/blob/main/README.md)')
@@ -81,7 +82,7 @@ with st.form("choose_model"):
81
 
82
  with col1:
83
  option = st.select_slider(
84
- f"""Slide the scale based on PST, then run [{pst_now.strftime('%H:%M')}]""",
85
  times_list,
86
  format_func=lambda x: f"{emojis_list[times_list.index(x)]} {x}"
87
  )
@@ -540,28 +541,7 @@ with st.form("choose_model"):
540
  data['VIX_EM_125_High'] = data['VIX_EM_125_High'].shift(1)
541
  data['VIX_EM_125_Low'] = data['VIX_EM_125_Low'].shift(1)
542
 
543
- df_em = pd.DataFrame(columns=['EM','Low','High','WithinRange','Tested'])
544
- df_em.loc['EM 1X'] = [
545
- data['VIX_EM'].iloc[-1].round(2),
546
- data['VIX_EM_Low'].iloc[-1].round(2),
547
- data['VIX_EM_High'].iloc[-1].round(2),
548
- f"{len(data.query('Close <= VIX_EM_High & Close >= VIX_EM_Low')) / len(data):.1%}",
549
- f"{len(data.query('High > VIX_EM_High | Low < VIX_EM_Low')) / len(data):.1%}"
550
- ]
551
- df_em.loc['EM 1.25X'] = [
552
- data['VIX_EM_125'].iloc[-1].round(2),
553
- data['VIX_EM_125_Low'].iloc[-1].round(2),
554
- data['VIX_EM_125_High'].iloc[-1].round(2),
555
- f"{len(data.query('Close <= VIX_EM_125_High & Close >= VIX_EM_125_Low')) / len(data):.1%}",
556
- f"{len(data.query('High > VIX_EM_125_High | Low < VIX_EM_125_Low')) / len(data):.1%}"
557
- ]
558
- df_em.loc[f"EM 1.5X"] = [
559
- data['VIX_EM_15'].iloc[-1].round(2),
560
- data['VIX_EM_15_Low'].iloc[-1].round(2),
561
- data['VIX_EM_15_High'].iloc[-1].round(2),
562
- f"{len(data.query('Close <= VIX_EM_15_High & Close >= VIX_EM_15_Low')) / len(data):.1%}",
563
- f"{len(data.query('High > VIX_EM_15_High | Low < VIX_EM_15_Low')) / len(data):.1%}"
564
- ]
565
 
566
  # Cache all DFs
567
  all_dfs = []
@@ -573,8 +553,43 @@ with st.form("choose_model"):
573
  with tab1:
574
  st.dataframe(prices.T.set_index('PrevClose', drop=True))
575
  st.write(df_probas)
576
- st.text(f'VIX EM ({curr_em:.2f} / {fwd_em:.2f})')
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
577
  st.write(df_em)
 
578
  with tab2:
579
  st.subheader('Latest Data for Pred')
580
  st.write(new_pred)
 
8
  import pytz
9
  import holidays
10
 
11
+ st.set_page_config(
12
+ page_title="Gameday $SPX",
13
+ page_icon="๐ŸŽฎ"
14
+ )
15
+
16
  # Function to convert UTC to PST
17
  def convert_to_pst(utc_time):
18
  utc_timezone = pytz.timezone('UTC')
 
43
 
44
  # Function to determine the emoji for each time
45
  @st.cache_data
46
+ def get_time_emojis(_times, _pst_now):
47
  pst_now_time = pst_now.time()
48
  us_holidays = get_us_holidays()
49
  emojis = []
50
 
51
+ for t in _times:
52
+ time_obj = convert_to_datetime(t, _pst_now)
53
 
54
  # Check if the time is less than or equal to the current time in PST
55
  if time_obj.time() <= pst_now_time:
 
69
  times_list = ['06:30', '07:00', '07:30', '08:00']
70
  emojis_list = get_time_emojis(times_list, pst_now)
71
 
 
 
 
 
72
 
73
  st.title('๐ŸŽฎ Gameday Model for $SPX')
74
  st.markdown('**PLEASE NOTE:** Model should be run at or after market open. Documentation on the model and its features [can be found here.](https://huggingface.co/spaces/boomsss/gamedayspx/blob/main/README.md)')
 
82
 
83
  with col1:
84
  option = st.select_slider(
85
+ f"""Slide the scale based on PST, then run.""",
86
  times_list,
87
  format_func=lambda x: f"{emojis_list[times_list.index(x)]} {x}"
88
  )
 
541
  data['VIX_EM_125_High'] = data['VIX_EM_125_High'].shift(1)
542
  data['VIX_EM_125_Low'] = data['VIX_EM_125_Low'].shift(1)
543
 
544
+
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
545
 
546
  # Cache all DFs
547
  all_dfs = []
 
553
  with tab1:
554
  st.dataframe(prices.T.set_index('PrevClose', drop=True))
555
  st.write(df_probas)
556
+
557
+ em_option = st.radio(f'๐ŸŒŠ VIX EM',['Curr','Fwd'],horizontal=True)
558
+ em_use = None
559
+ close_use = None
560
+ if em_option == 'Curr':
561
+ em_use = curr_em
562
+ close_use = prev_close
563
+
564
+ elif em_option == 'Fwd':
565
+ em_use = fwd_em
566
+ close_use = curr_close
567
+
568
+ df_em = pd.DataFrame(columns=['EM','Low','High','WithinRange','Tested'])
569
+ df_em.index.name = f'{close_use:.2f}'
570
+ df_em.loc['EM 1X'] = [
571
+ f"{em_use:.2f} ({em_use / close_use:.1%})",
572
+ f"{close_use - em_use:.2f}",
573
+ f"{close_use + em_use:.2f}",
574
+ f"{len(data.query('Close <= VIX_EM_High & Close >= VIX_EM_Low')) / len(data):.1%}",
575
+ f"{len(data.query('High > VIX_EM_High | Low < VIX_EM_Low')) / len(data):.1%}"
576
+ ]
577
+ df_em.loc['EM 1.25X'] = [
578
+ f"{curr_em * 1.25:.2f} ({(em_use * 1.25) / close_use:.1%})",
579
+ f"{close_use - (em_use * 1.25):.2f}",
580
+ f"{close_use + (em_use * 1.25):.2f}",
581
+ f"{len(data.query('Close <= VIX_EM_125_High & Close >= VIX_EM_125_Low')) / len(data):.1%}",
582
+ f"{len(data.query('High > VIX_EM_125_High | Low < VIX_EM_125_Low')) / len(data):.1%}"
583
+ ]
584
+ df_em.loc[f"EM 1.5X"] = [
585
+ f"{curr_em * 1.5:.2f} ({(em_use * 1.5) / close_use:.1%})",
586
+ f"{close_use - (em_use * 1.5):.2f}",
587
+ f"{close_use + (em_use * 1.5):.2f}",
588
+ f"{len(data.query('Close <= VIX_EM_15_High & Close >= VIX_EM_15_Low')) / len(data):.1%}",
589
+ f"{len(data.query('High > VIX_EM_15_High | Low < VIX_EM_15_Low')) / len(data):.1%}"
590
+ ]
591
  st.write(df_em)
592
+
593
  with tab2:
594
  st.subheader('Latest Data for Pred')
595
  st.write(new_pred)