-
Notifications
You must be signed in to change notification settings - Fork 4.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
ENH: Add slippage models to execute at limit, open prices #1512
Open
volconst
wants to merge
6
commits into
quantopian:master
Choose a base branch
from
volconst:limit-orders
base: master
Could not load branches
Branch not found: {{ refName }}
Loading
Could not load tags
Nothing to show
Loading
Are you sure you want to change the base?
Some commits from the old base branch may be removed from the timeline,
and old review comments may become outdated.
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Generalize SlippageModel by adding properties market_field and limits_enhance and sublasses that extend it and configure the properties. Thus the slippage model can be configured whether to execute at open or close price and whether to trigger limit and stop orders early at limit, stop price (if they fall within [low..high] range) or at the configured market_price. Default settings are backward compatible with respect to execution price (at least in the tests). To get the new behavior set the slippage model to a subclass. E.g.: def initialize(context): context.set_slippage(ConservativeCloseSlippage()) Once configured, the slippage model either always executes limit orders at limit price or always at market_price. It is not designed to use limit price and market_price for different orders in the same simulation.
SlippageModel is generalized 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())
Sync with added parameters at master BarData
What is the status of this PR? Did you guys come to a conclusion? |
This was referenced Dec 17, 2023
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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())