How to start algorithmic trading in India

The short answer

Algorithmic trading is a pipeline, not a script. You begin with a written hypothesis, assemble clean data, backtest it with realistic costs, paper-test it forward on live data, then wire it to a broker API for execution behind a risk and kill-switch layer with monitoring. Running alongside is the compliance gate: under SEBI's framework, retail API orders above a specified order-frequency threshold are treated as algo and must be tagged with an exchange-assigned algo ID through your broker. Coding is one link in that chain, and it is rarely the one that decides whether you make money.

Almost every search for "how to start algo trading" is really asking for the Python tutorial. The tutorial is a small, late part of the work. The uncomfortable truth, visible in the data on retail outcomes, is that most automated strategies fail before they place a single live order, and they fail in three specific places: the quality of the data, the honesty of the validation, and the accounting for cost. This guide walks the real end-to-end path, keeps the regulatory and risk layer in front where it belongs, and names the failure modes that quietly wreck the majority of attempts. If you want the market-level case for systematic trading in India, the companion landing page on algorithmic trading in India sets the scene; this article is the practitioner's build sheet.

The pipeline, end to end

An algorithmic trading system is a chain of stages, and the chain is only as strong as its weakest link. A brilliant execution layer cannot rescue a strategy built on a look-ahead bug, and a genuine edge can still bleed out through unmodelled costs or an unhandled disconnect. Read the pipeline left to right, but understand that each stage can veto everything downstream of it.

The algorithmic trading pipeline from hypothesis to live, with the kill-switch and the compliance gate Six stages run left to right: strategy hypothesis, data, backtest, paper and forward test, live execution through a broker API, and monitoring. A kill-switch layer sits beneath execution and monitoring and can halt the system on a limit breach. The SEBI compliance gate, requiring an exchange algo ID, sits over the execution stage. Idea to live: the six stages, and what guards them Hypothesis a written edge Data clean, no gaps Backtest in-sample Paper test forward, live data Execution broker API Monitoring and alerting SEBI gate: algo ID Kill-switch: halt on a limit breach Each stage can veto everything downstream. A weak link early is not fixed by a strong link late.
The pipeline is a veto chain, not a checklist. Data quality gates the backtest, the backtest gates the forward test, and the forward test gates live capital. The kill-switch spans execution and monitoring so a fault at either point stops the system, and the compliance gate attaches at the execution boundary, where your orders meet the exchange.

Stage one: a hypothesis you can actually test

A strategy is a falsifiable claim about the market, stated precisely enough that a computer can check it against history. "Momentum works" is not a hypothesis. "On the Nifty 50 index, a long position opened when the 20-day return is positive and closed when it turns negative, sized to a fixed risk, produces a positive expectancy after costs" is one, because every clause is measurable and the whole thing can be proven wrong. If your idea cannot be reduced to explicit entry, exit, and sizing rules, there is nothing to automate, because automation is exactly the act of writing those rules down without ambiguity.

The discipline here is to fix the rules before you see the results, not after. The moment you adjust the rule because the backtest looked poor, you have begun fitting the strategy to the very data you are meant to be testing it on, and the edge you measure afterwards is partly an illusion you built. Deciding what would make the idea sound, and what would kill it, in advance is the same judgement work that the method we teach is built around, and it is the part no library can do for you.

Stage two: data is where most edges quietly die

The single most under-appreciated fact in retail algo trading is that the data decides the result before the strategy does. Two data defects flatter almost every naive backtest.

Survivorship bias. Most freely available datasets contain only instruments that are still listed today. Every company that was delisted, merged away, or went to zero has been silently deleted from history. A strategy backtested on today's index members is quietly asking "how would this have done on the firms that survived," which is a question with a rosier answer than the one you need. An honest test uses point-in-time constituents and includes the names that later disappeared.

Look-ahead bias. A signal computed from a day's data cannot be acted on until the next tradable moment. In practice this means an indicator value on day N drives a position that opens on day N plus one, never the same bar. In a pandas backtest that is a one-line discipline, shifting the signal by one period before applying it. Omitting that shift lets the strategy trade on information it could not have had, and the resulting equity curve is fiction. Adjacent to it sit corporate-action errors: an unadjusted split or dividend produces a phantom overnight move that a careless strategy will happily and unrealistically capture.

