SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Thu Aug 22, 2019 5:10 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
PostPosted: Wed Mar 27, 2019 7:15 am 
Offline

Joined: Thu Dec 06, 2018 1:57 am
Posts: 28
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()?


Top
 Profile  
 
PostPosted: Wed Mar 27, 2019 9:39 am 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 497
Hello,
What type of strategy are you using?
How do you adding instrument to a strategy?


Top
 Profile  
 
PostPosted: Thu Mar 28, 2019 4:27 am 
Offline

Joined: Thu Dec 06, 2018 1:57 am
Posts: 28
I'm using InstrumentStrategy_

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


Top
 Profile  
 
PostPosted: Thu Apr 04, 2019 5:13 am 
Offline

Joined: Thu Dec 06, 2018 1:57 am
Posts: 28
Any progress here?


Top
 Profile  
 
PostPosted: Mon Jul 08, 2019 12:14 pm 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 497
Typically Portfolio.Account.Deposit() called OnStrategyStart event.
InstrumentStrategy has not substrategies for instruments at OnStrategyInit moment.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 5 posts ] 

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 2 guests


You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot post attachments in this forum

Search for:
Jump to:  
cron
Powered by phpBB® Forum Software © phpBB Group