# Slippage Modelling during Backtesting and Paper Trading in Algorum.

Slippage is the most important factor that effects the profit & loss of your strategy, if your strategy depends on Market orders. When you place a Market order, there are two factors that affect slippage, Time (Latency) and Market Depth. Take an example scenario where your strategy determines that it is time to place an order, where the stock that you are monitoring is at a price 20. Now when you place an order, the order might reach the stock exchange (NSE for India, and others like NASDAQ, NYSE, Market Venues for USA) within a second. Within this second, the price might have changed from to 21 or 19. If you are on BUY side, and if the price has changed to 21, this means you would have bought the stock at a higher price than desired. And if the price has changed to 19, this means you would have bought the stock at lesser price than desired. But in all probability you would end up buying stock at 21 price (greater price), as the ASK side of the market (sellers) always quotes prices higher than the current stock price. And in Market order scenario your BUY order will be filled from the ASK side of the Market.

Algorum provides two slippage models to try and simulate the Slippage in your backtesting, so you can understand the effect of slippage in your strategy.

### Basis Points Slippage (BPS) Model

In BPS model, you can specify number of basis points your order price would be moving away from when you are placing a Market order. When you are placing a BUY order, the current tick price of your stock symbol will be increased by the specified basis points. When you are placing a SELL order, the current tick price of your stock symbol will be decreased by the specified basis points. This will reduce your profit, but is helpful to understand how your strategy P&L is effected in a slippage scenario.

### Time Slippage Model

In Time slippage model, you can specify a delay in milliseconds, where this delay is used to get the next closest tick for your symbol. So if you placed order at 9.15 AM 30 Seconds, and specify a Time slippage of 1000 milliseconds, Algorum will fill your order with stock price at 9.15 AM 31 Seconds, from the historic data. This will essentially simulate the time delay between your strategy identifying the price to place an order and the actual time at which the order is sent to the stock exchange for filling. This may result in increase or decrease of profit based on whether the price has increased or decreased after the slippage time.

### Specifying Slippage while placing an order

You can specify the slippage type (SlippageType (Enumeration)) and slippage value while placing the order in the PlaceOrderRequest object, as shown below.

``````
var placeOrderRequest = new PlaceOrderRequest()
{
OrderType = OrderType.Market,
Price = tickData.LTP,
Quantity = qty,
Symbol = _symbol,
Timestamp = tickData.Timestamp,