Backtesting is the process of applying a set of rules to historical data with the goal of assessing the strategy's effectiveness in generating profit.
Streak has the most powerful backtesting engine in the world that generates performance metrics for multiple stocks in a single click.
The backtest results include pnl curve, maximum gains/losses, average gain per winning trade, average loss per losing trade, maximum drawdown and much more. These metrics give you a comprehensive idea of your algo’s performance before you deploy in the market.
After you create an algo and click on run backtest, the algos starts checking for all the signals that got generated during the selected time period.
The backtest page allows users to adjust and modify various input parameters which are used to run a backtest.
- Initial capital represents the hypothetical maximum capital allocated for the backtest of each equity/futures contract. This capital does not represent any capital held by the user and is for backtest purposes only. Initial capital acts as the maximum capital that will be used by the algo during a backtest to perform hypothetical trades.
- Quantity represents the trading quantity to be used by the algo. Quantity is a positive integer with defined absolute position size of an order, using which the algo performs hypothetical trades during the backtest. After the backtest is run with a quantity, the same quantity value is used when the algo is deployed.
- Stop loss percentage is the value used to calculate the stop loss price once the hypothetical entry position has been taken. An exit trigger is generated if the price hits/crosses the calculated stop loss price and the positions will be hypothetically exited at the close price of the subsequent candle.
- Target profit percentage is the value used by algo to calculate the target profit price once the hypothetical entry position has been taken. An exit trigger is generated if the price hits/crosses the calculated target profit price and the positions will be hypothetically exited at the close price of the subsequent candle.
- Order type can be MIS or CNC/NRML and represents the order type used to place hypothetical orders in a backtest. MIS is used for intra day margin trading, where the order will get squared off during the market close. CNC/NRML is used for overnight trading, where the stock/contract is held after the market closes and can be carried forward to the next day. If CNC/NRML has been selected as the order type, CNC will be used as the order type for equities and NRML for futures contracts based on the tick symbol and instrument segment.
- Candle Interval is defined as the time frame of each candle. All backtest calculations are made using the close price of the selected candle interval.
- Backtest period is the look back period to perform a backtest and is defined by selecting the start and stop date for the backtest. Backtest period can be modified to re-run backtests i.e users can change the start and end date of the backtest period but the period range is limited based on the candle interval.
- For 1 min candle interval, the maximum backtest period is 30 days from the start date. If the start date for the backtest is selected to be 1st Jan 2019, the allowed end date for the backtest would be till 30th Jan 2019.
- For 3-30 min candle interval, the maximum backtest period is 90 days from the start date. If the start date for the backtest is selected to be 1st Jan 2019, the allowed end date for the backtest would be till 31st March 2019.
- For an hour candle interval, the maximum backtest period is 365 days. If the start date for the backtest is selected to be 1st Jan 2018, the maximum allowed end date for the backtest would be till 31st Dec 2018.
- For a day candle interval, the maximum backtest period is five years. If the start date for the backtest is selected to be 1st Jan 2014, the allowed end date for the backtest would be till 1st Jan 2019.
- These limits are subject to change based on the availability of data. The backtest period and the data fetched is also subjected to technical limitations such as bandwidth, data availability, server load and various or technical implications.
- Equities/Future contracts can be added/removed on the backtest page. Backtests are run individually for every equity/contract that has been added and therefore the backtest counter is updated to reflect this.
If 5 equities have been added and backtest is run, the counter will be updated as 5 backtests run. If no new equities/contracts have been added and backtest is run, the backtests are re-run on all the equities/contracts irrespective of its previous status. Every time you change a parameter mentioned above and run backtest, the backtest count reduces
On clicking the "Run Backtest" button, a fresh backtest is run for each equity/contract by first fetching all the appropriate historical market data for the respective stock/contract and initializing all the user defined parameters. The historical market data is then processed to generate hypothetical trade signals and hypothetical trades are performed using the hypothetical initial capital.
Based on these hypothetical trades, certain performance metrics such as hypothetical profit/loss, winning streak, losing streak etc. are generated in an effort to provide a generalized and simplified understanding of the algo’s hypothetical returns and risk. All the hypothetical trades generated are shown in the transactions table along with profit/loss and portfolio values during every trade.
Backtest P&L : The cumulative P&L realized after taking all the trades generated through the algo.
Wins vs Losses : Displays the number of trades that ended up being profitable and the ones that weren’t. This important piece of information can help you decide whether your Risk/Reward ratio based on stoploss/profit-target & average loss/losing trade v/s average gain/winnig trade is favorable or not.
Winning Streak (WS): The highest number of subsequent winning trades, one after another.
Losing Streak (LS): The highest number of subsequent losing trades, one after another.
Max Drawdown (Max DD): Max drawdown measures the largest decline in the P&L curve at any given point of time.
More on Maximum drawdown¶
Maximum drawdown (Max DD) is the maximum loss from the peak (highest point) to a trough (lowest point) of a PnL chart, before a new peak is attained. It signifies downside risk and is calculated by measuring the highest fall (largest loss) in over a specified time period.
It is important to note that Max DD only measures the size of the largest loss among all the loss during a period. It does not consider the frequency of losses.
A max dd of 0.97 is better than 1.53. Similarly, a max dd of -0.12 is better than -0.93. The lower the value, the better. It should ideally as close to 0 as possible. If a strategy never made a loss making trade, the Max DD would be zero.
Streak's backtest result also allow user to see the trade details (entry/exit) based on which the backtest PnL and other metrics are calculated. You can find these specific entry and exit date and time by clicking on "Transaction Details".
Transaction details will list the date and time of entry along with the entry price followed by the date and time of exit and also the profit or loss on the transaction.
- EN - Entry
- SL - Stop Loss
- TP - Target Profit
- SO - Square off
- EX - Exit condition
We account for all the deductions as per brokerage calculator on your broker's website. Brokerage charges include broker's brokerage, STT, transaction charges, GST and SEBI charges.
Every contract note requires to be stamped as per regulations of the respective state government. The charges vary based on state of residence provided on correspondence address proof when opening an account. Stamp duty is not taken into account while calculating brokerage.
Backtest edit parameters¶
Provides a quick access to the backtest parameters. You can change most of the conditions including chart type, candle interval, SL & TP percentage.
You can view the strategy summary on the top of the backtest page.
Algos can be modified from backtest page also by clicking on algo name then clicking
Edit in the strategy summary section.
Backtest error messages¶
During a backtest, if any error occurs/proper results are not be generated, we try to show an appropriate message to help the user adjust the input parameters and run the backtest again. These error messages are explained below:
- No trades happened - This means that no hypothetical entry signals were generated for the algo and no hypothetical trades were performed for the backtest period selected by the user. This could mean that the algo conditions were never met in the specified backtest period or that the conditions were syntactically/logically incorrect or were not expressed properly with the right indicator parameters.
- No trades happened because initial capital is low - This means that the algo conditions were met and trading signals were generated but due to insufficient hypothetical initial capital, hypothetical trades were not generated. It can be resolved by increasing the hypothetical initial capital or by decreasing the quantity and running the backtest again.
- Limit Exceeded - This means while running backtest you have reached your daily maximum allowed backtest limit. This limit may vary depending on your subscription plan.
- Error while fetching data - This means that an internal error occurred while fetching historical data. It can be resolved by waiting for a few minutes and running the backtest again. If the backtest counter gets decreased, you can write to us and we will allow few additional backtests.
- Server timed out - This means that the user's browser is not able to connect to Streak servers due to internet connection error. It can be resolved by checking the internet connection and running the backtest again.
Backtesting on Streak: Backtesting on Streak allows users to measure the hypothetical performance or returns of an algo. All backtest results are a hypothetical representation of the performance and returns on an algo, based on certain underlying assumptions. These results do not provide any guarantee of future performance or returns, and all algos are subjected to market risks.
The Deploy function allows users to take their strategy live in the stock market and get actionable alerts based on the entry and exit conditions in their strategy.
Once you deploy an algo on Streak, you no longer have to track the trade manually. Streak tracks the price movements for trade signals and will send one click actionable alerts when all the conditions specified in a strategy are met in real-time.
The deploy button is greyed out when no algos are selected on backtest or algos page. Once you select any algo by clicking on the checkbox the deploy button turns Blue. This means you have selected one or more scrips and you are ready to deploy.
On clicking the "Deploy" button on either Backtest or Algos page, a popup is rendered with a summary of the user's algo with the entry condition, exit condition and candle interval.
Live Trading: Sends an actionable entry/exit notification once the strategy conditions are met
Paper Trading: Deploying your strategies in Paper-Trading mode allows user to check the performance of the strategy without risking any actual capital. This simulates trades in the live stock market, where you can track real-time positions based on virtual trades.
When a strategy is deployed as Paper trading, notifications are not sent, when conditions are met.
Strategy live for¶
MIS positions are squared off and strategies are stopped after market close. This option allows user to deploy strategies for multiple trading session by deploying it once. If you select "3 Day", the strategy will be redeployed automatically by the system in the morning before market open, for the current day and the next two days. Applicable only for MIS deployments.
Strategy Cycle defines the loop of the algo i.e entry followed by respective exit. The user should also select the field "Strategy cycle", which determines the cycles for which the algo will be live.
If "MIS" is selected, the order type will be intraday and the algo will be live for that single day. If the user selects "CNC/NRML", the order type will be CNC for equities and NRML for future contracts and the algo will be live for the next 30 days (or until the algo is stopped by the user or terminated due to some reason such as order rejection or user subscription expires).
You can either use Regular order or Bracket Order (BO).
When Opening Range indicator is used and the duration as lets say 15 mins is to be used, the candle interval always needs to be equal or lower. If you want to set Opening Range(High, 15 min), the candle interval needs to be equal to or lower than 15. If the candle interval is higher, the time frame will not be present in the dropdown.
During a backtest, hypothetical trades are generated with the following high level assumptions:
- During a backtest, irrespective of the order type, no margins is assumed for any instrument. The user must enter the desired initial capital value such that it is higher than the product of quantity and the instruments close price [Initial Capital >= (Quantity x Close Price) for all instruments being tested].
- During a backtest, any hypothetical signal to buy or sell is executed on the open price of the next candle irrespective of the actual volumes traded for that candle in the historical data.
- During a backtest, no form of averaging is done i.e., the algo does not take multiple consecutive entry positions before exiting the current position (entry position is taken only after the previous position has been exited i.e., when quantity at hand is zero).
- During a backtest, the strategy will only exit a position, when either the exit condition is met or when target profit price or stop loss price is hit.
- During a backtest, there is no context nor is any consideration given to corporate actions such as stock splits, rights issues etc. and no adjustments are made to stock/contract prices. The values OHLCV (Open , High, Low, Close and Volume) are taken directly as present in the historical candle data.
- During a backtest, a hypothetical buy signal is generated only if the condition is false in the previous candle and is true in the current candle.
- During a backtest, the profit/loss are calculated on the TP SL % and the PNL chart values are calculated on the Close price of every candle when a position is held, not only on buy/sell.
- During a backtest, if the order type is MIS, all open positions are hypothetically squared off at the open price of the 3:15 pm candle (for equity) 4:30 (for currency). This is done to simulate a square offs done by the brokers for MIS orders.
- Chart data is subjected to minor variations from market time to post market times due to standard data adjustments.
Disclaimer: The results of all the backtest are hypothetical and does not guarantee or portray in any form or manner any future performance or returns. Historical data is subject to limitations like rounding off, memory buffer limits, user's browser, system limitation, data availability, accurate data etc ↩