ib_trades_history
Retrieve Interactive Brokers trade executions with fills, commissions, realized P&L, and symbol-aggregated summaries. Use FlexReport tokens for full history beyond the ~7-day live API window.
Instructions
Fetch trade executions from Interactive Brokers.
Returns individual trade executions with fills, commissions, and realized P&L, plus aggregated summary by symbol. Uses live API (~7 days history) by default, or FlexReport for full history when token and query ID are provided. Requires TWS or IB Gateway running locally.
Args: port: IB port (7496 for live, 7497 for paper) account: Specific account ID (optional, fetches all if not specified) symbol: Filter trades by symbol (e.g., AAPL) start_date: Start date in YYYY-MM-DD format (default: Jan 1 of current year) end_date: End date in YYYY-MM-DD format (default: today) flex_token: FlexReport token for extended history beyond ~7 days flex_query_id: FlexReport query ID (required with flex_token). Pass a list of IDs to merge and deduplicate results from multiple queries — useful for spans exceeding the FlexReport 365-day per-query limit.
Input Schema
| Name | Required | Description | Default |
|---|---|---|---|
| port | No | ||
| symbol | No | ||
| account | No | ||
| end_date | No | ||
| flex_token | No | ||
| start_date | No | ||
| flex_query_id | No |