Rule of thumb. Before trusting any backtest, answer two questions about the data behind it: does it include the names that were later delisted, and is every signal strictly lagged so no bar trades on its own future. If you cannot answer both with a clear yes, the performance number is not yet meaningful. The mechanics of doing this correctly are covered in the companion piece on pandas backtesting for Indian equities.

Stage three: the backtest, and the overfitting trap

A backtest replays the strategy over historical data and reports what it would have done. Its danger is that it is trivially easy to make one look good and much harder to make one that means something. The core hazard is overfitting: tuning parameters so tightly to the historical sample that the strategy captures noise rather than a repeatable effect. If you try a hundred parameter combinations and keep the best, you have not found an edge, you have found the arrangement that best fits the random detail of one particular past. The tell is a strategy that is beautiful in-sample and falls apart the moment it meets data it was not fitted on.

The overfitting gap: in-sample brilliance versus out-of-sample decay An illustrative pair of equity curves. During the in-sample period the overfitted strategy climbs smoothly and the honest strategy climbs modestly. After the out-of-sample boundary the overfitted curve rolls over and declines while the honest curve keeps rising gently. The widening distance is the overfitting gap. Values are illustrative, not results. Why a great backtest can be worthless Illustrative equity curves, not results equity out-of-sample begins in-sample (fitted here) out-of-sample (unseen) overfitted: decays on unseen data honest edge: holds the gap Only the behaviour to the right of the boundary, on data the strategy never saw, tells you anything real.
Judge a strategy only on data it never saw. The overfitted curve is fitted to the left of the boundary and rolls over the instant it crosses into unseen data. The honest edge is unremarkable in-sample and roughly as unremarkable out-of-sample, which is exactly what a real, if modest, effect looks like. The out-of-sample segment is the only part worth reading.

The defences are structural, not clever. Hold out a segment of data the strategy never touches during design, and judge it only there. Use walk-forward testing, where you repeatedly fit on one window and test on the next unseen window, so the strategy is validated across many out-of-sample slices rather than one. Keep an honest count of how many variations you tried, because testing fifty ideas and reporting the best is a statistical certainty of finding a flatterer. And treat a strategy with dozens of tunable parameters with suspicion: the more knobs, the more room to fit noise. These traps, and how they present in Indian data specifically, are the subject of the companion article on backtesting mistakes retail traders make.

Stage four: costs turn many "winners" into losers

A backtest with no transaction costs is not a backtest, it is a daydream. Every real trade in India pays a stack of frictions, and for an active, high-turnover strategy that stack is often the difference between a positive and a negative expectancy. The components are not exotic, but they are cumulative, and they scale with how often you trade.

The friction stack on a round-trip trade, and why turnover matters (illustrative structure, verify current rates before use)
Cost componentRoughly what it scales withEffect on a high-turnover algo
BrokeragePer order, flat or percentageMultiplies directly with trade count
Securities transaction taxPercentage of turnoverHeavier on frequent trading
Exchange and clearing feesPercentage of turnoverSmall per trade, large in aggregate
Stamp duty, SEBI and GST chargesPercentage or per orderAdds a further layer each round trip
SlippageOrder size versus liquidityThe hidden cost most backtests ignore

The last row is the one that catches people. Slippage is the gap between the price your signal saw and the price your order actually filled at, and it does not appear in a naive backtest at all, because such a backtest assumes you transact at the historical price for free. In a fast or thin market the fill can be materially worse, and a strategy that trades often pays that toll on every leg. The practical rule is to build the full cost stack into the backtest from the first run, not to bolt it on later, because a strategy that only survives at zero cost was never viable. The mechanics of the Indian friction stack are broken down in the companion guide on the real cost of an Indian trade.

Stage five: paper and forward testing before capital

A strategy that has passed an honest in-sample backtest and an out-of-sample check has still only ever been evaluated against recorded history. It has never met the live market, and the live market introduces frictions no historical file contains: the feed arrives with latency, orders take time to route and fill, the price moves between the signal and the execution, and the system has to run unattended without you nursing it. Forward testing, also called paper trading, runs the full system on live data with simulated or tiny orders, so all of that surfaces while nothing is at risk.

