Hello guys,

i need some help to understand how the engine is working. It is a simple strategy that just buys two assets and sells them the day after.

I worked with it even in a debuger to trace the issue. 


This property above should represent how much available cash my algo has. But, for some reason it is lagging, it shows very low cash available, which suggests that portfolio is invested. But at the same time self.Portfolio.Invested returns false. 

Which creates a margin warning:

Backtest Handled Error: Order Error: id: 7, Insufficient buying power to complete order (Value:99774.36), Reason: Id: 7, Initial Margin: 99775.89, Free Margin: 331.12

And the next asset can not be bought. For some reason this script can only work with one asset. Do i use the Engine the wrong way? Where is the misstake i make?


Thanks in advance :)