SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Sun Jul 22, 2018 5:05 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 6 posts ] 
Author Message
PostPosted: Wed Aug 07, 2013 12:56 pm 
Offline

Joined: Wed Aug 08, 2007 6:32 pm
Posts: 218
Hi,

How can i optimize based on something other than the standard attributes in optimization, for example avgwin/avgloser ratio.

Had a look at the posts

search.php?keywords=OptimizationManager&terms=all&author=&sc=1&sf=all&sk=t&sd=d&sr=posts&st=0&ch=300&t=0&submit=Search

viewtopic.php?f=64&t=8627 this only does the standard optimization but through scenario.

but not sure how to implement this, where can i run the code etc.


Top
 Profile  
 
PostPosted: Wed Aug 07, 2013 1:39 pm 
Offline

Joined: Wed Oct 08, 2003 1:06 pm
Posts: 833
Hi,

OptimizationManager doesn't exist in OpenQuant, it is one of the components of another product.

As to this link:
viewtopic.php?f=64&t=8627

Just copy the code to the scenario.cs file and run solution as usually.

Regards,
sergey.


Top
 Profile  
 
PostPosted: Thu Aug 08, 2013 10:52 am 
Offline

Joined: Wed Aug 08, 2007 6:32 pm
Posts: 218
Thanks Baraz, but i wanted to optimize as you have shown in the topic but with another parameter like var99 or avgwin/losers ratio. How is that possible?


Top
 Profile  
 
PostPosted: Thu Aug 08, 2013 11:18 am 
Offline

Joined: Wed Oct 08, 2003 1:06 pm
Posts: 833
Hi Azuric,

If just need to replace the line "double objective = Solution.Portfolio.GetValue();" with some other objective function.

For example you could calculate any statistics in OnStrategyStop handler in the strategy code and put it into Global hashtable:

Code:
int wins = 0;
   int losses = 0;
   
   double equityOnPositionOpen;
   
   public override void OnPositionOpened()
   {
      equityOnPositionOpen = Portfolio.GetValue();
   }
   
   public override void OnPositionClosed()
   {
      if (Portfolio.GetValue() > equityOnPositionOpen)
         wins++;
      else
         losses++;
   }

   public override void OnStrategyStop()
   {
      Global["Win/Loss%"] = (double)wins/losses;
   }


and then get this value in the scenario.cs replacing the line mentioned above with:
Code:
double objective = (double)Strategy.Global[""Win/Loss%"];


Regards,
Sergey.


Top
 Profile  
 
PostPosted: Mon Aug 12, 2013 3:55 pm 
Offline

Joined: Wed Aug 08, 2007 6:32 pm
Posts: 218
ahh i get it now didn't realise we could use global hash tables. Thanks alot that is very helpful


Top
 Profile  
 
PostPosted: Sun Oct 13, 2013 10:59 pm 
Offline

Joined: Wed Aug 08, 2007 6:32 pm
Posts: 218
Hi Baraz,

I am trying to implement your code but I keep getting a

Object reference is not set to an instance of an object in the Run method.

How do instantiate this object properly to avoid this error.


Top
 Profile  
 
Display posts from previous:  Sort by  
Post new topic Reply to topic  [ 6 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