Treat the forward-test phase as a dress rehearsal for the whole machine, not just the strategy. It is where you discover that your session token expires and the reconnect logic was never exercised, that the feed drops for ninety seconds during a volatile open, that a corporate action is handled differently live than in your file. Only after the system has run cleanly forward, with the execution and operational layers behaving, does graduating to real capital, and then in small size first, make sense. The progression from a rehearsed system to live money is exactly the terrain of the companion guide on moving from paper trading to live capital.

Stage six: execution, and the SEBI compliance gate

Execution is where your code meets a broker API to place, modify, and cancel real orders, and in India this is no longer a purely technical step. It is governed by SEBI's framework for safer participation of retail investors in algorithmic trading, set out in a circular dated 4 February 2025. This is the scoop that dates every generic "how to algo trade" article that omits it, and it changes what you are allowed to run and how.

The mechanics matter, so state them precisely. Retail orders placed through a broker API above a specified order-frequency threshold, reported in the implementation standards as of the order of ten orders per second per exchange per client, are treated as algo orders. Those orders must be registered and tagged to the exchange with a unique algo ID, so the exchange has an audit trail of automated activity. The broker acts as the principal for API-based algo access and must onboard and empanel any algo or API provider as its agent. API access itself is hardened: static IP whitelisting, client-specific and vendor-specific keys, and strong authentication such as two-factor, with open or freely connectable APIs curbed in favour of routes controlled by the broker. Finally, the framework draws a white-box versus black-box line, and it registers where the risk sits.

How a retail API order is classified and tagged under the SEBI framework A retail API order meets a decision on order frequency. Below the specified threshold, of the order of ten orders per second per exchange per client, it is treated as an ordinary API order. Above the threshold it is an algo order, tagged with a unique algo ID through the broker acting as principal and registered with the exchange, which holds the audit trail. The SEBI gate: when an API order becomes an algo Retail API order placed via a broker API Order rate over threshold? approx. 10 orders / sec / exchange No Ordinary API order, not tagged Yes Treated as algo order Broker tags unique algo ID Registered with the exchange, audit trail
Frequency, not intent, is the trigger. The classification hinges on the order rate: below the exchange-specified threshold an API route is ordinary access, above it the same route is algo and must carry an exchange algo ID assigned through the broker. The broker is the principal onboarding the provider, and the exchange holds the audit trail. The threshold is set by the exchanges and can be revised.

The white-box versus black-box distinction is the part that decides how much scrutiny falls on you. A white-box, or execution, algo is one whose logic is fully disclosed to the user, who can see the rules and reproduce them. If you write and understand your own strategy, you are running a white-box algo on your own account, and the burden is the tagging and the hardened API route. A black-box algo is one whose logic is proprietary and hidden from the user, and here the framework loads heavier expectations onto the provider, including registration expectations such as registration as a research analyst and periodic disclosure. In plain terms, opaque strategy sellers face a higher bar than a trader automating their own transparent rules.

White-box versus black-box under the SEBI framework
DimensionWhite-box (execution) algoBlack-box (non-disclosed) algo
Logic visibilityFully disclosed to the user; rules are seen and reproducibleProprietary; internal logic hidden from the user
Typical operatorA trader automating their own transparent rulesA third party selling a strategy as a product
Registration weightLighter; the focus is tagging and a hardened API routeHeavier; registration expectations, including as a research analyst
DisclosureYou already know the logic you builtPeriodic disclosure expectations on the provider
Dates that have moved. The framework was set out on 4 February 2025 and then phased, with the timeline extended more than once through 2025, including an operational readiness window over August 2025, and an extended go-live reported as 1 April 2026 after the September 2025 extension. Because these dates were revised repeatedly and the order-frequency threshold is set by the exchanges, confirm the current effective date and the exact threshold with the exchange or your broker before you build to them. This guide names named brokers nowhere on purpose; choosing one is a separate exercise.

Stage seven: the risk layer and the kill-switch

