A Python algo sends every order through risk checks and the broker API

A Python algo sends every order through risk checks and the broker APIDiagram with 6 boxes. Price and order book data to Signal from a rule set fixed before testing; Signal from a rule set fixed before testing to Risk checks: loss limit, position limit, order rate; Risk checks: loss limit, position limit, order rate to Broker API: client key, static IP, two factor login; Broker API: client key, static IP, two factor login to Order tagged with the exchange identifier; Order tagged with the exchange identifier to Logs, kill switch and review.Price and order book dataSignal from a rule set fixedbefore testingRisk checks: loss limit,position limit, order rateBroker API: client key,static IP, two factor loginOrder tagged with theexchange identifierLogs, kill switch and review
The parts of a retail algo built on a broker API. A rule diagram with no market figures; the rules follow SEBI circulars of 4 Feb 2025 and 30 Sep 2025. Source: SEBI circulars on retail algo trading, Feb and Sep 2025. As of 16 Oct 2026.

An algo runs four jobs in a loop: it reads prices, turns them into a signal, checks the trade against risk limits, and sends the order. Python is often used for the first three because its data and testing tools are wide. The fourth step depends on the broker, because the order goes through the broker's API and the broker decides who may connect and from where.

The chart lists the parts in order. The API connection needs the client specific key, a whitelisted static IP and two factor login. Orders carry the exchange identifier, API sessions are logged out every day, and a high order rate can move a personal algo into the registered category. A risk check should sit between the signal and the order, with a loss limit, a position limit and a kill switch the program can trigger on its own.

Testing comes before any live order. Run the logic on dated historical data, and keep the test period apart from the period that shaped the rules. Then paper trade, and only then trade real money, at a size where a bad day can be survived. Keep a log of every order and every rejection, because the broker and the exchange can ask for them.

A backtest that looks good is not proof of profit. Costs, slippage and the way a rule was picked can all make a test look better than the live result. The backtesting question shows how a test should be set up before its result is read.

Before you trade. Derivatives trading carries a high risk of loss. SEBI's study "Profitability of Individual Traders in the Equity Derivatives Segment (FY25 to FY26)" (August 2026) found that 87.7% of individual traders in equity F&O made net losses in FY26, with aggregate net losses of Rs 91,685 crore. Read the SEBI study