Hello! Welcome to your next lesson.
In our last session, we explored the implicit costs of trading, like the bid-ask spread and slippage, which arise from the very structure of the market. Today, we shift our focus to the explicit costs: the unavoidable fees and taxes that are charged on every transaction.
Your goal is to build a trading bot that generates real cash flow, which means your profit and loss (P&L) calculations must be precise down to the last paisa. A strategy that looks profitable before costs can easily become a losing one after they are applied. This lesson will equip you to calculate brokerage, Securities Transaction Tax (STT), and Goods and Services Tax (GST) for both equity and F&O trades, ensuring your bot operates with a true understanding of its financial performance.
Deconstructing Your Trading Costs
Every trade you execute involves a set of charges that can be grouped into two main categories:
- Brokerage: The fee your broker (Angel One) charges for executing your trade.
- Statutory Charges: Taxes and fees levied by the government, exchanges, and regulatory bodies.
Let's begin with a video that gives a good overview of these charges using an example. While the broker in the video is Dhan, the types of charges are standardized across the industry.
Complete Guide to Trading Charges Explained | Futures, Commodity & Transaction Charges | Dhan
This video, 'Complete Guide to Trading Charges Explained', provides a clear walkthrough of the various fees involved in trading equities and futures in India.
Please watch the following segments: Equity Delivery (01:29 - 02:26): Get a feel for the types of charges on a simple delivery trade. Intraday Equity (03:51 - 05:24): Notice how the charges change for intraday, especially STT. Futures (05:24 - 09:03): Pay attention to how charges are calculated on a large contract value and the difference between buy-side and sell-side costs.
As you saw, the main components of your total cost are:
- Brokerage
- Securities Transaction Tax (STT) or Commodities Transaction Tax (CTT)
- Exchange Transaction Charges
- Goods and Services Tax (GST)
- Stamp Duty
- SEBI Turnover Charges
To calculate these, you first need to understand the concept of turnover.
Turnover is the total monetary value of your trade. Almost all charges are calculated as a percentage of this value.
- Equity (Intraday/Delivery): Turnover =
Price × Quantity - Futures: Turnover =
Price × Lot Size × Number of Lots - Options: Turnover =
(Premium) × Lot Size × Number of Lots
Now, let's get the specific rates for your chosen broker, Angel One.
Angel One Charges: The Authoritative Source
The most accurate information will come directly from your broker. The following resource is the definitive guide for our calculations.
Brokerage Charges, Transaction & Govt. Charges
This is Angel One's official page detailing their charges. We will use this as our primary source for all calculations. It's a good page to bookmark.
First, familiarize yourself with the structure of this page. Under the 'Equity' tab, look at the brokerage rates for 'Stock Investments' (delivery), 'Intraday Trading', and 'Futures & Options'. Then, examine the 'Regulatory & Statutory Charges' table, which lists all the percentages for STT, Transaction Charges, Stamp Duty, etc. Finally, quickly read the brief explanations of each charge type (e.g., STT, GST, Stamp Duty) further down the page to solidify your understanding.
Let's break down each charge with the specific rates for the NSE, which you'll be using.
1. Brokerage
Angel One uses a discount brokerage model. Based on the resource you just reviewed:
- Equity Delivery: ₹0 (Free)
- Equity Intraday: Lower of ₹20 or 0.1% of turnover per executed order.
- Equity/Index F&O: Flat ₹20 per executed order.
For your bot, you can almost always assume the flat ₹20 fee for intraday and F&O trades, as the turnover will likely make the percentage component higher.

