SmartQuant Discussion
http://www.smartquant.com/forums/

Deposit Funds in OnStrategyInit
http://www.smartquant.com/forums/viewtopic.php?f=60&t=14894
Page 1 of 1

Author:  abasqd [ Wed Mar 27, 2019 7:15 am ]
Post subject:  Deposit Funds in OnStrategyInit

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()?

Author:  skuvv [ Wed Mar 27, 2019 9:39 am ]
Post subject:  Re: Deposit Funds in OnStrategyInit

Hello,
What type of strategy are you using?
How do you adding instrument to a strategy?

Author:  abasqd [ Thu Mar 28, 2019 4:27 am ]
Post subject:  Re: Deposit Funds in OnStrategyInit

I'm using InstrumentStrategy_

To add an instrument I call strategy.Add(instrument)

Author:  abasqd [ Thu Apr 04, 2019 5:13 am ]
Post subject:  Re: Deposit Funds in OnStrategyInit

Any progress here?

Author:  skuvv [ Mon Jul 08, 2019 12:14 pm ]
Post subject:  Re: Deposit Funds in OnStrategyInit

Typically Portfolio.Account.Deposit() called OnStrategyStart event.
InstrumentStrategy has not substrategies for instruments at OnStrategyInit moment.

Page 1 of 1 All times are UTC + 3 hours
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/