A comprehensive trading analytics tool for analyzing IBKR (Interactive Brokers) trade data. Get deep insights into your trading performance with advanced metrics, visualizations, behavioral analysis, and real-time portfolio tracking.
After you install Python, run runner.bat and you are ready to go. Upload your IBKR CSV containing (Symbol | TradeDate | Quantity | TradePrice | IBCommission | FifoPnlRealized | Buy/Sell) and start analyzing!
- Features
- Installation
- Understanding Your Data
- Using the App
- Metrics Explained
- What Good Numbers Look Like
- Pro Tips
- Troubleshooting
- Win Rate, Profit Factor, Expectancy
- Risk/Reward Ratio
- Total P/L (already net of commissions)
- Max Drawdown ($ and %)
- Drawdown Duration
- Time-based Equity Curve
- Win/Loss Streaks
- Fear Index: Measures early exit tendency (30% threshold)
- Trade Grading: A+ to F based on profit vs commission
- Overtrading alerts
- Commission impact analysis
- Performance per symbol
- Open Position Tracking (blue highlighting)
- Win rate, best/worst trades per symbol
- Real-time portfolio view with live prices from Yahoo Finance
- Accurate cost basis using FIFO accounting (matches IBKR)
- Sector allocation with interactive pie chart
- Unrealized P/L tracking for open positions
- Concentration risk warnings
- Top 5 positions by value
- Individual holdings breakdown with:
- Average cost per share (includes commissions)
- Cost basis (total invested)
- Current market value
- Unrealized profit/loss ($ and %)
- Portfolio allocation %
- Sector/Industry classification
- Day of week performance
- Monthly tracking
- Top 5 winners/losers
- Date and symbol filters
- 7 organized tabs
- Export to CSV
- Professional charts with proper margins
- Parallel API fetching (fast loading)
- Python 3.8 or higher
-
Download files:
analyzer.pyapp.pyrequirements.txt
-
Install dependencies:
pip install -r requirements.txt
-
Run:
streamlit run app.py
-
Open browser:
- Auto-opens at
http://localhost:8501
- Auto-opens at
The most important thing to understand:
FifoPnlRealized = Your ACTUAL profit/loss (already includes ALL commissions)
You do NOT need to add or subtract anything!
Buy 100 shares @ $10 = $1,000 + $1 commission
Sell 100 shares @ $12 = $1,200 - $1 commission
FifoPnlRealized shown on SELL row: $198
(Not $200! Already minus both $1 commissions)
FifoPnlRealized
- Your FINAL profit or loss
- Already has buy AND sell commissions deducted
- Sum this for total profit/loss
- This is what goes in your pocket
IBCommission
- Fee for THIS transaction only
- Negative number (it's a cost)
- For information/tracking only
- Do NOT subtract from FifoPnlRealized
Quantity
- Positive = BUY
- Negative = SELL
- Sum by symbol to find open positions
Basic Stats:
- Total Trades, Wins, Losses, Win Rate
P/L Metrics:
- Total P/L: Your actual profit (already net)
- Total Fees: Commissions paid (informational)
- Fee Impact %: What % went to fees
Advanced Metrics:
-
Profit Factor (Total Wins Γ· Total Losses)
- <1.0 = Losing
- 1.5-2.0 = Good
- />2.0 = Excellent
-
Expectancy (Average $ per trade)
- Positive = Profitable strategy
- Higher = Better
-
R/R Ratio (Avg Win Γ· Avg Loss)
- <1.5 = Below average
- 1.5-2.5 = Good
- />2.5 = Excellent
Risk Metrics:
- Max Drawdown, Streaks
- Clean equity curve (time-based)
- Drawdown chart
- Win/loss distribution
- Trade grade bar chart
- Fear Index gauge
- Table of all symbols
- Blue = Open position (Quantity sum > 0)
- NetPnL, win rate per symbol
- Top 10 chart
- Performance by day of week
- Monthly breakdown
- Identify patterns
- Top 5 winners
- Top 5 losers
- Learn from extremes
Real-Time Portfolio Tracking:
Portfolio Summary:
- Total Cost Basis - Amount invested in open positions
- Total Market Value - Current value with live prices
- Total Unrealized P/L - Profit/loss on open positions ($ and %)
- Number of Holdings and Sectors
Sector Allocation:
- Interactive pie chart showing portfolio by sector
- Breakdown table with value and % per sector
- ETF handling (gets category/sector info)
Individual Holdings Table: Shows for each open position:
- Symbol
- Quantity held
- Average Cost - FIFO cost basis (includes commissions!)
- Current Price (live from Yahoo Finance)
- Cost Basis - Total invested (Quantity Γ Avg Cost)
- Market Value - Current worth
- Unrealized P/L ($) - Profit/loss if you sold now
- Unrealized P/L (%) - Return on investment
- % of Portfolio
- Sector/Industry
- Last Trade Date
Concentration Analysis:
- Top 5 holdings by value (bar chart)
- Portfolio concentration warnings:
- π¨ Top 5 > 70%: High risk
- π‘ Top 5 50-70%: Moderate
- β Top 5 < 50%: Well diversified
- Sector concentration alerts:
- π¨ One sector > 50%: Heavy concentration
- π‘ One sector 30-50%: Moderate exposure
- β All sectors < 30%: Good diversification
Key Features:
- β Matches IBKR cost basis (includes commissions)
- β Fast parallel fetching (1-2 seconds for 10 stocks)
- β Color-coded P/L (green for gains, red for losses)
- β Identifies break-even prices
- β Tax planning ready (shows unrealized gains)
- All closed trades
- Export to CSV
- P/L, commission, grade
Measures: Do you exit winners too early?
How it works:
- Calculate average winning trade
- Set threshold at 30% of average win
- Count wins below threshold
- Fear Index = (small wins / total wins) Γ 100
Example:
- Avg win = $100
- Threshold = $30
- 6 of 10 wins under $30
- Fear Index = 60%
Interpretation:
- <20%: β Excellent - let winners run
- 20-40%: π‘ Moderate
- 40-60%:
β οΈ High - cutting too early - />60%: π¨ Severe psychological issue
Measures: Trade quality vs commission cost
Grading:
- A+: Profit > 5Γ commission (Excellent)
- A: Profit > 3Γ commission (Very good)
- B: Profit > 1Γ commission (Good)
- C: Small profit (Barely profitable)
- D: Small loss (Minor)
- F: Large loss (Bad)
Example ($1 commission):
- Profit $6 = A+ (6Γ fee)
- Profit $4 = A (4Γ fee)
- Profit $2 = B (2Γ fee)
- Profit $0.50 = C (barely covered)
- Loss -$0.50 = D (small)
- Loss -$3 = F (3Γ fee lost)
Good distribution:
- A+/A: 20-30%
- B: 30-40%
- C: 20-30%
- D/F: <20%
Formula: Total Wins Γ· Total Losses
Example:
- Wins: $5,000
- Losses: $2,000
- Profit Factor = 2.5
Interpretation:
- <1.0: π¨ Losing
- 1.0-1.5:
β οΈ Barely profitable - 1.5-2.0: π‘ Decent
- 2.0-3.0: β Good
- />3.0: β Excellent
Formula: (Win Rate Γ Avg Win) + ((1 - Win Rate) Γ Avg Loss)
Example:
- Win Rate: 60%
- Avg Win: $100
- Avg Loss: -$50
- Expectancy = $40/trade
Meaning: Average profit per trade
Interpretation:
- Positive: β Strategy works
- Negative: π¨ Fix strategy
- Higher: Better
Formula: Avg Win Γ· Avg Loss
Example:
- Avg Win: $150
- Avg Loss: -$100
- R/R = 1.5:1
Interpretation:
- <1.0: π¨ Losses bigger than wins
- 1.0-1.5:
β οΈ Below average - 1.5-2.5: β Good
- />2.5: β Excellent
Key: You can be profitable with 40% win rate if R/R > 2:1
What it is: Weighted average price you paid for shares you currently hold.
How it's calculated: Uses FIFO (First-In-First-Out) accounting:
- Each BUY creates a "lot" at that price
- Each SELL removes shares from oldest lots first
- Commissions are included in the cost per share
- Average = Total cost of remaining lots / Total remaining shares
Example:
Buy 100 @ $150 + $0.35 commission β Cost: $150.0035/share
Buy 50 @ $160 + $0.35 commission β Cost: $160.0070/share
Sell 50 (removes from first buy)
Remaining: 50@$150.0035 + 50@$160.0070
Avg Cost = (50Γ$150.0035 + 50Γ$160.0070) / 100 = $155.01
Why it matters:
- β Matches IBKR calculations exactly
- β Includes commissions (tax-accurate)
- β Shows true break-even price
- β Basis for unrealized P/L
What it is: Profit or loss on positions you still hold (not yet sold).
Formula:
Unrealized P/L = Market Value - Cost Basis
Market Value = Quantity Γ Current Price
Cost Basis = Quantity Γ Average Cost
Unrealized P/L % = (Unrealized P/L / Cost Basis) Γ 100
Example:
Holding: 100 shares
Avg Cost: $150 (your entry)
Current Price: $160
Market Value: 100 Γ $160 = $16,000
Cost Basis: 100 Γ $150 = $15,000
Unrealized P/L: $16,000 - $15,000 = +$1,000
Unrealized P/L %: ($1,000 / $15,000) Γ 100 = +6.67%
Why it matters:
- Shows current position performance
- Helps decide when to take profits
- Indicates tax liability if you sell
- Combined with realized P/L = total trading return
Measures: Worst losing streak impact
Example:
- Peak: $10,000
- Bottom: $8,000
- Drawdown = -$2,000 (-20%)
Risk levels:
- <10%: Low risk
- 10-20%: Moderate
- 20-30%:
β οΈ High risk - />30%: π¨ Very high risk
Formula: (Total Fees Γ· Total P/L) Γ 100
Example:
- Profit: $1,000
- Fees: $300
- Impact = 30%
Interpretation:
- <15%: β Good
- 15-30%: π‘ Acceptable
- 30-50%:
β οΈ High - reduce frequency - />50%: π¨ Overtrading
| Metric | Beginner | Intermediate | Advanced |
|---|---|---|---|
| Win Rate | 45-55% | 50-60% | 55-70% |
| Profit Factor | 1.2-1.5 | 1.5-2.0 | 2.0+ |
| R/R Ratio | 1.0-1.5 | 1.5-2.0 | 2.0+ |
| Expectancy | $5-20 | $20-50 | $50+ |
| Fear Index | 40-60% | 20-40% | <20% |
| Fee Impact | 30-50% | 15-30% | <15% |
| Max DD % | 20-40% | 10-20% | <10% |
Win Rate: 70%
R/R: 0.8:1
Profit Factor: 1.3
Issue: Losses bigger than wins. Fragile.
Fix: Cut losses faster.
Win Rate: 40%
R/R: 3:1
Profit Factor: 2.4
Style: Trend following. Many small losses, huge wins.
Works if: You have discipline.
Win Rate: 55%
R/R: 1.8:1
Profit Factor: 2.2
Expectancy: $45
Result: Sustainable, professional.
-
Focus on Expectancy: If positive, strategy works
-
Balance Win Rate & R/R:
- High win rate + low R/R = Cut losers faster
- Low win rate + high R/R = Need discipline
-
Fear Index >40%: You're leaving money on table
-
Most trades B grade or better: Good efficiency
-
Commission Impact >30%: Trade less or bigger size
-
Use Date Filters: Track improvement over time
-
Analyze by Symbol: Stop trading consistent losers
-
Review Extremes: Learn from best/worst trades
-
Check Holdings Dashboard: Monitor unrealized P/L and sector allocation
-
Watch Concentration: Keep top 5 holdings < 60% of portfolio
How it works:
- Sums Quantity for each symbol
- If sum > 0: Open position
- If sum = 0: Closed
Visual:
- Blue highlighting in symbol table
HasOpenPositioncolumnOpenPositionshows quantity
Holdings Dashboard:
- Full breakdown with cost basis
- Unrealized P/L tracking
- Sector allocation
- Live market prices
Why it matters:
- Track active positions
- Distinguish realized vs unrealized
- Risk management
- Portfolio rebalancing
- Check FifoPnlRealized β 0
- Verify date filters
- Remember: FifoPnlRealized is already NET
- Verify: Total P/L = sum(FifoPnlRealized)
- Refresh page
- Check date filters
- Check Quantity sum
- Might have fractional shares
- Normal: Fetches live prices from Yahoo Finance
- Typical: 1-2 seconds for 10 stocks
- Uses parallel fetching for speed
- Should match within $0.01
- Includes commissions (like IBKR)
- Uses FIFO accounting
- Check if all trades are in CSV
- Code attempts to get ETF category
- Some ETFs may not have sector data
- Manually verify ticker symbol is correct
After upload, verify:
β
Total P/L = sum of FifoPnlRealized
β
Total Fees = sum of IBCommission
β
Trades = rows with FifoPnlRealized β 0
β
Win Rate in 30-70% range
β
Open positions highlighted blue
β
Equity curve trends correctly
β
Holdings Dashboard cost basis matches IBKR
β
Unrealized P/L seems accurate
- FifoPnlRealized = Net P/L (includes ALL commissions for closed trades)
- Don't add commissions (already deducted from P/L)
- Cost Basis DOES include commissions (this is correct for tax purposes)
- Open positions (blue highlighting, sum of Quantity > 0)
- Time-based charts (calendar time, not trade #)
- All metrics (based on closed trades only)
- Holdings Dashboard (tracks open positions with live prices)
- Install Python 3.8+
-
pip install -r requirements.txt -
streamlit run app.py - Upload IBKR CSV
- Check Overview tab
- Review Performance charts
- Identify open positions (blue in Symbol Analysis)
- Check Holdings Dashboard for current portfolio
- Review sector allocation and concentration
- Analyze time patterns
- Review best/worst trades
- Export data if needed
analyzer.py- Analysis engine with FIFO cost basisapp.py- Streamlit UI with 7 tabsrequirements.txt- Dependencies (includes yfinance)runner.bat- Use it to run the appREADME.md- This file
Ready to analyze! π
Upload your CSV and discover:
- Trading performance patterns
- Behavioral issues (Fear Index)
- Which symbols to trade/avoid
- Current portfolio allocation
- Unrealized gains/losses
- Sector diversification
- Areas for improvement
For detailed metric explanations, scroll up to the "Metrics Explained" section. Everything you need to understand your complete trading picture is here!