Skip to main content

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

Broker-Level Accuracy

Uses broker’s proprietary matching logic

Wash Sale Detection

Accurate wash sale flags from broker

FIFO Fallback

Estimates P/L when broker data unavailable

Complete Coverage

Handles all transaction types

How It Works

1

Load Broker Lots

System loads pre-calculated lot matches from broker’s realized gains/losses CSV
2

Process Sells

For each sell transaction, checks if corresponding broker lot exists
3

Use Broker Data

If lot found, uses broker’s P/L, wash sale flag, and cost basis
4

FIFO Estimate

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 badgeAll trades matched to broker lots with definitive P/L

Next Steps