2. Securities Transaction Tax (STT)
This is a direct tax levied by the government on transactions. The rates and applicability vary significantly.
- Equity Delivery: 0.1% on both buy and sell turnover.
- Equity Intraday: 0.025% on sell-side turnover only.
- Equity/Index Futures: 0.0125% on sell-side turnover only.
- Equity/Index Options: 0.0625% on sell-side turnover only (calculated on the premium). Note: The Angel One page can be slightly confusing here. The 0.0625% rate applies when you sell an options contract, which is the most common scenario for an algo. A different, higher rate applies if an option is exercised at expiry.
3. Exchange Transaction Charges (NSE)
This is a fee charged by the National Stock Exchange for using their platform.
- Equity (Delivery & Intraday): 0.00297% on turnover.
- Futures: 0.00173% on turnover.
- Options: 0.03503% on turnover (premium).
4. GST (Goods and Services Tax)
This is a standard tax of 18%. Crucially, it is levied on the sum of (Brokerage + Exchange Transaction Charges + SEBI Fees). It is not calculated on the trade's turnover itself.
5. Stamp Duty
This is charged by the government and, for your purposes, is applied only on the buy-side of a transaction.
- Equity Delivery: 0.015% on turnover.
- Equity Intraday: 0.003% on turnover.
- Futures: 0.002% on turnover.
- Options: 0.003% on turnover (premium).
6. SEBI Turnover Charges
A small fee charged by the regulator, SEBI. It's ₹10 per crore of turnover (or 0.0001%) on all segments.
Putting it Together: Calculation Examples
Let's walk through a few concrete examples. This is exactly the logic your bot will need to implement. We will calculate charges for a complete trade (one buy and one sell).
Scenario 1: Equity Intraday Trade
- Trade: Buy and sell 100 shares of
INFY. - Buy Price: ₹1,640
- Sell Price: ₹1,645
1. Calculate Turnover:
- Buy Turnover:
100 * 1640 = ₹1,64,000 - Sell Turnover:
100 * 1645 = ₹1,64,500 - Total Turnover:
₹3,28,500
2. Calculate Charges:
| Charge | Buy Leg Calculation | Sell Leg Calculation | Total | Notes |
|---|---|---|---|---|
| Brokerage | ₹20 |
₹20 |
₹40.00 |
Flat fee per order |
| STT | ₹0 |
1,64,500 * 0.025% = ₹41.13 |
₹41.13 |
Sell side only for intraday |
| Transaction Charge | 1,64,000 * 0.00297% = ₹4.87 |
1,64,500 * 0.00297% = ₹4.89 |
₹9.76 |
On both legs |
| Stamp Duty | 1,64,000 * 0.003% = ₹4.92 |
₹0 |
₹4.92 |
Buy side only |
| SEBI Fees | 1,64,000 * 0.0001% = ₹0.16 |
1,64,500 * 0.0001% = ₹0.16 |
₹0.32 |
On both legs |
| GST (18%) | (20 + 4.87 + 0.16) * 18% = ₹4.51 |
(20 + 4.89 + 0.16) * 18% = ₹4.51 |
₹9.02 |
On (Brokerage + Txn + SEBI) |
| TOTAL CHARGES | ₹105.15 |
3. Calculate Net P&L:
- Gross P&L:
(1645 - 1640) * 100 = ₹500 - Net P&L:
500 - 105.15 =₹394.85
Transaction costs consumed over 21% of your gross profit.
Scenario 2: NIFTY Futures Trade
- Trade: Buy and sell 1 lot of
NIFTYFutures. - Lot Size: 25
- Buy Price: 23,200
- Sell Price: 23,250
1. Calculate Turnover:
- Buy Turnover:
23200 * 25 = ₹5,80,000 - Sell Turnover:
23250 * 25 = ₹5,81,250 - Total Turnover:
₹11,61,250
2. Calculate Charges:
| Charge | Buy Leg Calculation | Sell Leg Calculation | Total | Notes |
|---|---|---|---|---|
| Brokerage | ₹20 |
₹20 |
₹40.00 |
Flat fee per order |
| STT | ₹0 |
5,81,250 * 0.0125% = ₹72.66 |
₹72.66 |
Sell side only for futures |
| Transaction Charge | 5,80,000 * 0.00173% = ₹10.03 |
5,81,250 * 0.00173% = ₹10.06 |
₹20.09 |
On both legs |
| Stamp Duty | 5,80,000 * 0.002% = ₹11.60 |
₹0 |
₹11.60 |
Buy side only |
| SEBI Fees | 5,80,000 * 0.0001% = ₹0.58 |
5,81,250 * 0.0001% = ₹0.58 |
₹1.16 |
On both legs |
| GST (18%) | (20 + 10.03 + 0.58) * 18% = ₹5.51 |
(20 + 10.06 + 0.58) * 18% = ₹5.52 |
₹11.03 |
On (Brokerage + Txn + SEBI) |
| TOTAL CHARGES | ₹156.54 |
3. Calculate Net P&L:
- Gross P&L:
(23250 - 23200) * 25 = ₹1,250 - Net P&L:
1250 - 156.54 =₹1,093.46
You can always verify these calculations using Angel One's brokerage calculator, which is a great tool for quick estimates.

