-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathapp.py
More file actions
66 lines (53 loc) · 2.03 KB
/
app.py
File metadata and controls
66 lines (53 loc) · 2.03 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
import streamlit as st
import pandas as pd
from src.agent import MarketRegimeAgent
st.set_page_config(page_title="Market Regime Agent", layout="wide")
st.title("📈 Market Regime Agent (v1)")
st.caption("Deterministic signals + JSON memory. Observe → Reason → Act → Remember.")
uploaded = st.file_uploader("Upload prices CSV (wide format: date, SPY, QQQ, IWM, TLT, GLD...)", type=["csv"])
memory_path = st.text_input("Memory file path", value="state/memory.json")
agent = MarketRegimeAgent(memory_path=memory_path)
if uploaded is None:
st.info("Upload a CSV to run. Example path: data/sample_prices.csv")
if st.button("Load sample CSV (data/sample_prices.csv)"):
df = pd.read_csv("data/sample_prices.csv")
decision, action = agent.run(df)
st.success("Ran on sample data.")
else:
st.stop()
else:
df = pd.read_csv(uploaded)
decision, action = agent.run(df)
st.success("Ran on uploaded data.")
left, right = st.columns([1, 1])
with left:
st.subheader("Regime Decision")
st.write(f"**As of:** {decision.asof}")
st.write(f"**Label:** {decision.label}")
st.write(f"**Confidence:** {decision.confidence:.2f}")
st.subheader("Drivers")
for d in decision.drivers:
st.write(f"- {d}")
st.subheader("Implications")
for i in decision.implications:
st.write(f"- {i}")
with right:
st.subheader("Signals")
s = decision.signals
st.write({
"trend": s.trend,
"trend_strength": s.trend_strength,
"realized_vol_annual": s.realized_vol_annual,
"breadth_pct_above_ma50": s.breadth_pct_above_ma50,
"risk_on_off": s.risk_on_off,
"risk_on_off_score": s.risk_on_off_score
})
st.subheader("Agent Action")
st.write(action)
st.subheader("Latest Memory Snapshot")
st.write({
"last_regime_label": agent.memory.last_regime_label,
"last_regime_asof": agent.memory.last_regime_asof,
"last_alert_asof": agent.memory.last_alert_asof,
"history_len": len(agent.memory.history)
})