Trading_skills ib-create-consolidated-report
Consolidate IBRK trade CSV files from a directory into a summary report. Groups trades by symbol, underlying, date, strike, buy/sell, and open/close. Outputs both markdown and CSV.
install
source · Clone the upstream repo
git clone https://github.com/staskh/trading_skills
Claude Code · Install into ~/.claude/skills/
T=$(mktemp -d) && git clone --depth=1 https://github.com/staskh/trading_skills "$T" && mkdir -p ~/.claude/skills && cp -r "$T/.claude/skills/ib-create-consolidated-report" ~/.claude/skills/staskh-trading-skills-ib-create-consolidated-report && rm -rf "$T"
manifest:
.claude/skills/ib-create-consolidated-report/SKILL.mdsource content
IB Create Consolidated Report
Reads all CSV files from a given directory (excluding subdirectories), consolidates trade data by key fields, and generates both markdown and CSV reports.
Instructions
uv run python scripts/consolidate.py <directory> [--port PORT] [--output-dir OUTPUT_DIR]
Arguments
- Path to directory containing IBRK trade CSV filesdirectory
- IB port to fetch unrealized P&L (7497=paper, 7496=live). If not specified, auto-probes both ports (tries 7496 first, then 7497).--port
- Output directory for reports (default: sandbox/)--output-dir
Consolidation Logic
Groups trades by:
- UnderlyingSymbol - The underlying ticker (e.g., GOOG, CAT)
- Symbol - Full option symbol
- TradeDate - Date of the trade
- Strike - Strike price
- Put/Call - Option type (C or P)
- Buy/Sell - Trade direction
- Open/CloseIndicator - Whether opening or closing
Aggregates:
- Quantity - Sum of quantities
- Proceeds - Sum of proceeds
- NetCash - Sum of net cash
- IBCommission - Sum of commissions
- FifoPnlRealized - Sum of realized P&L
Adds column:
- Position - SHORT (Sell+Open), LONG (Buy+Open), CLOSE_SHORT (Buy+Close), CLOSE_LONG (Sell+Close)
Output
Generates two files in the output directory:
- Markdown report with summary tablesconsolidated_trades_YYYY-MM-DD_HHMM.md
- CSV with all consolidated dataconsolidated_trades_YYYY-MM-DD_HHMM.csv
Example Usage
# Consolidate trades from IBRK reports directory uv run python scripts/consolidate.py "C:\Users\avrah\OneDrive\Business\Trading\IBRK reports\2stastrading2025" # Specify custom output directory uv run python scripts/consolidate.py "C:\path\to\reports" --output-dir "C:\output"