Test your understanding!
You execute a trade in a NIFTY Call Option:
- Trade: Buy 1 lot of NIFTY 23500 Call Option, then sell it.
- Lot Size: 25
- Buy Premium: ₹150
- Sell Premium: ₹170
Calculate the approximate total charges for this round-trip trade. Use the rates for Options from the lesson.
Show answer
1. Turnover:
- Buy Turnover (Premium):
150 * 25 = ₹3,750 - Sell Turnover (Premium):
170 * 25 = ₹4,250
2. Charges:
- Brokerage:
₹20 (buy) + ₹20 (sell) = ₹40 - STT:
4,250 * 0.0625% (on sell premium) = ₹2.66 - Transaction Charge:
(3750 + 4250) * 0.03503% = ₹2.80 - Stamp Duty:
3750 * 0.003% (on buy premium) = ₹0.11 - SEBI Fees:
(3750 + 4250) * 0.0001% = ₹0.08 - GST:
(40 + 2.80 + 0.08) * 18% = ₹7.72 - Approximate Total Charges:
40 + 2.66 + 2.80 + 0.11 + 0.08 + 7.72 ≈₹53.37
Gross Profit was (170 - 150) * 25 = ₹500. Net profit is 500 - 53.37 = ₹446.63.
Towards Implementation: A Python Function Blueprint
Your background in software architecture will tell you that this logic is a perfect candidate for a dedicated utility function in your trading bot. Here is a Python function stub that outlines how you could structure this.
def calculate_trade_costs(
trade_type: str,
buy_price: float,
sell_price: float,
quantity: int,
lot_size: int = 1
) -> dict:
"""
Calculates the explicit costs for a round-trip trade on NSE.
Args:
trade_type (str): Type of trade. One of ['intraday', 'delivery', 'futures', 'options'].
buy_price (float): The price per share/contract at which the asset was bought.
sell_price (float): The price per share/contract at which the asset was sold.
quantity (int): Number of shares or lots.
lot_size (int): The number of shares in one lot (for F&O). Defaults to 1 for equity.
Returns:
dict: A dictionary containing detailed charges and net P&L.
"""
# 1. Define constants for charge rates (STT, Transaction, Stamp Duty etc.)
# It's good practice to store these in a configuration file.
# 2. Calculate buy and sell turnover based on trade_type
# if trade_type in ['intraday', 'delivery']:
# buy_turnover = buy_price * quantity
# sell_turnover = sell_price * quantity
# elif trade_type in ['futures', 'options']:
# buy_turnover = buy_price * quantity * lot_size
# sell_turnover = sell_price * quantity * lot_size
# 3. Calculate each charge component for buy and sell legs
# - Brokerage (handle ₹20 flat fee logic)
# - STT (apply only on sell leg for intraday/F&O)
# - Transaction Charge (apply on both legs)
# - Stamp Duty (apply only on buy leg)
# - SEBI Fees
# 4. Calculate GST on (Brokerage + Transaction + SEBI) for each leg
# 5. Sum all charges
# 6. Calculate Gross P&L and Net P&L
# 7. Return a dictionary with all calculated values for logging and analysis
results = {
"gross_pnl": 0.0,
"net_pnl": 0.0,
"total_charges": 0.0,
"brokerage": 0.0,
"stt": 0.0,
# ... other charges
}
# Placeholder return, implementation needed
return results
This function will be a core component of your bot's P&L and performance tracking module.
Conclusion
You now have a detailed, practical framework for calculating the explicit costs of trading. For an automated system, "close enough" isn't good enough; these calculations must be precise to give you a real measure of your strategy's edge.
Key Takeaways:
- Costs are multi-faceted: Trading costs are a combination of broker fees and various statutory charges (STT, GST, Stamp Duty, etc.).
- Turnover is key: Most charges are calculated as a percentage of the trade's turnover value.
- Segment and side matter: The applicable rates change significantly based on whether you are trading delivery, intraday, futures, or options, and whether you are on the buy or sell side of the transaction.
- GST is a tax on services: GST (18%) is applied to the sum of Brokerage, Transaction Charges, and SEBI fees, not the trade value itself.
- Profitability is Net, not Gross: Your bot must subtract all these charges from the gross P&L to determine the true profitability of a trade.
Preview of the Next Lesson:
We have now covered both the implicit (spread) and explicit (fees/taxes) costs of a trade. In the next lesson, we will complete our foundational knowledge of market mechanics by answering the question: "What happens after my order is executed?" We will explain the role of the clearing corporation and settlement cycles, which are the behind-the-scenes processes that ensure money and securities are correctly transferred between parties.