AutoAgent for prediction market strategy discovery. Can an AI agent, given only raw weather data and market prices, autonomously discover a profitable Kalshi trading strategy?
Forked from kevinrgu/autoagent.
A meta-agent loop that iterates on a prediction market trading agent harness overnight. The meta-agent modifies the system prompt, tools, and strategy logic in agent.py, runs backtests, checks the score (PnL), and keeps or discards changes.
The trading agent gets access to:
- Weather observations (Therminal API / local parquets) — temperature, humidity, wind, pressure
- Kalshi OHLCV market data — 1-minute candles with real bracket definitions
- Backtester — simulates limit order fills, settles against real brackets, computes PnL after fees
- Python execution — for custom analysis
It does NOT get pre-built models, features, or existing strategies. It discovers edges from raw data.
This repo requires data from mostly-harmless-v2:
~/Documents/GitHub/mostly-harmless-v2/data/
├── raw/ohlcv/ # Kalshi OHLCV candles per city series
│ ├── kxhighny/ # NYC: KXHIGHNY-26MAR19_1m.parquet, ...
│ ├── kxhighchi/ # Chicago
│ └── ... # 20 cities total
├── raw/observations_therminal/ # Hourly weather observations
│ ├── nyc_metro/ # NYC_2024.parquet, NYC_2025.parquet, ...
│ ├── chicago_metro/
│ └── ...
└── raw/cli_ncei/ # Settlement ground truth (NWS CLI daily high)
Set the path in .env:
cp .env.example .env
# Edit MH_DATA_ROOT to point to your data directoryagent.py — trading strategy agent harness (meta-agent edits this)
backtester.py — clean Kalshi settlement engine (ground truth, don't modify)
test_backtester.py — settlement logic tests
program.md — meta-agent directive (human edits this)
tasks/ — evaluation tasks (NYC, Chicago, Miami, multi-city)
.env.example — required environment variables
The backtester handles the tricky parts of Kalshi weather markets correctly:
- Real bracket definitions from each OHLCV file (not hardcoded alignment)
- Even AND odd alignment — bracket floors vary per event (e.g., [66,67] vs [67,68])
- Settlement:
round(actual_temp)checked against[floor, cap]inclusive - Tail brackets: lower
≤ cap, upper≥ floor - Fill simulation: scans post-prediction candles for limit order fills
- Kalshi fees: taker
ceil(7 * N * p * (1-p)) / 100, makerceil(1.75 * ...)
# 1. Clone and set up
git clone git@github.com:helloiamvu/mostly-autoagent.git
cd mostly-autoagent
cp .env.example .env
# Edit .env with your data path and API key
# 2. Install deps
uv sync
# 3. Run the meta-agent
# Point Claude Code at the repo and say:
# "Read program.md and let's kick off a new experiment!"from backtester import Backtester
bt = Backtester(ohlcv_dir="path/to/ohlcv/kxhighny")
signals = [
{"date": "2026-03-19", "market": "KXHIGHNY-26MAR19-B47.5",
"side": "YES", "limit_price": 0.40, "actual_temp": 48.0},
]
trades, summary = bt.run(signals)
print(summary) # {'score': ..., 'win_rate': ..., 'n_trades': ...}MIT (our additions) + LGPL-3.0 (upstream AutoAgent/NautilusTrader portions)