---
title: 'Hybrid Matching Algorithm'
description: 'Broker-level accuracy for profit/loss and wash sale tracking'
---
## Overview
The hybrid matching algorithm combines two data sources to provide the most accurate profit/loss and wash sale tracking:
1. **Broker's Realized Gains/Losses CSV** - Pre-calculated lot matches with definitive P&L
2. **Transaction History CSV** - Complete record of all buy/sell transactions
## Key Benefits
Uses broker's proprietary matching logic
Accurate wash sale flags from broker
Estimates P/L when broker data unavailable
Handles all transaction types
## How It Works
System loads pre-calculated lot matches from broker's realized gains/losses CSV
For each sell transaction, checks if corresponding broker lot exists
If lot found, uses broker's P/L, wash sale flag, and cost basis
If no broker lot, applies FIFO (First In, First Out) matching logic
## Data Sources
### Broker Realized Gains/Losses
Contains:
- Opened date (purchase date)
- Closed date (sale date)
- Quantity sold from specific lot
- Cost basis and proceeds
- Gain/loss amount (pre-calculated)
- Wash sale flag
- Disallowed loss amount
- Term (Short/Long)
### Transaction History
Contains:
- All buy/sell transactions
- Transaction dates
- Symbol, quantity, price
- Commissions and fees
## Matching Criteria
The system matches broker lots to transactions using:
- **Symbol**: Must match exactly
- **Date**: Must match the transaction date
- **Quantity**: With tolerance for fractional shares
## Data Source Indicators
✓ **Broker-verified badge**
All trades matched to broker lots with definitive P/L
⚠️ **FIFO estimate badge**
Trades matched using FIFO logic (no broker lot available)
✓ **Broker-verified** + ⚠️ **FIFO estimate**
Month contains both broker-verified and FIFO-estimated trades
## Next Steps
Learn how to upload both CSV files
View your matched trades