ENH: Add slippage models to execute at limit, open prices #1512
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Generalize SlippageModel with the idea of bar stage.
3 bar stages are defined: Open, HighLow and Close. The behavior
until now corresponds to using only Close stage.
The first added slippage model HLCVolumeSlippage executes limit
orders at limit price instead of close price, but still using
close price for market orders.
The second slippage model OHLVolumeSlippage takes advantage of
all the OHLC prices in the bar, executing limit orders either
at open or limit depending on marketability.
Default behaviour is not changed. To use the new functionality:
def initialize(context):
context.set_slippage(HLCVolumeSlippage())