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.
114 stars 50 forks source link

txnsim - reorder txns variable in txnsim.txns() so that closing txns precede new opening txns #67

Closed jaymon0703 closed 6 years ago

jaymon0703 commented 6 years ago

Currently in v 0.14.0 when building the replicate transactions, the closing transactions related to prior opening transactions occur only after new opening transactions on the same timestamp. There is no impact on the performance of the replicate strategies, just nonsensical spikes in position fill charts etc as per the below screenshot.

image

A solution would be to rbind() opening transactions onto the closing transactions, ensuring the closing transaction on timestamp x occurs before the new opening transaction on the same timestamp.