mcpField
I
ib-create-consolidated-report

ib-create-consolidated-report

github.com/staskhData & databases39476 installsUpdated 1d ago
Repository

About ib-create-consolidated-report

ib-create-consolidated-report is a skill for consolidating Interactive Brokers trade CSV files by trade and contract fields. It aggregates quantities and cash or P&L values, then produces Markdown and CSV reports.

Key features

  1. 01Read CSV files from a directory
  2. 02Group trades by contract and transaction fields
  3. 03Aggregate quantities, proceeds, cash, commissions, and P&L
  4. 04Label position types
  5. 05Export Markdown and CSV reports

Use cases

  1. 01Combine trade records from multiple CSV files
  2. 02Summarize trades by ticker, option, and date
  3. 03Review aggregated proceeds and realized P&L

Install

Copy the command and run it in a terminal.

$npx skills add https://github.com/staskh/trading_skills --skill ib-create-consolidated-report

After installing, type/ib-create-consolidated-reportin Claude Code to confirm it loaded.

Bundled filesscripts/consolidate.py

Details

From the project README

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

  • directory - Path to directory containing IBRK trade CSV files
  • --port - IB port to fetch unrealized P&L (7497=paper, 7496=live). If not specified, auto-probes both ports (tries 7496 first, then 7497). Defaults to the IB_PORT env var when set (--port still overrides).
  • --output-dir - Output directory for reports (default: sandbox/)

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:

  • consolidated_trades_YYYY-MM-DD_HHMM.md - Markdown report with summary tables
  • consolidated_trades_YYYY-MM-DD_HHMM.csv - CSV with all consolidated data

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"

Timezone

All timestamps and time-based calculations must use the America/New_York timezone. All JSON output must include generated_at (NY time string) and data_delay fields.

Comments

Markdown supported