A tool for visualizing trade data from Interactive Brokers (IBKR). This project helps traders analyze their trading performance through intuitive and interactive visualizations in a streamlit web app. Currently only working for data exported via IBKR Activity Flex Query.
- Import trade data from IBKR via Activity Flex Query Web Service.
- Generate various visualizations to analyze trading performance.
- User-friendly interface made with streamlit for exploring trade metrics.
- Filter for time period, assets and symbols.
-
Clone the repository:
git clone https://github.com/your-username/ibkr-trade-visualization.git cd ibkr-trade-visualization -
Install dependencies using
pyproject.toml:uv sync --all-extras
- Generate IBKR Flex Query report.
- Configure .env with token and query id from IBKR.
- Explore the visualizations made with plotly in a streamlit web app to gain insights into your trading performance.
streamlit run main.py
To generate the required IBKR Flex Query report:
- Log in to your IBKR account.
- Navigate to Reports > Flex Queries.
- Create a new Flex Query with the following fields in Trades:
- Execution At the top of the report
- Account ID
- Description
- Asset Class
- Underlying Symbol
- Put/Call
- Buy/Sell
- Strike
- Date/Time
- Trade Date
- Settle Date
- Expiry
- Open/Close
- Notes
- Cost Basis
- Realized PnL
- MTM P/L
- IB Commission
- FX Rate
- Level of Detail
- At Delivery Configuration select Format: XML and Period: Year to Date.
- Set decimal for dates to None (no separator)
- Save the query and note the
Query ID. - Activate Web Services, see here: IBKR Web Services.
- Configure the
TOKEN,QUERY_ID, and other required environment variables in a.envfile. - Run main.py
Contributions are welcome!
This project is licensed under the MIT License. See the LICENSE file for details.
For questions or feedback, please open an issue in the repository.