Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -4,6 +4,7 @@ from collections import defaultdict
|
|
4 |
import streamlit as st
|
5 |
import streamlit.components.v1 as components
|
6 |
import plotly.express as px
|
|
|
7 |
|
8 |
|
9 |
st.set_page_config(page_title='Can you be truly random ?', layout = 'wide', page_icon = 'favicon.jpg', initial_sidebar_state = 'auto')
|
@@ -113,7 +114,16 @@ def user_select(i,choice):
|
|
113 |
update_pnl(user_win=True)
|
114 |
|
115 |
refresh_preds()
|
116 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
|
118 |
|
119 |
if st.session_state.stage == 1:
|
@@ -125,7 +135,7 @@ if st.session_state.stage == 1:
|
|
125 |
col.button(str(i),on_click=user_select, args=[str(i),choice],
|
126 |
use_container_width=True)
|
127 |
|
128 |
-
st.title('My earnings so far... :-)')
|
129 |
st.plotly_chart(px.line(st.session_state.pnl), use_container_width=True)
|
130 |
|
131 |
st.button('Start over', on_click=reset_game, args=[],
|
|
|
4 |
import streamlit as st
|
5 |
import streamlit.components.v1 as components
|
6 |
import plotly.express as px
|
7 |
+
import numpy as np
|
8 |
|
9 |
|
10 |
st.set_page_config(page_title='Can you be truly random ?', layout = 'wide', page_icon = 'favicon.jpg', initial_sidebar_state = 'auto')
|
|
|
114 |
update_pnl(user_win=True)
|
115 |
|
116 |
refresh_preds()
|
117 |
+
|
118 |
+
def compute_perf():
|
119 |
+
data = np.array(st.session_state.pnl)
|
120 |
+
if len(data) > 1:
|
121 |
+
data = data[1:] - data[:-1]
|
122 |
+
perf = data.mean()
|
123 |
+
std = data.std()
|
124 |
+
win = (data>0).mean()
|
125 |
+
sharpe = perf / std
|
126 |
+
return f'%age win={win:.2%} Sharpe={sharpe:.2f}'
|
127 |
|
128 |
|
129 |
if st.session_state.stage == 1:
|
|
|
135 |
col.button(str(i),on_click=user_select, args=[str(i),choice],
|
136 |
use_container_width=True)
|
137 |
|
138 |
+
st.title(f'My earnings so far... {compute_perf()} :-)')
|
139 |
st.plotly_chart(px.line(st.session_state.pnl), use_container_width=True)
|
140 |
|
141 |
st.button('Start over', on_click=reset_game, args=[],
|