IndiaTradeCost 0.1.0__tar.gz

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (37) hide show
  1. indiatradecost-0.1.0/CHANGELOG.md +29 -0
  2. indiatradecost-0.1.0/CITATION.cff +25 -0
  3. indiatradecost-0.1.0/LICENSE +21 -0
  4. indiatradecost-0.1.0/LICENSE-DATA.md +18 -0
  5. indiatradecost-0.1.0/MANIFEST.in +4 -0
  6. indiatradecost-0.1.0/PKG-INFO +273 -0
  7. indiatradecost-0.1.0/README.md +242 -0
  8. indiatradecost-0.1.0/fit/README.md +88 -0
  9. indiatradecost-0.1.0/fit/example_books.py +113 -0
  10. indiatradecost-0.1.0/fit/fit_impact.py +192 -0
  11. indiatradecost-0.1.0/fit/fit_spread.py +165 -0
  12. indiatradecost-0.1.0/fit/make_calibration.py +66 -0
  13. indiatradecost-0.1.0/pyproject.toml +57 -0
  14. indiatradecost-0.1.0/setup.cfg +4 -0
  15. indiatradecost-0.1.0/src/IndiaTradeCost.egg-info/PKG-INFO +273 -0
  16. indiatradecost-0.1.0/src/IndiaTradeCost.egg-info/SOURCES.txt +35 -0
  17. indiatradecost-0.1.0/src/IndiaTradeCost.egg-info/dependency_links.txt +1 -0
  18. indiatradecost-0.1.0/src/IndiaTradeCost.egg-info/entry_points.txt +2 -0
  19. indiatradecost-0.1.0/src/IndiaTradeCost.egg-info/requires.txt +4 -0
  20. indiatradecost-0.1.0/src/IndiaTradeCost.egg-info/top_level.txt +1 -0
  21. indiatradecost-0.1.0/src/indiatradecost/__init__.py +76 -0
  22. indiatradecost-0.1.0/src/indiatradecost/__main__.py +3 -0
  23. indiatradecost-0.1.0/src/indiatradecost/brokers.py +64 -0
  24. indiatradecost-0.1.0/src/indiatradecost/calibration.json +250 -0
  25. indiatradecost-0.1.0/src/indiatradecost/calibration.py +97 -0
  26. indiatradecost-0.1.0/src/indiatradecost/charges.py +159 -0
  27. indiatradecost-0.1.0/src/indiatradecost/cli.py +280 -0
  28. indiatradecost-0.1.0/src/indiatradecost/history.py +89 -0
  29. indiatradecost-0.1.0/src/indiatradecost/impact.py +78 -0
  30. indiatradecost-0.1.0/src/indiatradecost/model.py +147 -0
  31. indiatradecost-0.1.0/src/indiatradecost/rates.py +96 -0
  32. indiatradecost-0.1.0/src/indiatradecost/spread.py +91 -0
  33. indiatradecost-0.1.0/tests/test_charges.py +179 -0
  34. indiatradecost-0.1.0/tests/test_cli.py +107 -0
  35. indiatradecost-0.1.0/tests/test_history.py +46 -0
  36. indiatradecost-0.1.0/tests/test_model.py +160 -0
  37. indiatradecost-0.1.0/tests/test_spread_and_impact.py +149 -0
