SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Thu Dec 02, 2021 1:50 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 5 posts ] 
Author Message
 Post subject: Optimization
PostPosted: Sat Mar 19, 2016 4:33 am 
Offline

Joined: Thu Sep 17, 2015 5:52 am
Posts: 133
Hello, two questions regarding OQ2014's Optimization tool:

1. Is it possible to see what the current top result of an Optimization is if I pause the optimizer midway through its optimization? (This would come in very handy when doing optimizations that could take days, or even weeks.)

2. Is it possible to see what the top 20 (or more) results of an Optimization are? Rather then just the the top 1 result of the optimization? How can I do this if so?

Thanks!


Top
 Profile  
 
 Post subject: Re: Optimization
PostPosted: Wed Mar 30, 2016 11:18 am 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 583
Hello M101,
1)I think you can export result(with your parameters) to file on event OnStrategyStop.
2)All results have stored in OptimizationUniverse, look at SMACrossover solution.
So after optimization you can use it.
Code:
universe[index].Objective


Top
 Profile  
 
 Post subject: Re: Optimization
PostPosted: Wed Jun 01, 2016 8:53 pm 
Offline

Joined: Thu Sep 17, 2015 5:52 am
Posts: 133
Hi Skuvv, I've been having some trouble getting this to work.

Can you please post a complete code example for items 1 and 2?

thanks.


Top
 Profile  
 
 Post subject: Re: Optimization
PostPosted: Fri Jun 03, 2016 10:59 am 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 583
1)
Code:
      private string resultsPath = @"C:\results.txt";
      private static object lockObject = new object();
      protected override void OnStrategyStop()
      {
         lock(lockObject )
         {
            using (System.IO.StreamWriter sw = new System.IO.StreamWriter(resultsPath, true))
            {
               Strategy rootStrategy = this.GetRootStrategy();
               
               sw.WriteLine("{0} - {1}, your params", rootStrategy.Name, rootStrategy.Objective());
            }
         }
      }

2)
Code:
            optimizer.Optimize(strategy, instruments, universe, 10);

            System.Collections.Generic.List<OptimizationParameterSet> results = new System.Collections.Generic.List<OptimizationParameterSet>();

            for (int i = 0; i < universe.Count; i++)
                results.Add(universe[i]);

            //order by descending
            results.Sort((set1, set2) => set2.Objective.CompareTo(set1.Objective));

            for (int i = 0; i < results.Count; i++)
                Console.WriteLine("{0} - {1}, {2}", i, results[i].Objective, results[i]);


Top
 Profile  
 
 Post subject: Re: Optimization
PostPosted: Mon Jun 06, 2016 5:18 am 
Offline

Joined: Thu Sep 17, 2015 5:52 am
Posts: 133
Thanks Skuvv, that works great!

When you get a chance, can you please post a version of items 2's code that will also do the following?

A. Have each result's row also include all the data from the Statistics tab. (See attached item 1.jpg for the Statistics tab I am referring to).

B. If Pause is pressed during the Optimization, have the Output window display all Optimization results done so far in order from Best to Worst. Then if Play is pressed again, have the Optimization resume accordingly.

C. Get the Output window to display all the Optimization's Results in a .csv format and with column headers. For example,
The output window would display this:
Quote:
0 - 195560, Length1 = 7 Length2 = 15 Bar = 60
1 - 195526, Length1 = 6 Length2 = 16 Bar = 60
2 - 195326, Length1 = 2 Length2 = 26 Bar = 60

as this
Quote:
Version, Objective, Length1, Length2, Bar
0, 195560, 7, 15, 60
1, 195526, 6, 16, 60
2, 195326, 2, 26, 60


Thanks!


Attachments:
1.jpg
1.jpg [ 224.22 KiB | Viewed 4981 times ]
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