Tradebook Import

TraderTape's analysis pages โ€” P&L, edge finder, patterns, trends, benchmarks, campaigns โ€” all run on your historical trade data. To populate them, you upload your broker's tradebook files (Excel format) via Settings โ†’ Data Import. The system parses them, deduplicates, applies corporate actions, and rebuilds the P&L.

This guide covers what to upload, where to find the files, what the parser handles, and the most common gotchas.

What to upload

You can upload three kinds of files:

  1. Tradebook (XLSX) โ€” every executed trade for an account. Multiple files at once (one per quarter is the most common Kite export).
  2. Ledger (XLSX) โ€” cash movements, margin debits/credits, broker charges. One file per account.
  3. CAS (PDF) โ€” Consolidated Account Statement from NSDL or CDSL. Used for mutual fund holdings โ€” see Mutual Funds.

The tradebook is the most important. Without it, the analysis pages are empty. The ledger adds cash balance accuracy. The CAS adds MF tracking.

Where to get the files

Zerodha Kite

  1. Log in to console.zerodha.com
  2. Go to Reports โ†’ Trades
  3. Click the date range picker. Kite limits each export to a max of 1 quarter (~90 days).
  4. Pick Equity as the segment, Excel (XLSX) as the format, click Download
  5. Repeat for each quarter you want to import โ€” 12 files for 3 years
  6. (Optional) Repeat with F&O as the segment for futures and options trades

For the ledger:

  1. Reports โ†’ Ledger
  2. Pick the full date range (Kite usually allows the entire account history)
  3. Excel (XLSX) โ†’ Download

You'll end up with files like:

tradebook-XU6206-EQ-2023-01-01-to-2023-03-31.xlsx
tradebook-XU6206-EQ-2023-04-01-to-2023-06-30.xlsx
...
tradebook-XU6206-FO-2023-01-01-to-2023-03-31.xlsx
...
ledger-XU6206-2018-01-01-to-2026-04-08.xlsx

Upstox

The Upstox web console has a similar reports section. Export tradebook as XLSX. The format is slightly different from Kite's but TraderTape's parser auto-detects which broker the file is from based on column headers.

Groww

Groww's web console only allows exporting per-day P&L statements, not full trade history. The Groww trade history is available through their API, which the local agent fetches automatically. There's no manual XLSX upload path for Groww.

Uploading

In TraderTape, go to Settings โ†’ Data Import. There are three upload areas:

  • Tradebook โ€” accepts multiple XLSX files at once. Drag and drop a folder of quarterly exports.
  • Ledger โ€” accepts one XLSX
  • CAS โ€” accepts one PDF (NSDL or CDSL format auto-detected)

Click upload (or drop files). Each file shows its parse result inline:

โœ“ tradebook-XU6206-EQ-2023-01.xlsx
  413 trades imported, 12 duplicates skipped
  Date range: 2023-01-02 to 2023-03-31
  Symbols: 87

Errors are reported per file with the line number and the issue. The system never partially imports a file โ€” either the whole thing parses successfully or nothing is added.

What the parser handles

Standard Kite tradebook format

The default Kite XLSX format has columns: Trade ID, Order ID, Symbol, Series, Trade Date, Exchange, Trade Type, Quantity, Price, Trade Time, etc. The parser maps these to the Trade model in the database.

Each trade row creates one Trade record with:

  • tradingsymbol, exchange, segment
  • transaction_type (BUY / SELL)
  • quantity, price, total_value
  • trade_date, trade_time
  • kite_trade_id, kite_order_id (for dedup)
  • user_id, broker = "kite"

Standard Upstox tradebook format

Different column headers, same content. The parser detects "Upstox" in the file metadata or column names and switches to the Upstox parser. Trades are stamped with broker = "upstox".

Non-standard formats

Some legacy Kite exports (e.g. the Q1 2019 export) have different layouts โ€” no header row, columns in a different order, missing fields. The parser has special handlers for known non-standard formats. Unknown formats fail with a clear error.

If you have an unusual format you need imported, the cleanest path is to convert your file to the standard Kite format first, then upload normally. Email support if you have a format that's worth adding native support for.

Deduplication

Every trade has a unique kite_trade_id (or upstox_trade_id). The parser checks for existing trades with the same ID and skips them. So you can re-upload the same file safely โ€” duplicates are silently skipped, only new rows are added.

This means you can do incremental imports: upload your full history once, then upload just the latest quarter periodically without worrying about duplication.

Partial fills

A single order can have multiple fills. Kite reports each fill as a separate row with the same Order ID but different Trade ID. The parser preserves all fills and groups them by order ID when computing P&L (using VWAP for the merged price).

What happens after import

