NIfty algo backtest


I am new algo trading and trying to build some algos. While backtesting they showed good results for nifty spot data, but extremely poor results for Nifty futures. This is across multiple years of historical data for both spot and F1 futures. Since in realworld situation the algo would be trading in Nifty futures, why do ppl rely on nifty spot backtested algos? Am i missing something? Or is it some fault with my algo design that the difference between spot and futures backtest performance is so weird?

If anyone from the community can share thoughts, would be helpful

@Streak Any thoughts?

I would first ensure the data source is a good one. Then I would check the tradelist of both backtest results to see whether there are wide entry exit price difference.

Are you backtesting in streak ?

Have you optimised the parameters ? If so one common pitfall is that you optimised it to a narrow peak of profitability which falls off drastically as parameters vary slightly. Nifty future and spot obviously while deeply correlated will have price differences and hence parameters optimised for peak performance on one may not work on the other.

I had backtested on nifty and tried forward testing on nifty F1, in addition to backtesting on nifty f1. I am sure data is good quality.
My algo is generating many small trades - I guess small differences (in spot and f1) in each trade add up such that annual performance has a huge gap.
I am not on streak yet - still developing knowledge/confidence to go full throttle on this :slight_smile:

When you say small trades what would be the average PNL in terms of points ?

Just a thought, NIFTY spot vs NIFTY Future can be running in “premium” or “discount” as per the market scenario in various points of time. You might have to find a way to factor that into your algo as well.

Spot > Future = Discount
Spot < Future = Premium

1 Like

Avg gain per trade could be as low as 1 pt and go upto 20 pts

Yes. But I am just referring to a single data series at a time either spot of F1.

That’s too low. You will loose on trade slippage that much in a jiffy. This also indicates that the system is over optimized and bound to fail in other instruments however correlated they are.

Hmm. ok. So what would you suggest the min gain per trade one should look at to avoid slippages?

Also, do you think slippage risk would be low for nifty f1? I am guessing they would have reasonably tight bid ask and good volumes to reduce slippage risk.

Slippage is not just about bid ask spread. The data you get on your chart is delayed by few seconds. Once you act on a signal by placing an order which then gets executed there is again a few second delay. So within that time frame a highly liquid instrument like nifty futures could move few points easily.

Besides data feeds do miss ticks in real time. So the 1 point game could be easily mis triggered.

For small profit, I am happy game you need to be on a collocated server with exchange. That’s your best chance.

Got it. Thanks.
One more query - would this issue be worse for nifty futures compared to any other stock (say a RIL, HDFC etc) ?

Yes. Also the transaction cost - brokerage, taxes etc need to be accounted for in addition to slippage.

Cross check the data you are using. Algorithms work on the inputs and data you provide. So, it’s best to cross verify the input parameters.