I would like to call Portfolio.Account.Deposit from within OnStrategyInit. Like so:
protected override void OnStrategyInit() { Portfolio.Account.Deposit(1000000, CurrencyId.USD, "Initial allocation"); }
This causes a null pointer exception because at this point Portfolio is still null.
However this does work:
protected override void OnStrategyInit() { Init(); Portfolio.Account.Deposit(1000000, CurrencyId.USD, "Initial allocation"); }
I find this strange because I expected that if OnStrategyInit has been called that would mean that Init() has been called already? Is this understanding correct? How is it that OnStrategyInit has been called before Init()?
|