A comprehensive web-based dashboard for analyzing trading data, with special focus on options trading and complex multi-leg strategies.
- Account Summary: Total value, cash, and margin information
- Performance Metrics: P&L tracking, win/loss ratios, and performance charts
- Position Analysis: Current holdings with detailed metrics
- Stock Transactions: Individual stock trade tracking and analysis
- Option Transactions: Detailed options trading history
- Complex Option Trades: Multi-leg strategy aggregation and analysis
- Automatic detection of spreads, straddles, condors, and other complex strategies
- Credit/Debit analysis with proper profit/loss calculations
- Trade duration and timeline tracking
- Individual leg breakdown with visual cards
- Holding Period Analysis: Categorization and statistics by trade duration
- Realized P&L: Profit/loss calculations after fees
- Trade Structure Analysis: Buy vs Sell legs, Calls vs Puts breakdown
- Visual Metrics: Color-coded cards for quick profit/loss identification
- Responsive Design: Works on desktop, tablet, and mobile devices
- Bootstrap 5: Modern, clean interface with professional styling
- Interactive Modals: Detailed trade analysis in popup windows
- Tabbed Navigation: Organized sections for different data types
- Python 3.7 or higher
- pip (Python package installer)
git clone <repository-url>
cd trading_dashboardpython -m venv .venv
source .venv/bin/activate # On Windows: .venv\Scripts\activatepip install -r requirements.txtmkdir -p dataPlace your trading data file(s) (.tlg format) in the data/ folder. The application will automatically detect and list all .tlg files in the data directory.
- Interactive Brokers: Export third-party reports from your IBKR account
- Third-party Tools: Use IBKR-compatible reporting tools
- File Format: Ensure files are in
.tlgformat with pipe-delimited structure - Multiple Files: You can have multiple
.tlgfiles for different time periods or accounts
python app.pyThe dashboard will be available at http://localhost:5000
trading_dashboard/
βββ app.py # Main Flask application
βββ templates/
β βββ index.html # Dashboard template
βββ static/ # CSS, JS, and image files
βββ data/ # Trading data files
β βββ *.tlg # Your trading data files
βββ .venv/ # Virtual environment
βββ README.md # This file
The application processes trading data in .tlg format, which is a third-party report format used with Interactive Brokers (IBKR) trading platform.
- Source: Interactive Brokers third-party reports
- Format: Pipe-delimited text files with structured sections
- Content: Account information, transactions, and positions
- Generation: Can be exported from IBKR platform or third-party tools
Each .tlg file contains the following sections:
- ACCOUNT_INFORMATION: Account details and personal information
- STOCK_TRANSACTIONS: Individual stock trades and transactions
- OPTION_TRANSACTIONS: Options trades with detailed contract information
- STOCK_POSITIONS: Current stock holdings and positions
- OPTION_POSITIONS: Current options positions and contract details
- Date, Symbol, Description, Action, Quantity, Price, Amount, Fee
- Date, Symbol, Description, Action, Type, Strike, Expiration, Quantity, Price, Amount, Fee
- Description Format:
SYMBOL DDMMMYY STRIKE TYPE(e.g., "GOOG 04APR25 175 P") - Type: P (Put) or C (Call)
- Expiration: Extracted from description (e.g., "04APR25" β "2025-04-04")
The system automatically groups option transactions into complex trades based on:
- Same underlying symbol
- Same expiration date
- Related execution dates
- Multi-leg structure analysis
- Portfolio Overview: View account summary and performance metrics
- Recent Transactions:
- Stocks Tab: Individual stock trades
- Options Tab: Individual option trades
- Complex Trades Tab: Multi-leg option strategies
- Holding Period Analysis: Trade duration statistics
- Navigate to the "Complex Option Trades" tab
- Click "View Legs" on any trade to see detailed analysis
- The modal will show:
- Summary Cards: Net Credit/Debit, Total Fees, Realized P&L, Trade Duration
- Trade Structure: Buy/Sell legs, Calls/Puts breakdown
- Trade Timeline: Start/End dates and duration
- Individual Legs: Detailed cards for each option leg
- SELL options = Credit (negative amount = profit)
- BUY options = Debit (positive amount = loss)
- Net Credit = Green card (profitable position)
- Net Debit = Red card (costly position)
- Data Parsing: Custom parser for
.tlgtrading data files - Complex Trade Aggregation: Algorithm to group related option transactions
- Performance Calculations: P&L, fees, and duration analysis
- Responsive Grid: Mobile-first design approach
- Interactive Components: Modals, tabs, and collapsible sections
- Visual Indicators: Color-coded cards and badges for quick analysis
parse_trading_data(): Processes raw trading dataaggregate_complex_option_trades(): Groups multi-leg strategiescalculate_holding_period_stats(): Analyzes trade duration patterns
- Modify
templates/index.htmlfor layout changes - Update Bootstrap classes for visual customization
- Add custom CSS in the
<style>section
- Edit
app.pyto modify data parsing logic - Adjust complex trade detection algorithms
- Add new analytics functions
- New data visualizations can be added to the template
- Additional analysis functions can be implemented in
app.py - Custom JavaScript can be added for enhanced interactivity
The dashboard automatically detects and analyzes:
- Credit Spreads: Sell high, buy low strikes
- Debit Spreads: Buy high, sell low strikes
- Iron Condors: Sell both call and put spreads
- Straddles: Buy both call and put at same strike
- Strangles: Buy both call and put at different strikes
- Butterflies: Three-leg option strategies
- Calendar Spreads: Different expiration dates
- Diagonal Spreads: Different strikes and expirations
- Data File Not Found: Ensure your
.tlgfile is in thedata/folder - Import Errors: Activate the virtual environment before running
- Port Already in Use: Change the port in
app.pyor kill existing processes - Invalid .tlg Format: Ensure file follows Interactive Brokers third-party report structure
- Missing Sections: .tlg files should contain ACCOUNT_INFORMATION, STOCK_TRANSACTIONS, OPTION_TRANSACTIONS sections
- File Not Loading: Check that the file is properly formatted with pipe-delimited fields
- Missing Data: Ensure all required sections are present in the file
- Date Format: Dates should be in YYYYMMDD format
- Option Descriptions: Should follow format
SYMBOL DDMMMYY STRIKE TYPE
Run with debug output:
python debug_complex_trades.pyThe debug script will automatically use the first .tlg file found in the data/ directory.
- Fork the repository
- Create a feature branch
- Make your changes
- Test thoroughly
- Submit a pull request
This project is for personal use and educational purposes.
This trading dashboard application is provided "AS IS" for personal use and educational purposes only. By using this software, you acknowledge and agree to the following terms:
- This application is NOT financial advice
- The author is NOT a licensed financial advisor
- All trading decisions are YOUR RESPONSIBILITY
- Past performance does not guarantee future results
- The software is provided without any warranties, express or implied
- The author makes NO GUARANTEES about accuracy, completeness, or reliability
- Data analysis and calculations may contain errors
- The application may not work as expected in all situations
- The author is NOT RESPONSIBLE for any financial losses incurred
- Trading involves substantial risk of loss
- You assume all risks associated with trading decisions
- The author disclaims all liability for trading outcomes
- This software is intended for personal use only
- Commercial use is not authorized
- Redistribution requires explicit permission
- Modification for personal use is permitted
- The application processes data as provided
- No verification of data accuracy is performed
- Users are responsible for validating their data
- The author is not liable for data processing errors
Trading options and other securities involves substantial risk and is not suitable for all investors. You can lose some or all of your invested capital. Always consult with a qualified financial advisor before making investment decisions.
Happy Trading! ππ°
- Real-time data integration
- Advanced charting capabilities
- Risk analysis tools
- Portfolio optimization suggestions
- Export functionality for reports
- Multiple account support
- API integration for live market data