Slippage #169
Slippage
#169
Replies: 1 comment
-
Hi @markxbaker, The RandomSlippageModel only applies slippage to the number of shares filled, not price. You can implement your own PriceSlippageModel though by extending SlippageModel and setting |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Uh oh!
There was an error while loading. Please reload this page.
-
How do I make sure the random slippage works when I set price type? Only seems to work on the stoploss.
I can't enter a trade on the close of the signal bars so i need to set to the open of the next bar but I'm getting fills at the open price with no slippage which i don't think would reflect a true simulation.
I've checked against the price data using the trades and they are the same
if not long_pos and cross_up:
elif long_pos and cross_down:
ctx.sell_all_shares()
ctx.sell_fill_price = pybroker.common.PriceType.OPEN
strategy = Strategy(data_source_M30, start_date, end_date, config)
strategy.add_execution(exec_fn, tickers, indicators=list(indicators.values()))
strategy.set_slippage_model(RandomSlippageModel(min_pct=5.0, max_pct=10.0))
result = strategy.backtest(warmup=260, calc_bootstrap=True)
result.trades
Beta Was this translation helpful? Give feedback.
All reactions