A Python algo sends every order through risk checks and the broker API
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