@@ -0,0 +1,29 @@
1
+ # Changelog
2
+
3
+ ## 0.1.0
4
+
5
+ The first public release.
6
+
7
+ **Published rates**
8
+
9
+ - Brokerage, securities transaction tax, exchange charges, the investor protection levy, the SEBI
10
+ fee, stamp duty, GST and depository charges for NSE delivery, intraday and futures, and NSE and
11
+ BSE index options, with option expiry. Rates in force from 1 Apr 2026, read between 22 Oct and
12
+ 1 Nov 2026, each with its source.
13
+ - Dated rules for backtests: the 0.125% delivery tax of 1 Jun 2006 to 30 Jun 2012, and NSE's tick
14
+ history from before June 2024 to the price table of April 2025.
15
+
16
+ **Our own research**
17
+
18
+ - A spread and five level depth model, fitted on our own recording of the NSE order book over
19
+ eight sessions, 11 to 20 Nov 2026, for 498 stocks.
20
+ - The square root impact rule, with its coefficient fitted on the same recording at windows of
21
+ 1 to 360 minutes, with standard errors.
22
+ - A combined cost of an order at its own size: charges, half the spread and impact.
23
+ - The fitting code, so the same fits can be run on your own recording.
24
+
25
+ **Licences**
26
+
27
+ - The code is MIT licensed. The fitted numbers are licensed under CC BY 4.0, with a credit line
28
+ in `LICENSE-DATA.md` and inside the calibration file itself. `CITATION.cff` gives GitHub's
29
+ "Cite this repository" button.
@@ -0,0 +1,25 @@
1
+ cff-version: 1.2.0
2
+ message: "If you use this package or its fitted numbers, please cite it as below."
3
+ title: "IndiaTradeCost: what a trade really costs on the Indian stock market"
4
+ type: software
5
+ authors:
6
+ - name: "HERCULES"
7
+ version: 0.1.0
8
+ license:
9
+ - MIT
10
+ - CC-BY-4.0
11
+ repository-code: "https://github.com/tarunn613/IndiaTradeCost"
12
+ url: "https://github.com/tarunn613/IndiaTradeCost"
13
+ abstract: >-
14
+ Published brokerage, taxes and fees for Indian equity, futures and options
15
+ trades, each with its source, plus a spread and depth model and the square
16
+ root impact rule fitted on our own recording of the NSE order book over
17
+ eight sessions in November 2026. The code is MIT licensed. The fitted
18
+ numbers are licensed under CC BY 4.0.
19
+ keywords:
20
+ - india
21
+ - nse
22
+ - transaction costs
23
+ - market impact
24
+ - bid ask spread
25
+ - backtesting
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 Revenin Technologies
4
+
5
+ Permission is hereby granted, free of charge, to any person obtaining a copy
6
+ of this software and associated documentation files (the "Software"), to deal
7
+ in the Software without restriction, including without limitation the rights
8
+ to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9
+ copies of the Software, and to permit persons to whom the Software is
10
+ furnished to do so, subject to the following conditions:
11
+
12
+ The above copyright notice and this permission notice shall be included in all
13
+ copies or substantial portions of the Software.
14
+
15
+ THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16
+ IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17
+ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18
+ AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19
+ LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20
+ OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21
+ SOFTWARE.
@@ -0,0 +1,18 @@
1
+ # Licence for the fitted numbers
2
+
3
+ The code in this repository is licensed under the MIT licence in `LICENSE`.
4
+
5
+ The fitted numbers are licensed differently. They are our own research: the spread and depth coefficients, the impact coefficients, their standard errors, the medians by size group, and the description of how they were measured. They live in `src/indiatradecost/calibration.json`, and they are licensed under the Creative Commons Attribution 4.0 International licence (CC BY 4.0):
6
+
7
+ - the licence in brief: https://creativecommons.org/licenses/by/4.0/
8
+ - the full legal code: https://creativecommons.org/licenses/by/4.0/legalcode
9
+
10
+ You may copy, share and adapt these numbers for any purpose, commercial or not, as long as you give credit. A credit line such as this one is enough:
11
+
12
+ > Fitted coefficients from IndiaTradeCost by HERCULES, https://github.com/tarunn613/IndiaTradeCost, licensed under CC BY 4.0.
13
+
14
+ Say so if you changed them, for example by refitting or combining them with your own.
15
+
16
+ The statutory rates in the code are not ours. They are published by the exchanges, the regulator and the brokers named beside each one, and anyone may use them.
17
+
18
+ Copyright (c) 2026 Revenin Technologies.
@@ -0,0 +1,4 @@
1
+ include README.md CHANGELOG.md LICENSE LICENSE-DATA.md CITATION.cff
2
+ recursive-include tests *.py
3
+ recursive-include fit *.py *.md
4
+ global-exclude *.pyc __pycache__ .DS_Store
@@ -0,0 +1,273 @@
1
+ Metadata-Version: 2.4
2
+ Name: IndiaTradeCost
3
+ Version: 0.1.0
4
+ Summary: What a trade really costs on the Indian market: published charges, plus a spread and impact model fitted on recorded NSE order books.
5
+ Author: HERCULES
6
+ License-Expression: MIT AND CC-BY-4.0
7
+ Project-URL: Homepage, https://github.com/tarunn613/IndiaTradeCost
8
+ Project-URL: Source, https://github.com/tarunn613/IndiaTradeCost
9
+ Project-URL: Issues, https://github.com/tarunn613/IndiaTradeCost/issues
10
+ Project-URL: Changelog, https://github.com/tarunn613/IndiaTradeCost/blob/main/CHANGELOG.md
11
+ Keywords: india,nse,bse,stt,brokerage,transaction costs,market impact,bid ask spread,slippage,backtesting
12
+ Classifier: Development Status :: 4 - Beta
13
+ Classifier: Programming Language :: Python :: 3
14
+ Classifier: Programming Language :: Python :: 3.10
15
+ Classifier: Programming Language :: Python :: 3.11
16
+ Classifier: Programming Language :: Python :: 3.12
17
+ Classifier: Programming Language :: Python :: 3.13
18
+ Classifier: Operating System :: OS Independent
19
+ Classifier: Intended Audience :: Developers
20
+ Classifier: Intended Audience :: Financial and Insurance Industry
21
+ Classifier: Intended Audience :: Science/Research
22
+ Classifier: Topic :: Office/Business :: Financial :: Investment
23
+ Requires-Python: >=3.10
24
+ Description-Content-Type: text/markdown
25
+ License-File: LICENSE
26
+ License-File: LICENSE-DATA.md
27
+ Provides-Extra: fit
28
+ Requires-Dist: numpy>=1.24; extra == "fit"
29
+ Requires-Dist: pandas>=2.0; extra == "fit"
30
+ Dynamic: license-file
31
+
32
+ # IndiaTradeCost
33
+
34
+ What a trade really costs on the Indian stock market: the brokerage, taxes and fees you can look up, plus the two costs you cannot look up. Those are crossing the bid ask spread and moving the price with your own order.
35
+
36
+ The package keeps two kinds of number strictly apart.
37
+
38
+ **Published rates.** Brokerage, securities transaction tax (STT), exchange charges, the investor protection levy, the SEBI fee, stamp duty, GST and depository charges. Anyone can check these. Every rate in the package carries the circular or page it was read from and the date it was read.
39
+
40
+ **Our own research.** How wide the order book is for a stock of a given size, and how far an order of a given size moves the price. Nobody publishes these for India, so we measured them on our own recording of the NSE order book over eight sessions in November 2026. We publish the fitted coefficients, their standard errors, the summary medians by size group and the code that produced them. We do not publish the recorded books or ticks.
41
+
42
+ Python 3.10 or newer. No dependencies.
43
+
44
+ ## Install
45
+
46
+ ```bash
47
+ pip install IndiaTradeCost
48
+ ```
49
+
50
+ Or from a clone of this repository:
51
+
52
+ ```bash
53
+ pip install .
54
+ ```
55
+
56
+ ## A first example
57
+
58
+ ```python
59
+ from indiatradecost import Stock, round_trip_cost
60
+
61
+ # A stock that trades a median of ₹268.7 crore a day, moves 1.8% on a typical day,
62
+ # and is priced at ₹1,500. These are example figures, not a real stock.
63
+ stock = Stock(median_day=268.7e7, volatility=0.018, price=1_500.0)
64
+
65
+ cost = round_trip_cost(stock, 2_00_000, when="2026-11-20") # buy and sell ₹2 lakh
66
+
67
+ round(cost.charges.total, 2) # 515.76 published charges
68
+ round(cost.spread, 2) # 74.82 half the spread on each leg
69
+ round(cost.impact, 2) # 51.11 the move your own order makes
70
+ round(cost.bps(), 2) # 32.08 all of it, in basis points of one side
71
+ ```
72
+
73
+ `when` dates the trade, which sets the tax and NSE's tick size for that day, so the same call prices a trade in 2009 correctly. Each result splits its cost three ways, and `cost.as_dict()` lists every line.
74
+
75
+ ## From the command line
76
+
77
+ ```bash
78
+ indiatradecost trade 2L --median-day 268.7cr --volatility 0.018 --price 1500 --date 2026-11-20
79
+ ```
80
+
81
+ ```
82
+ Delivery round trip of Rs 200,000.00 a side on 2026-11-20
83
+ Brokerage: Angel One
84
+ Stock: median day Rs 268.7 crore, daily volatility 1.80%, price Rs 1,500.00
85
+
86
+ Charges 515.76 25.79 bps
87
+ Spread 74.82 3.74 bps
88
+ Impact 51.11 2.56 bps
89
+ Total 641.69 32.08 bps
90
+
91
+ Charges from published rates in force from 2026-04-01.
92
+ Spread and impact from our own fit on 8 recorded sessions, 2026-11-11 to 2026-11-20, at a 30 minute window.
93
+ ```
94
+
95
+ Amounts accept `L` for lakh and `cr` for crore. Add `--side buy` for one leg, `--segment intraday` for a same day trade, and `--broker none` for the statutory charges alone.
96
+
97
+ The charges on their own work for futures and options too:
98
+
99
+ ```bash
100
+ indiatradecost round-trip delivery 150000 150000
101
+ indiatradecost order futures sell 1500000 --broker none
102
+ indiatradecost order options buy 6500 --venue BSE
103
+ indiatradecost expiry 3250 --short
104
+ ```
105
+
106
+ And `indiatradecost calibration` prints what the model was fitted on, with every coefficient.
107
+
108
+ ## How the three costs behave
109
+
110
+ One leg of an order worth `value` rupees costs
111
+
112
+ ```
113
+ published charges at that order's own size, at the rates of its date
114
+ + value × half the fitted spread
115
+ + value × Y × daily volatility × √(value / median day)
116
+ ```
117
+
118
+ Each part grows differently with the order, which is why the package keeps them apart. Charges are heavy on small orders, because of the brokerage minimum and the flat depository fee. The spread is a fixed share of whatever you trade. Impact grows with the square root of the order, so it is negligible on a small order and the largest cost on a big one.
119
+
120
+ The example stock above, bought and sold on the same terms at five sizes:
121
+
122
+ | Order, each side | Charges | Spread | Impact | Total | Total, bps |
123
+ |---:|---:|---:|---:|---:|---:|
124
+ | ₹10,000 | ₹69.45 | ₹3.74 | ₹0.57 | ₹73.76 | 73.76 |
125
+ | ₹1 lakh | ₹293.28 | ₹37.41 | ₹18.07 | ₹348.76 | 34.88 |
126
+ | ₹10 lakh | ₹2,295.61 | ₹374.11 | ₹571.43 | ₹3,241.15 | 32.41 |
127
+ | ₹1 crore | ₹22,318.92 | ₹3,741.11 | ₹18,070.20 | ₹44,130.23 | 44.13 |
128
+ | ₹10 crore | ₹2,22,552.00 | ₹37,411.08 | ₹5,71,429.89 | ₹8,31,392.97 | 83.14 |
129
+
130
+ The cheapest size in basis points sits in the middle. Below it you pay for the brokerage minimum, and above it you pay for your own footprint.
131
+
132
+ ## Published rates
133
+
134
+ In force from 1 Apr 2026, read between 22 Oct and 1 Nov 2026.
135
+
136
+ | Charge | Delivery | Intraday | Futures | Options |
137
+ |---|---|---|---|---|
138
+ | STT | 0.1% on the buy and on the sell | 0.025% on the sell | 0.05% on the sell | 0.15% of the premium on the sell, and 0.15% of the intrinsic value of an exercised option, paid by its holder |
139
+ | Stamp duty | 0.015% on the buy | 0.003% on the buy | 0.002% on the buy | 0.003% of the premium on the buy |
140
+ | Exchange charge, each side | NSE ₹306.99 a crore | NSE ₹306.99 a crore | NSE ₹182.99 a crore | NSE 0.0355299% of the premium, BSE 0.0325% |
141
+ | IPFT levy, each side | ₹0.01 a crore | ₹0.01 a crore | ₹0.01 a crore | ₹0.01 a crore |
142
+ | SEBI fee, each side | ₹10 a crore | ₹10 a crore | ₹10 a crore | ₹10 a crore |
143
+ | GST | 18% of brokerage, exchange charge, IPFT levy, SEBI fee and depository charge | same | same | same |
144
+
145
+ Sources:
146
+
147
+ 1. NSE circular [NSE/FA/73061](https://nsearchives.nseindia.com/content/circulars/FA73061.pdf) of 27 Feb 2026, for the cash market's exchange charge and the IPFT levy from 1 Mar 2026.
148
+ 2. Angel One's [pricing](https://www.angelone.in/pricing) and [exchange transaction charges](https://www.angelone.in/exchange-transaction-charges) pages, read 22 Oct to 1 Nov 2026, for STT, stamp duty, the futures and options exchange charges, the SEBI fee and GST.
149
+ 3. Zerodha's [charges page](https://zerodha.com/charges/), read 31 Oct 2026, which agrees on the futures rates.
150
+ 4. The higher futures and options STT from 1 Apr 2026 follows the Union Budget of 1 Feb 2026, as reported, for example, in [PRS India's analysis](https://prsindia.org/budgets/parliament/union-budget-2026-27-analysis). We could not open the Finance Act's text itself.
151
+
152
+ The same sources sit in `RATES.sources`.
153
+
154
+ ### Brokerage
155
+
156
+ Brokerage and depository charges belong to each broker, so every call names one. Two are built in, and you can define your own with `Broker` and `Fee`.
157
+
158
+ | Preset | Delivery and intraday | Futures and options | Options at expiry | Depository charge on a delivery sale |
159
+ |---|---|---|---|---|
160
+ | `ANGEL_ONE` | 0.1% of the order, at most ₹20 and at least ₹5 | ₹20 an order | ₹20 | ₹20 a stock a day, plus GST |
161
+ | `NO_BROKERAGE` | none | none | none | none |
162
+
163
+ `ANGEL_ONE` holds Angel One's published rates for individual accounts, read on angelone.in: cash on 22 and 27 Oct 2026, futures on 31 Oct 2026 and options on 1 Nov 2026.
164
+
165
+ ### Rates for past dates
166
+
167
+ A backtest should not charge 2026 rates in 2008, so two rules carry dates:
168
+
169
+ - **STT on delivery** was 0.125% on each side from 1 Jun 2006 to 30 Jun 2012 and 0.1% outside those dates. These are the dates our research has used. We have not checked them against the Finance Acts that set them. Any different rate before June 2006 is not modelled.
170
+ - **NSE's tick** was ₹0.05 for every stock until 9 Jun 2024. It then fell to ₹0.01 below ₹250, and from 15 Apr 2025 it follows a table of the price. The 2025 table comes from NSE circular [NSE/CMTR/67133](https://nsearchives.nseindia.com/content/circulars/CMTR67133.pdf) of 13 Mar 2025. The 2024 change comes from press and broker reports. The flat ₹0.05 before 2024 is an inference from NSE's own research for March 2004 and reports from just before June 2024, not a reading of every circular in between.
171
+
172
+ The details sit in `indiatradecost.history.SOURCES`.
173
+
174
+ ## Our own research
175
+
176
+ ### What we recorded
177
+
178
+ We recorded the NSE order book for the month's 500 most traded stocks, by rupees traded, from Angel One's market data feed, over the eight sessions from 11 to 20 Nov 2026. The recording kept every update the feed sent: the best five bids and offers with their quantities, the last trade price and the day's traded volume. The spread fit reads the book once a minute. The impact fit reads every update and treats each rise in the day's volume as a trade at the last price, so several trades between two updates count as one.
179
+
180
+ Stocks are grouped by market value rank: large 1 to 100, mid 101 to 250 and small 251 to 500. "Outside 500" holds stocks traded heavily enough to be recorded but ranked below 500 by market value. A stock's median day is its median daily rupees traded over the six months before the recording. Its volatility is the standard deviation of its daily log returns over the last sixty sessions.
181
+
182
+ ### The spread
183
+
184
+ For each stock, we took the median quoted spread over each window's snapshots, then the median over the eight sessions. Across the 498 stocks we fitted
185
+
186
+ ```
187
+ log(spread in bps) = a + b log(median day) + c log(volatility) + d log(price)
188
+ ```
189
+
190
+ by least squares, for two windows. The opening window runs from 09:16 to 09:30, which is where an order placed at the open trades. The day window runs from 09:16 to 15:15. Standard errors are in brackets.
191
+
192
+ | Window | a | b, median day | c, volatility | d, price | R² | Stocks |
193
+ |---|---:|---:|---:|---:|---:|---:|
194
+ | Open | 9.179 (0.198) | −0.286 (0.010) | +0.438 (0.028) | +0.014 (0.006) | 0.75 | 498 |
195
+ | Day | 9.713 (0.237) | −0.324 (0.012) | +0.474 (0.034) | +0.013 (0.008) | 0.72 | 498 |
196
+
197
+ The signs are what you would expect. A stock that trades ten times as much has a book about half as wide at the open. A more volatile stock has a wider book, and price barely matters once the other two are known. The fit explains three quarters of the variation across stocks, and it lands within 0.4 bps of the measured median in every group:
198
+
199
+ | Window | Group | Stocks | Median day | Spread measured | Spread fitted | Depth on five levels, one side | Minutes at one tick |
200
+ |---|---|---:|---:|---:|---:|---:|---:|
201
+ | Open | Large | 100 | ₹268.7 crore | 3.43 bps | 3.67 bps | ₹8.7 lakh | 5.0% |
202
+ | Open | Mid | 130 | ₹101.2 crore | 4.84 bps | 5.04 bps | ₹3.8 lakh | 2.5% |
203
+ | Open | Small | 139 | ₹59.1 crore | 6.24 bps | 6.30 bps | ₹1.6 lakh | 1.7% |
204
+ | Open | Outside 500 | 129 | ₹34.6 crore | 7.40 bps | 7.76 bps | ₹1.1 lakh | 0.8% |
205
+ | Day | Large | 100 | ₹268.7 crore | 2.16 bps | 2.31 bps | ₹11.1 lakh | 21.1% |
206
+ | Day | Mid | 130 | ₹101.2 crore | 3.23 bps | 3.32 bps | ₹5.1 lakh | 12.7% |
207
+ | Day | Small | 139 | ₹59.1 crore | 4.21 bps | 4.24 bps | ₹2.2 lakh | 7.5% |
208
+ | Day | Outside 500 | 129 | ₹34.6 crore | 5.28 bps | 5.39 bps | ₹1.4 lakh | 4.9% |
209
+
210
+ Books are about half as wide again in the opening quarter hour as over the whole day. The same form fits the rupees resting on the five levels of a side; those coefficients are in the calibration file. A fitted spread is never allowed below one tick, and the model charges half the spread on each leg.
211
+
212
+ ### The impact
213
+
214
+ We signed each recorded trade by the side of the book it hit: a buy at or above the offer standing just before it, a sale at or below the bid, otherwise by the side of the middle, otherwise by the tick rule. We then added up net buying over clock windows from 09:15 to 15:15. For each window length we fitted
215
+
216
+ ```
217
+ move of the middle price / daily volatility = Y × sign(net buying) × √(|net buying| / median day)
218
+ ```
219
+
220
+ by least squares through zero, with each stock day as a cluster for the standard error. This is the square root rule, and Y is its one free number.
221
+
222
+ | Window | Y | Standard error | Windows | Log log slope |
223
+ |---:|---:|---:|---:|---:|
224
+ | 1 minute | 0.610 | 0.008 | 288,000 | 0.58 |
225
+ | 5 minutes | 0.689 | 0.014 | 57,600 | 0.86 |
226
+ | 15 minutes | 0.761 | 0.021 | 19,200 | 0.54 |
227
+ | 30 minutes | 0.823 | 0.032 | 9,600 | 0.57 |
228
+ | 60 minutes | 0.872 | 0.048 | 4,800 | 0.57 |
229
+ | 120 minutes | 0.888 | 0.073 | 2,400 | 0.53 |
230
+ | Full day | 0.628 | 0.121 | 800 | 0.25 |
231
+
232
+ Y rises with the window, because a longer window holds more of the move, until the full day, where only 800 windows remain and the error is wide. The model uses 30 minutes by default, and `minutes=` picks another. The last column checks the shape: across bins of the traded share of a day, the move grew with a slope between 0.53 and 0.58 on a log scale at every window except 5 minutes and the full day. An exact square root would give 0.5.
233
+
234
+ ### How far to trust it
235
+
236
+ Plainly, this is a first measurement, not a settled one.
237
+
238
+ - **Eight sessions of one month.** A fit on 11 to 20 Nov 2026 may not hold in a busier or quieter market. Check it against your own fills.
239
+ - **Impact comes from large caps only.** Y was fitted on the 100 largest stocks. Smaller stocks are priced with the same Y and their own volatility and median day. That is an extrapolation we have not tested.
240
+ - **Impact is the whole market's flow.** It measures everyone's net buying together, not one trader's order worked over time, which is what the square root rule was found on. A slice worked through a window pays on average less than the move measured at the window's end, so charging the whole fitted move is cautious rather than optimistic.
241
+ - **The past is a reach.** Applying the spread fit to earlier years assumes the link between liquidity and spread held then too. A fit on November 2026 cannot test that. The tick floor helps, because ticks were coarser before 2024.
242
+
243
+ To use your own coefficients, refit on your own recording and point the package at the result:
244
+
245
+ ```bash
246
+ export INDIATRADECOST_CALIBRATION=/path/to/calibration.json
247
+ ```
248
+
249
+ The fitting code and the format it expects are in [`fit/`](fit/README.md). You can also pass your own `y=` straight to `impact_share` or `leg_cost`.
250
+
251
+ ## What it does not cover
252
+
253
+ - Spread and impact for futures and options. The charges cover them, but our recording held cash equity books only.
254
+ - BSE cash and BSE futures, currency and commodity derivatives, and the physical settlement of stock futures and options.
255
+ - The opening and closing auctions. The fits cover continuous trading.
256
+ - Capital gains tax, account maintenance fees, margin interest and service fees such as call and trade.
257
+ - Rounding on contract notes. Some brokers round lines; this package does not.
258
+
259
+ ## Keeping it current
260
+
261
+ Rates change, most often at the Union Budget in February and through exchange circulars. If a rate here has changed, please open an issue with a link to the source.
262
+
263
+ ## Licence
264
+
265
+ The code is MIT licensed, in `LICENSE`.
266
+
267
+ The fitted numbers in `calibration.json` are our own research and are licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), in `LICENSE-DATA.md`. You may use them for anything, commercial or not, as long as you credit them, for example:
268
+
269
+ > Fitted coefficients from IndiaTradeCost by HERCULES, https://github.com/tarunn613/IndiaTradeCost, licensed under CC BY 4.0.
270
+
271
+ The statutory rates belong to the exchanges, the regulator and the brokers that publish them. To cite the package itself, use the "Cite this repository" button on GitHub, which reads `CITATION.cff`.
272
+
273
+ Built by HERCULES.
@@ -0,0 +1,242 @@
1
+ # IndiaTradeCost
2
+
3
+ What a trade really costs on the Indian stock market: the brokerage, taxes and fees you can look up, plus the two costs you cannot look up. Those are crossing the bid ask spread and moving the price with your own order.
4
+
5
+ The package keeps two kinds of number strictly apart.
6
+
7
+ **Published rates.** Brokerage, securities transaction tax (STT), exchange charges, the investor protection levy, the SEBI fee, stamp duty, GST and depository charges. Anyone can check these. Every rate in the package carries the circular or page it was read from and the date it was read.
8
+
9
+ **Our own research.** How wide the order book is for a stock of a given size, and how far an order of a given size moves the price. Nobody publishes these for India, so we measured them on our own recording of the NSE order book over eight sessions in November 2026. We publish the fitted coefficients, their standard errors, the summary medians by size group and the code that produced them. We do not publish the recorded books or ticks.
10
+
11
+ Python 3.10 or newer. No dependencies.
12
+
13
+ ## Install
14
+
15
+ ```bash
16
+ pip install IndiaTradeCost
17
+ ```
18
+
19
+ Or from a clone of this repository:
20
+
21
+ ```bash
22
+ pip install .
23
+ ```
24
+
25
+ ## A first example
26
+
27
+ ```python
28
+ from indiatradecost import Stock, round_trip_cost
29
+
30
+ # A stock that trades a median of ₹268.7 crore a day, moves 1.8% on a typical day,
31
+ # and is priced at ₹1,500. These are example figures, not a real stock.
32
+ stock = Stock(median_day=268.7e7, volatility=0.018, price=1_500.0)
33
+
34
+ cost = round_trip_cost(stock, 2_00_000, when="2026-11-20") # buy and sell ₹2 lakh
35
+
36
+ round(cost.charges.total, 2) # 515.76 published charges
37
+ round(cost.spread, 2) # 74.82 half the spread on each leg
38
+ round(cost.impact, 2) # 51.11 the move your own order makes
39
+ round(cost.bps(), 2) # 32.08 all of it, in basis points of one side
40
+ ```
41
+
42
+ `when` dates the trade, which sets the tax and NSE's tick size for that day, so the same call prices a trade in 2009 correctly. Each result splits its cost three ways, and `cost.as_dict()` lists every line.
43
+
44
+ ## From the command line
45
+
46
+ ```bash
47
+ indiatradecost trade 2L --median-day 268.7cr --volatility 0.018 --price 1500 --date 2026-11-20
48
+ ```
49
+
50
+ ```
51
+ Delivery round trip of Rs 200,000.00 a side on 2026-11-20
52
+ Brokerage: Angel One
53
+ Stock: median day Rs 268.7 crore, daily volatility 1.80%, price Rs 1,500.00
54
+
55
+ Charges 515.76 25.79 bps
56
+ Spread 74.82 3.74 bps
57
+ Impact 51.11 2.56 bps
58
+ Total 641.69 32.08 bps
59
+
60
+ Charges from published rates in force from 2026-04-01.
61
+ Spread and impact from our own fit on 8 recorded sessions, 2026-11-11 to 2026-11-20, at a 30 minute window.
62
+ ```
63
+
64
+ Amounts accept `L` for lakh and `cr` for crore. Add `--side buy` for one leg, `--segment intraday` for a same day trade, and `--broker none` for the statutory charges alone.
65
+
66
+ The charges on their own work for futures and options too:
67
+
68
+ ```bash
69
+ indiatradecost round-trip delivery 150000 150000
70
+ indiatradecost order futures sell 1500000 --broker none
71
+ indiatradecost order options buy 6500 --venue BSE
72
+ indiatradecost expiry 3250 --short
73
+ ```
74
+
75
+ And `indiatradecost calibration` prints what the model was fitted on, with every coefficient.
76
+
77
+ ## How the three costs behave
78
+
79
+ One leg of an order worth `value` rupees costs
80
+
81
+ ```
82
+ published charges at that order's own size, at the rates of its date
83
+ + value × half the fitted spread
84
+ + value × Y × daily volatility × √(value / median day)
85
+ ```
86
+
87
+ Each part grows differently with the order, which is why the package keeps them apart. Charges are heavy on small orders, because of the brokerage minimum and the flat depository fee. The spread is a fixed share of whatever you trade. Impact grows with the square root of the order, so it is negligible on a small order and the largest cost on a big one.
88
+
89
+ The example stock above, bought and sold on the same terms at five sizes:
90
+
91
+ | Order, each side | Charges | Spread | Impact | Total | Total, bps |
92
+ |---:|---:|---:|---:|---:|---:|
93
+ | ₹10,000 | ₹69.45 | ₹3.74 | ₹0.57 | ₹73.76 | 73.76 |
94
+ | ₹1 lakh | ₹293.28 | ₹37.41 | ₹18.07 | ₹348.76 | 34.88 |
95
+ | ₹10 lakh | ₹2,295.61 | ₹374.11 | ₹571.43 | ₹3,241.15 | 32.41 |
96
+ | ₹1 crore | ₹22,318.92 | ₹3,741.11 | ₹18,070.20 | ₹44,130.23 | 44.13 |
97
+ | ₹10 crore | ₹2,22,552.00 | ₹37,411.08 | ₹5,71,429.89 | ₹8,31,392.97 | 83.14 |
98
+
99
+ The cheapest size in basis points sits in the middle. Below it you pay for the brokerage minimum, and above it you pay for your own footprint.
100
+
101
+ ## Published rates
102
+
103
+ In force from 1 Apr 2026, read between 22 Oct and 1 Nov 2026.
104
+
105
+ | Charge | Delivery | Intraday | Futures | Options |
106
+ |---|---|---|---|---|
107
+ | STT | 0.1% on the buy and on the sell | 0.025% on the sell | 0.05% on the sell | 0.15% of the premium on the sell, and 0.15% of the intrinsic value of an exercised option, paid by its holder |
108
+ | Stamp duty | 0.015% on the buy | 0.003% on the buy | 0.002% on the buy | 0.003% of the premium on the buy |
109
+ | Exchange charge, each side | NSE ₹306.99 a crore | NSE ₹306.99 a crore | NSE ₹182.99 a crore | NSE 0.0355299% of the premium, BSE 0.0325% |
110
+ | IPFT levy, each side | ₹0.01 a crore | ₹0.01 a crore | ₹0.01 a crore | ₹0.01 a crore |
111
+ | SEBI fee, each side | ₹10 a crore | ₹10 a crore | ₹10 a crore | ₹10 a crore |
112
+ | GST | 18% of brokerage, exchange charge, IPFT levy, SEBI fee and depository charge | same | same | same |
113
+
114
+ Sources:
115
+
116
+ 1. NSE circular [NSE/FA/73061](https://nsearchives.nseindia.com/content/circulars/FA73061.pdf) of 27 Feb 2026, for the cash market's exchange charge and the IPFT levy from 1 Mar 2026.
117
+ 2. Angel One's [pricing](https://www.angelone.in/pricing) and [exchange transaction charges](https://www.angelone.in/exchange-transaction-charges) pages, read 22 Oct to 1 Nov 2026, for STT, stamp duty, the futures and options exchange charges, the SEBI fee and GST.
118
+ 3. Zerodha's [charges page](https://zerodha.com/charges/), read 31 Oct 2026, which agrees on the futures rates.
119
+ 4. The higher futures and options STT from 1 Apr 2026 follows the Union Budget of 1 Feb 2026, as reported, for example, in [PRS India's analysis](https://prsindia.org/budgets/parliament/union-budget-2026-27-analysis). We could not open the Finance Act's text itself.
120
+
121
+ The same sources sit in `RATES.sources`.
122
+
123
+ ### Brokerage
124
+
125
+ Brokerage and depository charges belong to each broker, so every call names one. Two are built in, and you can define your own with `Broker` and `Fee`.
126
+
127
+ | Preset | Delivery and intraday | Futures and options | Options at expiry | Depository charge on a delivery sale |
128
+ |---|---|---|---|---|
129
+ | `ANGEL_ONE` | 0.1% of the order, at most ₹20 and at least ₹5 | ₹20 an order | ₹20 | ₹20 a stock a day, plus GST |
130
+ | `NO_BROKERAGE` | none | none | none | none |
131
+
132
+ `ANGEL_ONE` holds Angel One's published rates for individual accounts, read on angelone.in: cash on 22 and 27 Oct 2026, futures on 31 Oct 2026 and options on 1 Nov 2026.
133
+
134
+ ### Rates for past dates
135
+
136
+ A backtest should not charge 2026 rates in 2008, so two rules carry dates:
137
+
138
+ - **STT on delivery** was 0.125% on each side from 1 Jun 2006 to 30 Jun 2012 and 0.1% outside those dates. These are the dates our research has used. We have not checked them against the Finance Acts that set them. Any different rate before June 2006 is not modelled.
139
+ - **NSE's tick** was ₹0.05 for every stock until 9 Jun 2024. It then fell to ₹0.01 below ₹250, and from 15 Apr 2025 it follows a table of the price. The 2025 table comes from NSE circular [NSE/CMTR/67133](https://nsearchives.nseindia.com/content/circulars/CMTR67133.pdf) of 13 Mar 2025. The 2024 change comes from press and broker reports. The flat ₹0.05 before 2024 is an inference from NSE's own research for March 2004 and reports from just before June 2024, not a reading of every circular in between.
140
+
141
+ The details sit in `indiatradecost.history.SOURCES`.
142
+
143
+ ## Our own research
144
+
145
+ ### What we recorded
146
+
147
+ We recorded the NSE order book for the month's 500 most traded stocks, by rupees traded, from Angel One's market data feed, over the eight sessions from 11 to 20 Nov 2026. The recording kept every update the feed sent: the best five bids and offers with their quantities, the last trade price and the day's traded volume. The spread fit reads the book once a minute. The impact fit reads every update and treats each rise in the day's volume as a trade at the last price, so several trades between two updates count as one.
148
+
149
+ Stocks are grouped by market value rank: large 1 to 100, mid 101 to 250 and small 251 to 500. "Outside 500" holds stocks traded heavily enough to be recorded but ranked below 500 by market value. A stock's median day is its median daily rupees traded over the six months before the recording. Its volatility is the standard deviation of its daily log returns over the last sixty sessions.
150
+
151
+ ### The spread
152
+
153
+ For each stock, we took the median quoted spread over each window's snapshots, then the median over the eight sessions. Across the 498 stocks we fitted
154
+
155
+ ```
156
+ log(spread in bps) = a + b log(median day) + c log(volatility) + d log(price)
157
+ ```
158
+
159
+ by least squares, for two windows. The opening window runs from 09:16 to 09:30, which is where an order placed at the open trades. The day window runs from 09:16 to 15:15. Standard errors are in brackets.
160
+
161
+ | Window | a | b, median day | c, volatility | d, price | R² | Stocks |
162
+ |---|---:|---:|---:|---:|---:|---:|
163
+ | Open | 9.179 (0.198) | −0.286 (0.010) | +0.438 (0.028) | +0.014 (0.006) | 0.75 | 498 |
164
+ | Day | 9.713 (0.237) | −0.324 (0.012) | +0.474 (0.034) | +0.013 (0.008) | 0.72 | 498 |
165
+
166
+ The signs are what you would expect. A stock that trades ten times as much has a book about half as wide at the open. A more volatile stock has a wider book, and price barely matters once the other two are known. The fit explains three quarters of the variation across stocks, and it lands within 0.4 bps of the measured median in every group:
167
+
168
+ | Window | Group | Stocks | Median day | Spread measured | Spread fitted | Depth on five levels, one side | Minutes at one tick |
169
+ |---|---|---:|---:|---:|---:|---:|---:|
170
+ | Open | Large | 100 | ₹268.7 crore | 3.43 bps | 3.67 bps | ₹8.7 lakh | 5.0% |
171
+ | Open | Mid | 130 | ₹101.2 crore | 4.84 bps | 5.04 bps | ₹3.8 lakh | 2.5% |
172
+ | Open | Small | 139 | ₹59.1 crore | 6.24 bps | 6.30 bps | ₹1.6 lakh | 1.7% |
173
+ | Open | Outside 500 | 129 | ₹34.6 crore | 7.40 bps | 7.76 bps | ₹1.1 lakh | 0.8% |
174
+ | Day | Large | 100 | ₹268.7 crore | 2.16 bps | 2.31 bps | ₹11.1 lakh | 21.1% |
175
+ | Day | Mid | 130 | ₹101.2 crore | 3.23 bps | 3.32 bps | ₹5.1 lakh | 12.7% |
176
+ | Day | Small | 139 | ₹59.1 crore | 4.21 bps | 4.24 bps | ₹2.2 lakh | 7.5% |
177
+ | Day | Outside 500 | 129 | ₹34.6 crore | 5.28 bps | 5.39 bps | ₹1.4 lakh | 4.9% |
178
+
179
+ Books are about half as wide again in the opening quarter hour as over the whole day. The same form fits the rupees resting on the five levels of a side; those coefficients are in the calibration file. A fitted spread is never allowed below one tick, and the model charges half the spread on each leg.
180
+
181
+ ### The impact
182
+
183
+ We signed each recorded trade by the side of the book it hit: a buy at or above the offer standing just before it, a sale at or below the bid, otherwise by the side of the middle, otherwise by the tick rule. We then added up net buying over clock windows from 09:15 to 15:15. For each window length we fitted
184
+
185
+ ```
186
+ move of the middle price / daily volatility = Y × sign(net buying) × √(|net buying| / median day)
187
+ ```
188
+
189
+ by least squares through zero, with each stock day as a cluster for the standard error. This is the square root rule, and Y is its one free number.
190
+
191
+ | Window | Y | Standard error | Windows | Log log slope |
192
+ |---:|---:|---:|---:|---:|
193
+ | 1 minute | 0.610 | 0.008 | 288,000 | 0.58 |
194
+ | 5 minutes | 0.689 | 0.014 | 57,600 | 0.86 |
195
+ | 15 minutes | 0.761 | 0.021 | 19,200 | 0.54 |
196
+ | 30 minutes | 0.823 | 0.032 | 9,600 | 0.57 |
197
+ | 60 minutes | 0.872 | 0.048 | 4,800 | 0.57 |
198
+ | 120 minutes | 0.888 | 0.073 | 2,400 | 0.53 |
199
+ | Full day | 0.628 | 0.121 | 800 | 0.25 |
200
+
201
+ Y rises with the window, because a longer window holds more of the move, until the full day, where only 800 windows remain and the error is wide. The model uses 30 minutes by default, and `minutes=` picks another. The last column checks the shape: across bins of the traded share of a day, the move grew with a slope between 0.53 and 0.58 on a log scale at every window except 5 minutes and the full day. An exact square root would give 0.5.
202
+
203
+ ### How far to trust it
204
+
205
+ Plainly, this is a first measurement, not a settled one.
206
+
207
+ - **Eight sessions of one month.** A fit on 11 to 20 Nov 2026 may not hold in a busier or quieter market. Check it against your own fills.
208
+ - **Impact comes from large caps only.** Y was fitted on the 100 largest stocks. Smaller stocks are priced with the same Y and their own volatility and median day. That is an extrapolation we have not tested.
209
+ - **Impact is the whole market's flow.** It measures everyone's net buying together, not one trader's order worked over time, which is what the square root rule was found on. A slice worked through a window pays on average less than the move measured at the window's end, so charging the whole fitted move is cautious rather than optimistic.
210
+ - **The past is a reach.** Applying the spread fit to earlier years assumes the link between liquidity and spread held then too. A fit on November 2026 cannot test that. The tick floor helps, because ticks were coarser before 2024.
211
+
212
+ To use your own coefficients, refit on your own recording and point the package at the result:
213
+
214
+ ```bash
215
+ export INDIATRADECOST_CALIBRATION=/path/to/calibration.json
216
+ ```
217
+
218
+ The fitting code and the format it expects are in [`fit/`](fit/README.md). You can also pass your own `y=` straight to `impact_share` or `leg_cost`.
219
+
220
+ ## What it does not cover
221
+
222
+ - Spread and impact for futures and options. The charges cover them, but our recording held cash equity books only.
223
+ - BSE cash and BSE futures, currency and commodity derivatives, and the physical settlement of stock futures and options.
224
+ - The opening and closing auctions. The fits cover continuous trading.
225
+ - Capital gains tax, account maintenance fees, margin interest and service fees such as call and trade.
226
+ - Rounding on contract notes. Some brokers round lines; this package does not.
227
+
228
+ ## Keeping it current
229
+
230
+ Rates change, most often at the Union Budget in February and through exchange circulars. If a rate here has changed, please open an issue with a link to the source.
231
+
232
+ ## Licence
233
+
234
+ The code is MIT licensed, in `LICENSE`.
235
+
236
+ The fitted numbers in `calibration.json` are our own research and are licensed under [CC BY 4.0](https://creativecommons.org/licenses/by/4.0/), in `LICENSE-DATA.md`. You may use them for anything, commercial or not, as long as you credit them, for example:
237
+
238
+ > Fitted coefficients from IndiaTradeCost by HERCULES, https://github.com/tarunn613/IndiaTradeCost, licensed under CC BY 4.0.
239
+
240
+ The statutory rates belong to the exchanges, the regulator and the brokers that publish them. To cite the package itself, use the "Cite this repository" button on GitHub, which reads `CITATION.cff`.
241
+
242
+ Built by HERCULES.