Profile Picture

Restrict shares to percent of volume for backtesting

Posted By alpha23 7 Years Ago
Message
Posted Sunday November 28 2010
Is there a way to restrict the number of shares executed to a percent of the volume for a bar during backtesting? For example, if the volume for the next bar is 10,000 (unknown at the time the order is placed) and % = 40%, then a max of 4,000 shares would be executed regardless of the amount set in the position manager (leading to a partial fill).

Thanks, Duane
Posted Sunday November 28 2010
There's not a simple way to do this. You can derive your own paper broker from the existing PaperTrader and override some functionality. But it doesn't support partial fills, so the best you could do would probably be to avoid filling the order entirely if the trading volume wasn't large enough.

Of course you can also write your own paper broker from scratch, but that's not exactly simple Smile

Thanks,
Daniel
Posted Tuesday December 07 2010
Daniel,

Can you add to the feature request list?

Thanks, Duane

Edited: Tuesday December 07 2010 by alpha23
Posted Thursday December 09 2010
Logged as ID 1356.
Posted Saturday February 11 2012
is there any update to this feature request?

Thanks, Duane
Posted Thursday February 16 2012
Sorry, no progress on this.

Thanks,
Daniel
Posted Friday March 09 2012
Daniel,

For simulation, I’m trying to develop an efficient way to handle limiting the order size based on the volume at the time of the order. Unfortunately, there is not an easy way to handle in the strategy because, for example, there is no way to know the volume during fill for limit orders at their time of order placement.

The alternative is to process the restriction in a paper trader’s ShouldFill method. It is easy enough to obtain the volume data from the SQL db. The only issue I’m running into is that if the actual order size is greater than the limitation, the order should be executed as a partial fill with the remaining amount left outstanding to be potentially filled on subsequent ticks.

Can you provide an override to ShouldFill that includes a parameter fillSize, and fill only the fillSize returned, leaving the remaining outstanding?

Users should then easily be able to handle partial fills in backtesting. The fill size is an important consideration during backtesting because partial fills are common in real trading depending on the symbols the strategy is executed against. Additionally, if fill size is not considered, users may impact real fill prices, which will be unknown to them at the time of execution.

Thanks, Duane
Posted Wednesday March 28 2012
Please advise.

Thanks, Duane
Posted Wednesday March 28 2012
Hi Duane,

Yes, I'd like to allow the ShouldFill method to specify the size of the fill and support partial fills in the paper broker. Unfortunately, this change isn't very simple to make so I can't commit to doing it any time soon.

Thanks,
Daniel
Posted Tuesday April 03 2012
Support for partial fills in plugins derived from PaperBroker should be in the next build, which will allow you to limit the size of the fill based on the size of the current tick or bar (or whatever other criteria you choose).

Thanks,
Daniel


Similar Topics


Reading This Topic


2005-2017 © RightEdge Systems