Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -52,12 +52,15 @@ ibkr_df = get_ibkr_parquet()
|
|
| 52 |
|
| 53 |
|
| 54 |
st.title('Trades')
|
|
|
|
| 55 |
trade_opt = st.selectbox(
|
| 56 |
'Select Trade Pair',
|
| 57 |
list(trade_df.currency_pair.unique())
|
| 58 |
)
|
| 59 |
|
| 60 |
params = trade_ibkr_dict[trade_opt]
|
|
|
|
|
|
|
| 61 |
if params[2] == 'normal':
|
| 62 |
tmp_df = fx_pair(trade_df,ibkr_df,trade_opt,params[0],inv=params[1])
|
| 63 |
min_y = tmp_df.premium.min()
|
|
@@ -83,7 +86,7 @@ if params[2] == 'normal':
|
|
| 83 |
y = 'independent'
|
| 84 |
)
|
| 85 |
st.altair_chart(op.interactive(),use_container_width=True)
|
| 86 |
-
|
| 87 |
|
| 88 |
elif params[2] == 'stable':
|
| 89 |
tmp_df = trade_df[trade_df.currency_pair==trade_opt]
|
|
@@ -113,6 +116,18 @@ elif params[2] == 'cross':
|
|
| 113 |
y = 'independent'
|
| 114 |
)
|
| 115 |
st.altair_chart(op.interactive(), use_container_width=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 116 |
|
| 117 |
|
| 118 |
#show_df = trade_df[trade_df.currency_pair==trade_opt]
|
|
|
|
| 52 |
|
| 53 |
|
| 54 |
st.title('Trades')
|
| 55 |
+
st.markdown('**Premium**')
|
| 56 |
trade_opt = st.selectbox(
|
| 57 |
'Select Trade Pair',
|
| 58 |
list(trade_df.currency_pair.unique())
|
| 59 |
)
|
| 60 |
|
| 61 |
params = trade_ibkr_dict[trade_opt]
|
| 62 |
+
trade_for_vis = trade_df[trade_df.currency_pair==trade_opt]
|
| 63 |
+
|
| 64 |
if params[2] == 'normal':
|
| 65 |
tmp_df = fx_pair(trade_df,ibkr_df,trade_opt,params[0],inv=params[1])
|
| 66 |
min_y = tmp_df.premium.min()
|
|
|
|
| 86 |
y = 'independent'
|
| 87 |
)
|
| 88 |
st.altair_chart(op.interactive(),use_container_width=True)
|
| 89 |
+
|
| 90 |
|
| 91 |
elif params[2] == 'stable':
|
| 92 |
tmp_df = trade_df[trade_df.currency_pair==trade_opt]
|
|
|
|
| 116 |
y = 'independent'
|
| 117 |
)
|
| 118 |
st.altair_chart(op.interactive(), use_container_width=True)
|
| 119 |
+
if params[2] != 'stable':
|
| 120 |
+
st.markdown('**Price**')
|
| 121 |
+
trade_for_vis = trade_for_vis.loc[str(ibkr_df.index[0]):str(ibkr_df.index[-1])]
|
| 122 |
+
trade_min = trade_for_vis['price'].min()
|
| 123 |
+
trade_max = trade_for_vis['price'].max()
|
| 124 |
+
|
| 125 |
+
trade_sc = alt.Chart(trade_for_vis).mark_circle().encode(
|
| 126 |
+
x='time', y=alt.Y('price', scale=alt.Scale(domain=[trade_min, trade_max])),
|
| 127 |
+
size='amount', color='side', tooltip=['time', 'price', 'side','amount']
|
| 128 |
+
)
|
| 129 |
+
layered = alt.layer(trade_sc,line)
|
| 130 |
+
st.altair_chart(layered.interactive(),use_container_width=True)
|
| 131 |
|
| 132 |
|
| 133 |
#show_df = trade_df[trade_df.currency_pair==trade_opt]
|