ib-create-consolidated-report

$npx mdskill add staskh/trading_skills/ib-create-consolidated-report

Consolidates IBRK trade CSV files into a summary report.

  • Groups trades by symbol, underlying, date, strike, buy/sell, and open/close.
  • Depends on trading-skills and optionally IB port for unrealized P&L.
  • Aggregates quantity, proceeds, net cash, commissions, and realized P&L.
  • Outputs both markdown and CSV reports to a specified directory.

SKILL.md

.github/skills/ib-create-consolidated-reportView on GitHub ↗
---
name: ib-create-consolidated-report
description: 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.
dependencies: ["trading-skills"]
---

# 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

```bash
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

```bash
# 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.

More from staskh/trading_skills

SkillDescription
earnings-calendarGet upcoming earnings dates with timing (before/after market) and EPS estimates. Use when user asks about earnings dates, earnings calendar, when a company reports, or upcoming earnings.
fundamentalsGet fundamental financial data including financials, earnings, and key metrics. Use when user asks about financials, earnings, revenue, profit, balance sheet, income statement, or company fundamentals.
greeksCalculate option Greeks (delta, gamma, theta, vega) and implied volatility for specific options. Use when user asks about Greeks, delta, gamma, theta, vega, IV, or option sensitivity analysis.
ib-accountGet account summary from Interactive Brokers including cash balance, buying power, and account value. Use when user asks about their account, balance, buying power, or available cash. Requires TWS or IB Gateway running locally.
ib-collarGenerate tactical collar strategy reports for protecting PMCC positions through earnings or high-risk events. Requires TWS or IB Gateway running locally.
ib-find-short-rollFind roll options for existing short positions OR find best covered call/put to open against long stock. Use when user asks about rolling shorts, finding roll candidates, writing covered calls, or managing option positions. Requires TWS or IB Gateway running locally.
ib-option-chainGet option chain data from Interactive Brokers for equities, ETFs, and futures (FOP), including calls and puts with strikes, bids, asks, volume, implied volatility, and model Greeks. Use when user asks about options using IBKR data, futures options (NQ/ES/CL/GC...), or needs real-time option quotes from their broker. Requires TWS or IB Gateway running locally.
ib-pmcc-advisorAnalyze PMCC (Poor Man's Covered Call / diagonal spread) positions from IB portfolio. For each diagonal spread, reports short leg risk (delta, IV, assignment probability), daily P&L projections, top-3 roll candidates, and a side-by-side comparison table. Requires TWS or IB Gateway running locally.
ib-portfolioGet portfolio positions from Interactive Brokers. Use when user asks about their portfolio, positions, holdings, or what stocks they own. Requires TWS or IB Gateway running locally.
ib-portfolio-action-reportGenerate a comprehensive portfolio action report with earnings dates and risk assessment. Use when user asks for portfolio review, action items, earnings risk, or position management across IB accounts. Requires TWS or IB Gateway running locally.