braverock / blotter

blotter provides transaction infrastructure for defining transactions, portfolios and accounts for trading systems and simulation. Provides portfolio support for multi-asset class and multi-currency portfolios. Actively maintained and developed.
112 stars 49 forks source link

txnsim - Limit layered quantity to max pos of observed strategy #63

Closed jaymon0703 closed 6 years ago

jaymon0703 commented 6 years ago

Currently in txnsim() we do not limit the quantity from layering long and short trades when building out the replicate strategies.

To remedy this, we can create a new stylized fact, namely; 'maxlongpos' for the maximum long position observed in the original strategy, and maxshortpos for the maximum absolute short position observed in the original strategy. Then keep track of the cumsum of the layered quantities as we layer, making sure we only add to the long and short layer if the cumsum is within the max long or short positions observed in the original strategy, respectively.