Skip to content

plwg/bettrack

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

25 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Bettrack - Prediction Market Calibration Tracker

Track and analyze your prediction market trades from Interactive Brokers (IBKR).

Installation

uv tool install git+https://github.com/plwg/bettrack

Usage

# Sync trades directly from IBKR (recommended)
bettrack sync

# Or import from CSV file
bettrack import trades.csv

# Launch interactive TUI dashboard
bettrack

Data Sources

Option 1: Direct Sync from IBKR (Recommended)

Fetch trades directly from IBKR using the Flex Web Service API. This is the easiest way to keep your data up to date.

One-Time Setup

  1. 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
  2. Generate a Flex Web Service token:

    • Go to Settings > Reporting > Flex Web Service
    • Generate a new token (1-year validity recommended)
  3. Configure bettrack:

    cp .env_template .env

    Edit .env with your credentials:

    IBKR_FLEX_TOKEN=your_token_here
    IBKR_FLEX_QUERY_ID=your_query_id_here
    

Syncing

bettrack sync

This fetches all trades from IBKR and merges them with your local data.

Option 2: Manual CSV Import

  1. Log in to IBKR Client Portal
  2. Go to Reports > Activity
  3. Set the date range to cover your prediction market trades
  4. Export as CSV
  5. Import: bettrack import trades.csv

Refreshing Data

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 Storage

Data is stored locally in JSON format:

~/.bettrack/trades.json

Features

  • 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

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors

Languages