A backtesting engine that never trades on a price it has seen
Veloce replays one-minute market history bar by bar. Strategies decide on closed candles, orders fill at the next candle’s open, and every fill pays slippage and itemised Indian charges. This page explains each of those rules and where it lives in the engine.
An algo trading harness around your strategy
In software, a test harness runs your code against controlled inputs and records what it does. Veloce does the same for a trading strategy: the strategy plugs in, and the harness supplies the market data, contracts, fills, costs, exits, risk limits, portfolio and report, the same way on every run.
Market data
One-minute bars, checked as they arrive and resampled to your candle.
flux.dataExpiries and contracts
Expiry calendars with holidays, and strikes picked from the closed candle.
flux.optionsFills
Every order fills at the next bar’s open, never on a price already seen.
flux.executionCosts
Brokerage, STT or CTT, exchange and SEBI fees, stamp duty, GST and slippage.
flux.trading.charges
Exits
Stops, targets, trails and exits before expiry, checked on every bar.
flux.trading.exitsRisk limits
Lot caps, cash, futures margin, loss at expiry and daily limits.
flux.trading.riskPortfolio
Positions in units, cash, cost basis and equity, in exact decimals.
flux.domain.portfolioReports and runs
Calendar, equity, breakdowns and trades, with every run stored.
flux.api.runs
Plugs in
Your strategy
Reads closed candles and returns the position it wants, in signed lots. It never places an order or touches cash.
- A shipped strategy
- Your own indicator rules
- A strategy spec, written as data
Backtests today. Paper and live trading are coming soon.
Five steps, in the same order, on every bar
1
Bars for one moment
The engine takes every bar that starts at the same moment: the underlying and each contract the strategy has picked so far.
BacktestEngine2
Broker fills first
Options past expiry settle. Orders waiting on a contract fill at its bar’s open, with slippage and charges, and the portfolio updates.
SimulatedBroker.on_bar3
Strategy decides
Only then does the strategy see the closed bars. It returns target positions in signed lots, never orders.
Strategy.on_bar4
Stages review
Exit-by time, daily target and stop, skipped days, exit rules and risk limits each adjust the targets in turn.
TargetStage5
Orders wait
The difference between each target and what is already ordered becomes an order, which waits for the next bar.
OrderExecutor.submit
Instruments join as the strategy picks them
A backtest starts with the underlying alone: NIFTY 50, BANK NIFTY, SENSEX, or the gold future being traded. An option strategy then picks contracts as it goes, through the option chain: the at-the-money strike from the closed candle’s price, a set number of strikes away, on the nearest expiry. The engine adds each new contract to the replay from that bar on.
Before a contract can be ordered it needs a price for the risk checks. The engine looks back over the last hour, or one candle if that is longer, and takes the close of the last bar that had closed. If the contract did not trade in that window, the backtest stops and says so, instead of inventing a price.
Strategies return positions, not orders
A strategy says what it wants to hold: minus one lot of the 24000 put, plus one lot of the 23800 put. It never says buy or sell. Stages then review those targets against an account snapshot that already counts orders still waiting to fill, and the engine sends only the difference between the reviewed target and what is ordered.
The portfolio keeps positions in units, lots times the lot size at the time of the fill, so an exchange revising a lot size cannot change a position that is already open.
Decide on the close, fill at the next open
GOLDM future, one-minute candles
DecisionFill price
- The candle closesA candle labelled 10:14 covers 10:14:00 to 10:15:00. Its close is known only at 10:15:00, so that is when the strategy sees it.
- Targets go through reviewExit rules and risk limits adjust the strategy’s targets against the account, and only the difference becomes an order.
- The next candle fills itThe simulated broker fills at the open of the contract’s next candle, the first price after the decision, before the strategy sees that candle.
Illustrative prices.
Slippage, in ticks
Fills then move against you by the number of ticks you set, one by default. A buy pays more and a sell receives less. The result is rounded to the contract’s tick, up for buys and down for sells, and a sell never fills below one tick.
A tick is ₹0.05 on NIFTY, BANK NIFTY and SENSEX options and ₹1 on gold futures. Set slippage to zero to see what the strategy would make with perfect fills, then compare.
| Order | Next open | Slippage | Fill |
|---|---|---|---|
| Buy NIFTY call | ₹120.00 | +₹0.05 | ₹120.05 |
| Sell NIFTY call | ₹150.00 | −₹0.05 | ₹149.95 |
| Sell a ₹0.05 option | ₹0.05 | −₹0.05 | ₹0.05 |
| Buy GOLDM future | ₹1,21,450 | +₹1 | ₹1,21,451 |
Six rules that keep the future out of the past
- Rule 1
Bars are labelled by their open
Every bar carries the time it starts. The strategy sees it at start plus interval, the moment it closes, and not before.
- Rule 2
The broker sees each moment first
All bars that start at the same moment go to the simulated broker before any reaches the strategy, so pending orders fill on prices the strategy has not seen.
- Rule 3
Contracts are priced from closed bars
When a strategy picks a contract mid-run, its first price is the close of its last bar that had already closed, looking back at least an hour.
- Rule 4
Only the difference is ordered
The engine compares each target with what is already ordered and sends the difference. Targets that change nothing send nothing.
- Rule 5
Data is checked as it arrives
A bar out of order, at the wrong interval or outside the requested range stops the backtest with an error instead of being used.
- Rule 6
Signals stop before the closing auction
Since 3 August 2026, NIFTY index bars go flat from 15:15 and jump to the official close. Index-option signals ignore bars that close after 15:15.
The glossary defines lookahead bias and the other terms on this page, and the blog works through them with examples.
Larger candles, built from one-minute bars
Candles line up with the session: 09:15 for NSE and BSE, 09:00 for MCX. A 15-minute NIFTY candle covers 09:15 to 09:30, then 09:30 to 09:45, the way a trading terminal draws them. A one-hour candle covers 09:15 to 10:15.
The app offers 1, 3, 5, 15 and 30 minutes and 1 hour. Each strategy has a default: 1 minute for the iron condor and the hedged straddle, 3 minutes for the moving average and MACD buyers, 5 minutes for the rest.
| Field | Taken from |
|---|---|
| Start | The session open plus whole intervals |
| Open | The first one-minute bar |
| High and low | The highest high and lowest low of all of them |
| Close | The last one-minute bar |
| Volume | The sum |
Itemised charges on every fill
NSE and BSE index options
| Charge | Rate | On |
|---|---|---|
| Brokerage | ₹20 per order | Every order |
| Exchange transaction charge | 0.03503% of premium turnover | Buys and sells |
| SEBI turnover fee | 0.0001% of turnover (₹10 a crore) | Buys and sells |
| Securities transaction tax (STT) | 0.15% of premium turnover | Sells only |
| Stamp duty | 0.003% of turnover | Buys only |
| GST | 18% of brokerage, exchange and SEBI charges | Every order |
Turnover is premium times units. STT defaults to 0.15% and can be changed per backtest.
MCX gold futures
| Charge | Rate | On |
|---|---|---|
| Brokerage | ₹20 per order | Every order |
| Exchange transaction charge | 0.0021% of turnover | Buys and sells |
| SEBI turnover fee | 0.0001% of turnover (₹10 a crore) | Buys and sells |
| Commodity transaction tax (CTT) | 0.01% of turnover | Sells only |
| Stamp duty | 0.002% of turnover | Buys only |
| GST | 18% of brokerage, exchange and SEBI charges | Every order |
Turnover is the futures price times units, so a GOLDM lot at ₹1,21,450 is ₹12,14,500.
Buy NIFTY 24200 CE
1 lot of 65, filled at the next open
- Next candle’s open
- ₹120.00
- One tick of slippage
- +₹0.05
- Fill price
- ₹120.05
- Turnover
- ₹7,803.25
| BrokeragePer order | ₹20.00 |
|---|---|
| Exchange charge0.03503% | ₹2.73 |
| SEBI fee0.0001% | ₹0.01 |
| STTSells only | ₹0.00 |
| Stamp duty0.003% | ₹0.23 |
| GST18% of the first three | ₹4.09 |
| Charges on this fill | ₹27.07 |
Sell NIFTY 24200 CE
1 lot of 65, filled at the next open
- Next candle’s open
- ₹150.00
- One tick of slippage
- −₹0.05
- Fill price
- ₹149.95
- Turnover
- ₹9,746.75
| BrokeragePer order | ₹20.00 |
|---|---|
| Exchange charge0.03503% | ₹3.41 |
| SEBI fee0.0001% | ₹0.01 |
| STT0.15% | ₹14.62 |
| Stamp dutyBuys only | ₹0.00 |
| GST18% of the first three | ₹4.22 |
| Charges on this fill | ₹42.26 |
What the two fills cost
Bought at ₹120.05 and sold at ₹149.95, the round trip makes ₹1,943.50 gross. Charges take ₹69.33, and the two ticks of slippage already took ₹6.50 against the opens. Net: ₹1,874.17.
Rows are rounded to the paisa. Veloce keeps every amount exact, so a column of rounded rows can differ from the total by a paisa.
What each charge is, in the glossaryOptions held to expiry settle in cash
At the close of the derivatives session on expiry day, 15:30, or 15:40 for expiries from 3 August 2026, each open option closes at its intrinsic value: for a call, the index close minus the strike, and for a put, the strike minus the close, never below zero. Orders still waiting on an expired contract are dropped.
Settlement fills carry no charges in Veloce. In practice, exercised in-the-money options pay STT on their intrinsic value, so a strategy that holds to expiry will look slightly better than it would have done. No shipped option strategy holds to expiry by default: the iron condor and the credit spread exit a day before, and the rest square off at 15:15 each day.
Expiry dates come from a calendar per underlying, with holidays moved to the previous trading day. The NIFTY and BANK NIFTY page shows the calendar, including the move from Thursday to Tuesday expiries.
Common backtest shortcuts, and what Veloce does instead
| Shortcut | Veloce | Why it matters |
|---|---|---|
| Fill at the close of the signal candle | Fill at the open of the next candle, after the decision | The close is the price that produced the signal. No order placed after seeing it could have traded there. |
| Label candles by their close time and act at once | Label candles by their open and act only after start plus interval | A candle stamped 09:15 covers 09:15 to 09:20. Acting on it at 09:15 reads five minutes of the future. |
| Trade the index price for an options strategy | Trade the option contract, priced from its own one-minute bars | An index cannot be ordered. Option premiums move with time and volatility as well as spot. |
| Ignore charges, or take a flat percentage | Itemise brokerage, STT or CTT, exchange and SEBI fees, stamp duty and GST on each fill | Charges differ by side and product. STT is on option sells only; stamp duty is on buys only. |
| Assume fills at the quoted price | Move every fill against you by the ticks of slippage you set, one by default | Real orders cross a spread and move the market. Even one tick is a cost on every fill. |
| Use floating-point numbers for money | Use exact decimals for every price and amount, and reject floats | Floats round 0.1 + 0.2 to 0.30000000000000004. Over thousands of fills the errors add up. |
Where the bars come from
Option data arrives one trading day at a time and covers strikes around the money, up to ten either side on the nearest expiry and three on later ones. Each finished day is cached, so a second backtest over the same period downloads nothing.
The trading calendar is the days the index has a daily bar. That is how Veloce knows a day was a holiday, and why it refuses expiry dates beyond the last day it has data for rather than guessing.
Every price and amount is an exact decimal, and every timestamp carries its time zone. The engine rejects floating-point prices and times without a zone outright.
Backtest with fills you can trust
Create an account with a verified email and phone number, pick a strategy and a market, and see every fill, fee and day of P&L.