πŸ“ˆ Log daily Interactive Brokers trades to a Google Sheets journal

⚑ 167 views Β· πŸ“ˆ Crypto Trading & Stock Market

Description

tempImageKbwBTH.gif

Automated Trade Report from Interactive Brokers

This workflow is aimed at traders who use Interactive Brokers. It automatically retrieves the trades made in IBKR on a daily basis and writes them to a Google Sheet, so that anyone can easily perform further analyses and statistics using the on-board tools.

This creates an automatic, continuous trade journal.

Typical Usecaes

How it works

  1. A daily schedule triggers a FlexStatement request to Interactive Brokers to start generating a trade report.
  2. The workflow extracts the reference code from IBKR’s response, waits for the report to be ready, then downloads the Flex report XML.
  3. The XML is parsed and split into individual Trade records.
  4. Key fields (tradeDate, symbol, quantity, buySell, tradeID, price, money, currency, fxRateToBase) are normalized.\n5. Each trade is appended or updated in the configured Google Sheet, matching on tradeID to avoid duplicates and keep the journal current.

Prerequisites

Setup

1. Create Flex Query Token:

Go to IBKR Account Management Reports β†’ Flex Queries β†’ Flex Web Service β†’ Generate Current Token β†’ Make a note of the token (e.g.: 123456789012345678901234)

2. Enter Flex Token:

In node β€˜1. Request Flex Report’ and in node β€˜2. Extract Reference Code’ Replace YOUR_FLEX_TOKEN with your token ID

3. Create Flex Query in IBKR (if not already done):

Go to IBKR Account Management Reports β†’ Flex Queries β†’ Activity Flex Query β†’ Create Select: Trade Confirmation βœ“ Period: Last 365 Days Format: XML Save and note down the query ID

4. Enter Flex Query ID:

In node β€˜1. Request Flex Report’ Replace YOUR_QUERY_ID with your query ID

πŸ”— Nodes Used

Google Sheets, HTTP Request, Schedule Trigger

πŸ“₯ Import

Download workflow.json and import into n8n: Workflow menu β†’ Import from File

πŸ“– Importing guide Β· πŸ”‘ Credential setup