Once trades are in the database, several things happen in order:

  1. Corporate action processing โ€” splits, mergers, demergers, physical delivery, option expiry. The system has a curated list of ~40 known corporate actions on Indian large caps. Each action generates virtual trades that adjust quantities and cost basis.

  2. FIFO pairing โ€” for each symbol, trades are paired buy โ†’ sell using First In First Out. Each pair becomes a "round trip" with realized P&L.

  3. Realized vs unrealized split โ€” closed round trips contribute to realized P&L. Unmatched buys (still held) contribute to unrealized.

  4. Open position computation โ€” symbols with unmatched buys after corporate action processing become open positions. The "open positions" section of the dashboard shows these.

  5. Pattern analysis โ€” every closed round trip is enriched with indicator snapshots (RSI, vol regime, trend alignment) at entry and exit. This populates the Edge Finder, Patterns, and Trend pages.

This pipeline runs lazily โ€” the first time you visit an analysis page after upload, it computes the pairing for that symbol set. Subsequent loads use a cache. If you upload more data, the cache is invalidated automatically.

Corporate actions

The system handles five types of corporate actions:

Stock splits

Hardcoded in STOCK_SPLITS constant. For each split, all trades before the split date have their quantity and price adjusted by the ratio.

Example: PFC 5:4 split on 2024-01-15. All pre-split trades have qty *= 5/4 and price *= 4/5.

If a stock has been through a split that we haven't recorded yet, your open position count will be wrong. Email support with the symbol and split ratio and we'll add it.

Mergers

MERGERS constant. Old symbol โ†’ new symbol mapping with effective date. All pre-merger trades are renamed to use the new symbol.

Example: HDFC merged into HDFCBANK on 2023-07-13. All pre-merger HDFC trades become HDFCBANK trades.

Demergers

DEMERGERS constant. Parent symbol โ†’ child symbol with cost allocation percentage. Generates virtual sell+rebuy trades on the demerger date that:

  1. Sell the parent at the day's close (zero P&L round trip to close the old position)
  2. Rebuy the parent at a reduced average price (reduced by the cost allocation percentage, per Section 49(2C/2D) of the Income Tax Act)
  3. Buy the child at the allocated cost basis

Example: RELIANCE โ†’ JIOFIN demerger on 2023-07-20. 9.8% of RELIANCE cost basis is allocated to JIOFIN. The user receives 1 JIOFIN share for every 1 RELIANCE share held on the record date.

Physical delivery

For F&O contracts that expire in the money on physical-settlement underlyings (most stock options/futures), the contract converts to an equity position at the strike price. The system generates virtual EQ trades for the delivery.

Option expiry

OTM options expire worthless (closed at โ‚น0.05). ITM options:

  • Index options (NIFTY, BANKNIFTY): cash settled at intrinsic value (max(0, settlement - strike) for CE, max(0, strike - settlement) for PE)
  • Stock options: physical delivery at strike

Settlement prices come from Yahoo Finance (close price on the expiry date). Approximate but usually within 0.3% of the exchange VWAP.

Common gotchas

"I uploaded but nothing changed"

Refresh the analysis page. The first compute pass takes a few seconds. If still empty, check Settings โ†’ Data Coverage to confirm the trades are in the database.

"Open positions look wrong"

Most common cause: a missing corporate action. Compare your open position count to your real broker holdings. If they differ, the gap is usually a missing split or merger. Email support with the symbol and date โ€” adding a corporate action is a 5-minute fix on our end and we'll recompute your P&L automatically.

"P&L doesn't match Kite's report"

TraderTape's P&L includes some things Kite doesn't (e.g. demerger cost basis reduction per Section 49) and excludes some things Kite includes (e.g. open positions in the realized bucket). Expect a 1-2% difference. The Cross-Validation section of CLAUDE.md has the full breakdown.

"Old upload added duplicates"

If you see duplicates from an older upload, email support with your account email โ€” we'll dedupe them server-side. The current parser dedupes correctly, so this only affects historical uploads.

"Q1 2019 trades missing"

Kite's API doesn't return Q1 2019 data. If you have a personal record from another source (e.g. an Excel sheet you maintained), email support with the file and we can import it manually.

"Symbol XYZ not recognised"

The symbol may have changed (renamed, demerged). Check the MERGERS constant. If it's a genuine new symbol the parser doesn't know about, it'll still get imported โ€” but it won't have an Yahoo Finance price for backtesting.

What gets stored

After a successful upload, the system stores:

  • One record per trade fill (raw, unmodified)
  • One record per ledger entry (cash/margin/charge movements)
  • For CAS uploads: folios, schemes, transactions, and holdings snapshots

Corporate action virtual trades are computed on the fly during P&L calculation, not stored. If a corporate action is missing or wrong, fixing it doesn't require re-importing your data โ€” the next page refresh recomputes everything.

Privacy

If you have upload obfuscation enabled, uploads must go through the local agent (the cloud upload endpoint returns 403). The agent multiplies all numeric values by your obfuscation factor before sending the data to the cloud. The cloud sees scaled-down quantities; you see real values when viewing from the agent.

If obfuscation is off, uploads go through either the agent or the cloud directly. Choose based on your privacy preference.

Next