Skip to content
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
wants to merge 6 commits into
base: master
Choose a base branch
from

Conversation

volconst
Copy link

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())

Snail Mail added 5 commits August 30, 2016 21:51
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
@coveralls
Copy link

Coverage Status

Coverage increased (+0.01%) to 86.563% when pulling 2fdbb2d on volconst:limit-orders into be0ecb6 on quantopian:master.

@coveralls
Copy link

coveralls commented Sep 23, 2016

Coverage Status

Coverage increased (+0.06%) to 86.607% when pulling d8a5b31 on volconst:limit-orders into be0ecb6 on quantopian:master.

@rclai
Copy link

rclai commented Oct 10, 2016

What is the status of this PR? Did you guys come to a conclusion?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants