SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Mon Jul 06, 2020 5:07 am

All times are UTC + 3 hours




Post new topic Reply to topic  [ 2 posts ] 
Author Message
PostPosted: Fri Dec 16, 2016 11:52 am 
Offline

Joined: Tue Oct 13, 2009 12:19 pm
Posts: 270
Dear all,

can you point me in the right direction on how to add Money to my strategy from the Scenario?

I tried this:
strategy = new MyStrategy(framework, "Debug");
Initialize();
if (strategy.Portfolio == null)
Console.WriteLine("strategy.Portfolio == null");
strategy.Portfolio.Account.Deposit(Clock.DateTime, 1000*1000, CurrencyId.USD, "Initial allocation",true);
StartStrategy();

but I get this error:
Code:
Building MyStrategy
strategy.Portfolio == null
System.Reflection.TargetInvocationException: Exception has been thrown by the target of an invocation. ---> System.NullReferenceException: Object reference not set to an instance of an object.
   at OpenQuant.MyScenario.Run()
   at OpenQuant.Program.Main(String[] args)
   --- End of inner exception stack trace ---
   at System.RuntimeMethodHandle.InvokeMethod(Object target, Object[] arguments, Signature sig, Boolean constructor)
   at System.Reflection.RuntimeMethodInfo.UnsafeInvokeInternal(Object obj, Object[] parameters, Object[] arguments)
   at System.Reflection.RuntimeMethodInfo.Invoke(Object obj, BindingFlags invokeAttr, Binder binder, Object[] parameters, CultureInfo culture)
   at OpenQuant.Projects.SolutionRunner.Run(Object obj)


So when is the Portfolio added? Or is it not to be intented to be used in this way, that each Scenario should specify how much cash to start with?

Thx
Mike


Top
 Profile  
 
PostPosted: Tue Dec 20, 2016 4:21 pm 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 569
At moment before StartStrategy() strategy has no Portfolio.
Try make deposit at start of strategy - OnStrategyStart().


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

All times are UTC + 3 hours


Who is online

Users browsing this forum: No registered users and 1 guest


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