An automated system's great danger is its speed. A human trader who makes a mistake can usually stop after one bad order; an algorithm with a logic error, a stale feed, or a runaway loop can send many wrong orders before anyone notices, and in an unattended system nobody is watching in real time. The risk layer exists to bound that failure, and its sharpest instrument is the kill-switch: a set of pre-committed rules that halt the algo, and where required flatten open positions, the instant a limit is breached.

The limits are decided in writing before the account is live, and they trigger automatically, without discretion, because discretion in the moment is precisely what fails under stress. Sensible triggers include a maximum daily loss, a hard cap on position size or aggregate exposure, a data-feed disconnect, and an order-rejection or error storm that signals the system has lost its footing. The operational corollary is that live execution belongs on an always-on host, not a laptop that sleeps and drops connectivity, with reconnect logic for the feed, session and token management for the broker API, and monitoring of the handful of metrics that reveal the system's health: whether data is arriving, how many orders are open, current exposure, and the connection status. You do not talk yourself out of a kill-switch once it has fired. That pre-commitment is the whole point.

Where retail algos actually blow up. Not on exotic strategy risk, but on plumbing. An unhandled token expiry that silently kills authentication mid-session; a dropped feed with no reconnect logic, so the strategy trades on stale prices it believes are live; a missing kill-switch, so a single bug keeps firing until margin is gone; and an oversized first live deployment that turns a routine adverse move into a rule-breaking loss. Every one of these is an engineering failure, not a market call.

What the failure data is really telling you

It is worth grounding all of this in the outcomes. A SEBI study released in July 2025 found that 91 percent of individual traders in the equity-derivatives segment lost money in FY25, with aggregate net losses of about 1,05,603 crore rupees. That figure is not a verdict on automation specifically, and automation is not the cause of it. But it is the backdrop against which any "start algo trading" pitch has to be read, because it says plainly that the median outcome in fast, leveraged trading is a loss, and that adding a computer to a strategy without an edge, without honest validation, and without cost accounting simply loses money faster and more consistently. Automation is a force multiplier. It multiplies whatever is already there, including a negative expectancy.

The correct reading of the pipeline, then, is defensive. The reason to insist on clean data, out-of-sample validation, a full cost model, a forward test, a hardened compliant execution route, and an automatic kill-switch is not bureaucratic thoroughness. It is that each stage is a place where the majority quietly fail, and passing all of them is what separates a system with a chance from one of the statistics. If you want the structured version of that path, from the research layer through to production architecture and the deployment playbook, that is the terrain the curriculum sequencing below is built to cover, in order, so that the compliance and risk layers are learned as first-class stages rather than afterthoughts.

Build the pipeline in the right order

Bharath Shiksha is a 30-volume curriculum across 6 stages, from chart reading (Stage 1 at ₹14,999) through the systems and capital stages that cover research, backtesting, execution architecture, and the risk and compliance layer, up to the full bundle at ₹1,49,999. Every volume ships with a companion worksheet and a gate quiz, and a 7-day money-back guarantee.

Take the free diagnostic →

Frequently asked questions

Start with a written strategy hypothesis, not with code. Then assemble clean historical data, backtest the idea honestly with realistic costs, forward-test it on paper on live data, and only then wire it to a broker API for execution behind a risk and kill-switch layer with monitoring. In parallel, meet the compliance gate: under the SEBI framework, retail API orders above a specified order-frequency threshold are treated as algo and must be tagged with an exchange-assigned algo ID through your broker. Coding is one link in that chain, and rarely the one that decides the outcome.

Under the SEBI circular dated 4 February 2025 on safer participation of retail investors in algorithmic trading, retail orders placed through a broker API above a specified order-frequency threshold are treated as algo orders and must be registered and tagged with the exchange through a unique algo ID. Your broker is the principal that onboards and empanels the algo or API provider as its agent. You do not personally register as an intermediary to automate your own account, but the algorithm and the API route are subject to broker onboarding and exchange approval. The framework was phased, with an extended go-live of 1 April 2026.

A white-box or execution algo is one whose logic is fully disclosed to the user, who can see the decision rules and reproduce them. A black-box algo is one whose internal logic is proprietary and not disclosed to the user. Under the SEBI framework the distinction matters because opaque, non-disclosed strategy providers face heavier registration expectations, including registration as a research analyst, and periodic disclosure. If you write and understand your own rules, you are operating a white-box algo on your own account.

