Track and analyze your prediction market trades from Interactive Brokers (IBKR).
uv tool install git+https://github.com/plwg/bettrack# Sync trades directly from IBKR (recommended)
bettrack sync
# Or import from CSV file
bettrack import trades.csv
# Launch interactive TUI dashboard
bettrackFetch trades directly from IBKR using the Flex Web Service API. This is the easiest way to keep your data up to date.
-
Create a Flex Query in IBKR Client Portal:
- Go to Reporting > Flex Queries > Create Activity Flex Query
- Include the "Trades" section with fields: Symbol, Description, DateTime, Quantity, TradePrice, Notes/Codes
- Save the query and note the Query ID
-
Generate a Flex Web Service token:
- Go to Settings > Reporting > Flex Web Service
- Generate a new token (1-year validity recommended)
-
Configure bettrack:
cp .env_template .env
Edit
.envwith your credentials:IBKR_FLEX_TOKEN=your_token_here IBKR_FLEX_QUERY_ID=your_query_id_here
bettrack syncThis fetches all trades from IBKR and merges them with your local data.
- Log in to IBKR Client Portal
- Go to Reports > Activity
- Set the date range to cover your prediction market trades
- Export as CSV
- Import:
bettrack import trades.csv
Run bettrack sync to fetch the latest trades and resolution status from IBKR.
The sync automatically merges new data with existing positions:
- New positions are added
- Existing positions are updated if resolution status changed (e.g., PENDING -> WON/LOST)
- Duplicate trades are ignored
Data is stored locally in JSON format:
~/.bettrack/trades.json
- Track positions: Won, Lost, Pending, and Hedged
- Hedged position detection: Automatically identifies when you hold both YES and NO on the same question
- Calibration analysis: probability bucket and edge breakdown
- Profit tracking: ROI, P/L by outcome type
- Interactive TUI with filtering and multiple views