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

Order df before finding intervals for idx_open and idx_close; and switch operator for determining whether or not to layer #68

Closed jaymon0703 closed 6 years ago

jaymon0703 commented 6 years ago

The vectorised implementation for building our txns in txnsim.txns() uses findInterval() to assign timestamps and prices to our txns. When our original observed strategy is a strategy with layering, the vectorised solution implemented with commit c172724 introduces a bug, in that findInterval() will be called with an unordered input parameter (the layered trades with older timestamps will come after the more recent timestamps in the time series).

Also, commit bf43488 introduced a bug in that layering was never possible with the operator the wrong way round.