SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Mon Nov 19, 2018 9:22 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Sub Strategies
PostPosted: Wed Mar 28, 2018 4:34 pm 
Offline

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

I have used the SlowTurtleTrendFollowing example, and wanted to have two different Child strategies. Each one with a new instance of the Turtles class. And then, I will amend the Parameters for each child strategy.

Though, when I start this code, OQ crashed and in VS2017, I get an StackOverflow Error.

Can you point me in the right direction?

Code:
public override void Run()
      {
   Instrument instrument1 = InstrumentManager.Instruments["AAPL"];
            Instrument instrument2 = InstrumentManager.Instruments["MSFT"];

            strategy = new Turtles(framework, "Turtles");

            var sUS = new Turtles(framework, "Turtles US");
            var sCA = new Turtles(framework, "Turtles JP");

            sUS.AddInstrument(instrument1);
            sCA.AddInstrument(instrument2);

            //strategy.AddInstrument(instrument1);
         //strategy.AddInstrument(instrument2);

         DataSimulator.DateTime1 = new DateTime(2013, 01, 01);
         DataSimulator.DateTime2 = new DateTime(2013, 12, 31);

            BarFactory.Clear();
            //sUS.BarFactory.Clear(); //not needed here, BarFactory.Clear(); Clears all
            //sCA.BarFactory.Clear(); //not needed here, BarFactory.Clear(); Clears all
            sUS.BarFactory.Add(instrument1, BarType.Time, barSize);
         sCA.BarFactory.Add(instrument2, BarType.Time, barSize);

            strategy.AddStrategy(sUS);
            strategy.AddStrategy(sCA);

            StartStrategy();
      }

Regards
Mike


Last edited by mikembb on Thu Mar 29, 2018 5:59 pm, edited 1 time in total.

Top
 Profile  
 
 Post subject: Re: Sub Strategies
PostPosted: Thu Mar 29, 2018 4:10 pm 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 441
Hello,
BarFactory is same for all strategies, so you don't necessary to do strategy.BarFactory.Clear();

I not sure why StackOverflow happens, perhaps something in Turtles strategy, which cause this problem.
You can send me part of code for reprodusing StackOverflow.


Top
 Profile  
 
 Post subject: Re: Sub Strategies
PostPosted: Thu Mar 29, 2018 5:55 pm 
Offline

Joined: Tue Oct 13, 2009 12:19 pm
Posts: 235
if you replace the RUN part of the SlowTurtleTrendFollowing example with my code from above, it will produce that error.

But otherwise the concept is correct, that I add only certain instruments to certain strategies. The idea is, to differenticate the different countries into different instances of the same strategy.
Ok, and I will put BarFactory.Clear() only once into the code.

Or do I need to define providers for the sub strategies?

Regards
Mike


Top
 Profile  
 
 Post subject: Re: Sub Strategies
PostPosted: Fri Mar 30, 2018 11:45 pm 
Offline

Joined: Tue Oct 13, 2009 12:19 pm
Posts: 235
ok, I read through the OQ2014 manuel again, and I added a new project called MetaStrategy. This MetaStrategy instance became my Parent Strategy (not like before, where I had a instrument strategy as my parent strategy) - and the two ChildStrategies, are instances of the Turtles Strategy.

Now, at least OQ does not crash with a StackOverflow error.

Though, now I get this funny behavior, see screenshot - a NullReferenceException.

When I run the regular SlowTurtleTrendFollowing strategy as provided by OQ2014, then the data is all right over the same timeframe.

Any ideas? How could I debug this Exception that it is throwing?

Regards
Mike


Attachments:
File comment: this is the source code.
SlowTurtleTrendFollowing - US and CA demo.zip [256.16 KiB]
Downloaded 59 times
File comment: This is the exception that I cannot find out what it is
2018-03-30 OpenQuant 2014_Solutions_SlowTurtleTrendFollowing - US an.zip [40.54 KiB]
Downloaded 58 times
Top
 Profile  
 
 Post subject: Re: Sub Strategies
PostPosted: Tue Apr 03, 2018 10:34 am 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 441
The problem was that you forgot to add a reference for MetaStrategy.
At result the scenario used other type of SmartQuant.MetaStrategy instead your OpenQuant.MetaStrategy.


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