SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Tue Jul 14, 2020 8:10 pm

All times are UTC + 3 hours

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

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");
if (strategy.Portfolio == null)
Console.WriteLine("strategy.Portfolio == null");
strategy.Portfolio.Account.Deposit(Clock.DateTime, 1000*1000, CurrencyId.USD, "Initial allocation",true);

but I get this error:
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?


PostPosted: Tue Dec 20, 2016 4:21 pm 

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

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 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:  
Powered by phpBB® Forum Software © phpBB Group