Add Zerodha broker import (equity, long-only)#171
Open
rajeshmohanan wants to merge 1 commit into
Open
Conversation
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Adds support for importing trades from Zerodha (Kite), one of the largest Indian discount brokers, by parsing their tradebook CSV export.
New "Zerodha" entry in the broker import dropdown
Maps Zerodha's tradebook CSV columns to TradeNote's internal execution format
Since Zerodha's tradebook export doesn't include brokerage/taxes/fees, this PR computes them using Zerodha's published equity fee schedule (brokerage, STT, exchange transaction charges, SEBI charges, stamp duty, GST), classified per matched buy/sell pair as intraday or delivery based on whether they occurred on the same day
Scope (v1)
This is intentionally scoped to start:
Equity (EQ) segment only — no F&O, currency, or commodity
Long positions only — any sell that would require a short position is rejected with a clear error rather than imported incorrectly
One account per import — users with multiple Zerodha accounts should import each account's tradebook separately
Known limitation: fee estimation is approximate, not exact
Zerodha's tradebook export doesn't say whether an order was placed as intraday (MIS) or delivery (CNC), which is the actual basis Zerodha bills on. This PR estimates that by checking whether a matched buy/sell pair happened on the same calendar day. That's a reasonable approximation for journaling purposes, but it can diverge from the real ledger — e.g. a position originally placed as an intraday order but carried overnight will be billed by Zerodha at intraday rates, while this estimates it at delivery rates. Documented in brokers/README.md; not intended to be relied on for tax/accounting purposes.
Test plan
Done:
Not done: