devalpha-io / devalpha-node

A stream-based approach to algorithmic trading and backtesting in Node.js
https://devalpha.io
GNU General Public License v3.0
247 stars 40 forks source link

backtesting cash synchronization problem #10

Open unsaved opened 6 years ago

unsaved commented 6 years ago

I am not limited by startCapital. In any strategy event callback invocation where state.capital.cash > 0, I can buy as I wish to using multiple buys as long as each buy is for <= state.capital.cash. state.capital.cash goes negative.

It seems that within a single event cycle you either don't update state.capital.cash or don't check trades against the updated value.