AJAY KASU commited on
Commit ·
30c7379
1
Parent(s): 81146df
Fix UI state reset by using st.session_state for portfolio variables
Browse files
app.py
CHANGED
|
@@ -9,6 +9,15 @@ from src.strategies.arbitrage import CrossPlatformArbitrage
|
|
| 9 |
|
| 10 |
st.set_page_config(page_title="ArbIntel Scanner", layout="wide", page_icon="📈")
|
| 11 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 12 |
st.title("ArbIntel: Prediction Markets Alpha Engine")
|
| 13 |
st.markdown("### Live Cross-Platform Arbitrage Scanner")
|
| 14 |
st.write("Detecting price inefficiencies between Polymarket and Kalshi in real-time.")
|
|
@@ -54,6 +63,13 @@ if st.button("Run Live Arbitrage Scan", type="primary"):
|
|
| 54 |
|
| 55 |
st.markdown("#### Execute Paper Trade")
|
| 56 |
if st.button("Auto-Execute All"):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 57 |
st.info("Paper Trading Engine simulated execution successfully. Portfolios updated.")
|
| 58 |
else:
|
| 59 |
st.info("No active opportunities detected above risk-free threshold (markets efficient).")
|
|
@@ -61,7 +77,8 @@ if st.button("Run Live Arbitrage Scan", type="primary"):
|
|
| 61 |
st.markdown("---")
|
| 62 |
st.markdown("### Portfolio & Risk Metrics")
|
| 63 |
col1, col2, col3, col4 = st.columns(4)
|
| 64 |
-
|
| 65 |
-
|
| 66 |
-
|
|
|
|
| 67 |
col4.metric("Market Regime", "Stable", "-Vol")
|
|
|
|
| 9 |
|
| 10 |
st.set_page_config(page_title="ArbIntel Scanner", layout="wide", page_icon="📈")
|
| 11 |
|
| 12 |
+
if "capital" not in st.session_state:
|
| 13 |
+
st.session_state.capital = 10000.00
|
| 14 |
+
if "pnl" not in st.session_state:
|
| 15 |
+
st.session_state.pnl = 0.00
|
| 16 |
+
if "positions" not in st.session_state:
|
| 17 |
+
st.session_state.positions = []
|
| 18 |
+
if "trades" not in st.session_state:
|
| 19 |
+
st.session_state.trades = []
|
| 20 |
+
|
| 21 |
st.title("ArbIntel: Prediction Markets Alpha Engine")
|
| 22 |
st.markdown("### Live Cross-Platform Arbitrage Scanner")
|
| 23 |
st.write("Detecting price inefficiencies between Polymarket and Kalshi in real-time.")
|
|
|
|
| 63 |
|
| 64 |
st.markdown("#### Execute Paper Trade")
|
| 65 |
if st.button("Auto-Execute All"):
|
| 66 |
+
for o in opps:
|
| 67 |
+
profit = o.expected_profit_margin * o.buy_size
|
| 68 |
+
st.session_state.pnl += profit
|
| 69 |
+
st.session_state.capital += profit
|
| 70 |
+
if o.market_id_pm not in st.session_state.positions:
|
| 71 |
+
st.session_state.positions.append(o.market_id_pm)
|
| 72 |
+
st.session_state.trades.append(o)
|
| 73 |
st.info("Paper Trading Engine simulated execution successfully. Portfolios updated.")
|
| 74 |
else:
|
| 75 |
st.info("No active opportunities detected above risk-free threshold (markets efficient).")
|
|
|
|
| 77 |
st.markdown("---")
|
| 78 |
st.markdown("### Portfolio & Risk Metrics")
|
| 79 |
col1, col2, col3, col4 = st.columns(4)
|
| 80 |
+
pnl_sign = "+" if st.session_state.pnl >= 0 else "-"
|
| 81 |
+
col1.metric("Available Capital", f"${st.session_state.capital:,.2f}", f"{pnl_sign}${abs(st.session_state.pnl):,.2f}")
|
| 82 |
+
col2.metric("Active Positions", str(len(st.session_state.positions)))
|
| 83 |
+
col3.metric("24h PnL", f"${st.session_state.pnl:,.2f}")
|
| 84 |
col4.metric("Market Regime", "Stable", "-Vol")
|