Most retail algo effort fails on data quality, overfitting, and cost, not on the code. Free or survivorship-biased data flatters a backtest by hiding the names that were delisted. Testing many parameter combinations and keeping the best fits the strategy to noise, so it looks excellent in-sample and decays out-of-sample. And backtests run without brokerage, exchange fees, taxes, and slippage report a profit the live account never sees. A strategy that survives honest data, out-of-sample validation, and full costs is rare, and that survival, not the automation, is the hard part.

Overfitting is when a strategy is tuned so tightly to the historical sample that it captures noise rather than a repeatable effect, so its measured edge does not persist. You detect it by holding out data the strategy never saw during design and comparing performance in-sample versus out-of-sample. A large gap, where the equity curve is smooth in-sample and ragged or negative out-of-sample, is the signature. Walk-forward testing, where you repeatedly fit on a window and test on the next unseen window, and counting how many parameter combinations you tried, both help expose it.

A kill-switch is a pre-committed rule that halts the algo and, where required, flattens open positions when a limit is breached: a maximum daily loss, a position or exposure cap, a data-feed disconnect, or an order-rejection storm. You need one because an automated system can send wrong orders far faster than a human can intervene, and a single unhandled bug or a stale feed can compound losses in seconds. The switch is defined in writing before the account goes live, it triggers automatically, and it is not overridden in the moment.

Enough clean history to cover more than one market regime, including at least one meaningful drawdown, and data that includes names that were later delisted so the sample is not survivorship-biased. Beyond the in-sample backtest you need an out-of-sample test on data untouched during design, and then a forward or paper-trading phase on live data so execution, latency, and the difference between the signal price and the fill price are exposed before money is at risk. There is no fixed number of days, but a strategy that has only ever been fit, and never validated forward, is not ready.

A laptop is fine for research and backtesting but not for live execution, because it sleeps, drops connectivity, and updates itself mid-session. Live algos run on an always-on host with a stable connection, session and token management for the broker API, reconnect logic for the streaming feed, monitoring of the key operational metrics, and alerting. Under the SEBI framework the API route is also hardened, with static IP whitelisting, client-specific and vendor-specific keys, and strong authentication such as two-factor, so the infrastructure has to satisfy the broker's onboarding requirements too.

Under the implementation standards for the SEBI framework, an order route is treated as algo when its order rate exceeds a specified threshold set by the exchanges, reported as ten orders per second per exchange per client. Below that threshold an API is treated as ordinary automated access; above it, the orders must be tagged as algo with a unique exchange-assigned algo ID through the broker so the exchange has an audit trail. The threshold is set by the exchanges and can be revised, so the current figure should be confirmed with the exchange or the broker.

Where the facts come from

  • SEBI, safer participation of retail investors in algorithmic trading. Circular dated 4 February 2025 establishing the retail algo framework: broker as principal, algo or API provider as agent, unique algo ID tagging of API orders above the specified frequency threshold, hardened API access, and the white-box versus black-box distinction. sebi.gov.in
  • SEBI, extension of the implementation timeline. Circular dated September 2025 extending the timeline for implementing the 4 February 2025 retail algo circular; the go-live was reported as moving to 1 April 2026 after a phased schedule through 2025. Confirm the current effective date directly. sebi.gov.in
  • Order-frequency threshold. The implementation standards for the framework set the threshold above which an API route is treated as algo, reported as of the order of ten orders per second per exchange per client. The threshold is set by the exchanges and can be revised, so verify it with the exchange or your broker.
  • SEBI study on individual trader outcomes, July 2025. Found that 91 percent of individual traders in the equity-derivatives segment lost money in FY25, with aggregate net losses of about 1,05,603 crore rupees. Cited here as the outcome backdrop for retail participation, not as a claim about any strategy.
Educational note. This guide explains the process and the regulatory framework for starting algorithmic trading in India. It is not a recommendation to trade or invest, and it is not investment advice. Historical backtesting does not predict future results, and algorithmic trading involves a material risk of loss. Bharath Shiksha is an educational publisher, not a SEBI-registered investment adviser or research analyst.

Related guides