No slippage model | Not working

Hi Team,



I am writing to understand the no slippage model.

Please see my attached image which briefs the doubt that i have.



Screenshot 2022 02 07 at 3 05 53 PM — Postimages





In the initialize function I am setting the slippage to NoSlippage but the order is still executed at a different price.

 

def initialize(self, context):
context.set_slippage(slippage.NoSlippage())
set_slippage(slippage.NoSlippage())


 

Can you please explain a bit more what you mean by "still executed at different price"? What are the prices you are comparing? If you are placing an order at time t, it can be executed only at time t+1minute (or later). NoSlippage will simulate the fill (subject to volume limits) at the then present close price. If you are comparing your entry price at t to the execution price (which is at t+1min) that is not correct. If you are seeing difference comparing the t+1min close to the execution price, please share a minimal version of your strategy code that can reproduce the result to the email "blueshift-support@quantinsti.com"

in fact in your case, the pipeline API is evaluated on last day's close. So you have t+1day delay before the trade is executed. If you are calculating the entry at 105 and entering it at the same bar (same price), that introduces a subtle look-ahead bias. Blueshift will always execute at the next available bar. Setting NoSlippage just ensures no deviation of the execution price from the close price at the bar the trade is executed.

Okay now I understand…

Hi Prodipta



Lets take an example. This is on a daily timeframe.



Day 1 : When the SMA Cross Over happens on a closing basis.

Day 2 : When the Crossover is shown on the  data, Trigger the order on close price

Day 3: Order is executed, But on a close price of day 3



Now my question is, the order should have been executed on the closing price of Day 2. It is now executing the order on the close price of Day 3.



I was thinking of an instant slippage model, where the order is executed on the closing price of day 2

Actually, this is what happens:

  1. day2, time t1: compute the SMA based on up till day 1 close prices, cross-over happens. (time t1 is when you run your pipeline output function)
  2. day2 time t2: place the order (in most cases time t1 == t2, but depends on your specific strategy)
  3. day2 time t2+1min: the first time the order is eligible to execute, gets executed partially or fully
  4. day2 close: the unfilled part (if any) gets cancelled (unless your order validity is GTC).



    It does not get into day3 at all. Given the above, if you are still not clear on the model, can you pelase re-phrase your question? And provide a code sample to replicate if applicable.