SmartQuant Discussion

Automated Quantitative Strategy Development, SmartQuant Product Discussion and Technical Support Forums
It is currently Sat Nov 25, 2017 12:48 pm

All times are UTC + 3 hours




Post new topic Reply to topic  [ 9 posts ] 
Author Message
 Post subject: StatisticsManager
PostPosted: Thu Jul 13, 2017 4:56 pm 
Offline

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

if I run below:
Code:
List<int> statsToSee = new List<int>();
      statsToSee.Add(5);statsToSee.Add(7);statsToSee.Add(9);statsToSee.Add(10);statsToSee.Add(21);statsToSee.Add(24);statsToSee.Add(43);statsToSee.Add(69);statsToSee.Add(71);
            statsToSee.Add(72);statsToSee.Add(73);statsToSee.Add(74);statsToSee.Add(75);statsToSee.Add(76);            
            foreach (var x in fields)
            {
               int t = (int)x.GetValue(null);
               if (calculateStats)
               {
                  if (!statsToSee.Contains(t)) StatisticsManager.Remove(t);
               }
               else
                  StatisticsManager.Remove(t);
            }


I get the following error message and OQ2014 halts:

Quote:
Building MyStrategy
07/13/2017 15:51:13.470 Framework::Clear
07/13/2017 15:51:16.773 Framework::Clear
07/13/2017 15:51:18.064 Scenario::StartStrategy Backtest
07/13/2017 15:51:18.067 StrategyManager::StartStrategy TestTheBug
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 System.Object.GetType()
at SmartQuant.StatisticsManager.Clone(Int32 type)
at SmartQuant.PortfolioStatistics.Kpl6miQZR8(PortfolioStatisticsItem , Int32 )
at SmartQuant.PortfolioStatisticsItem.Subscribe(Int32 itemType)
at SmartQuant.Statistics.ProfitFactor.OnInit()
at SmartQuant.PortfolioStatistics.Add(PortfolioStatisticsItem item)
at SmartQuant.PortfolioStatistics..ctor(Portfolio portfolio)
at SmartQuant.Portfolio.Init(Framework framework)
at SmartQuant.Portfolio..ctor(Framework framework, String name)
at SmartQuant.Strategy.Init()
at SmartQuant.StrategyManager.StartStrategy(Strategy strategy, StrategyMode mode)
at SmartQuant.Scenario.StartStrategy()
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)


any idea, what that could be? Is it possible, that ProfitFactor is dependent on some other stats, that I did not enable?

And if I remove all stats, and then if I do not close OQ fully, next run, the stats are still removed from the StatisticsManager. How could I reinit the StatisticsManager to have all stats again?

Thanks
Mike


Top
 Profile  
 
 Post subject: Re: StatisticsManager
PostPosted: Thu Jul 13, 2017 5:04 pm 
Offline

Joined: Tue Oct 13, 2009 12:19 pm
Posts: 204
an error like that also happens when I remove 10: ProfitFactor - then it stops at: ProfitablePercent

On another topic: would it be possible to add these stats as % to portfolio equity:

AvgTrade
AvgWinTrade
AvgLossTrade

MaxAdverseExcursion
MaxFavorableExcursion

AvgMaxAdverseExcursion
AvgMaxFavorableExcursion

Thanks
Mike


Top
 Profile  
 
 Post subject: Re: StatisticsManager
PostPosted: Fri Jul 14, 2017 11:13 am 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 386
Hello Mike,
some of statistics items can use other items.
In case where you delete them you get error.

If you do update version of OQ2014, it will print you which statistic item is missed.
It helpful to setup necessary list of items.


Top
 Profile  
 
 Post subject: Re: StatisticsManager
PostPosted: Fri Jul 14, 2017 4:38 pm 
Offline

Joined: Tue Oct 13, 2009 12:19 pm
Posts: 204
great thanks for that.

Is there a way, to have the performance chart of a portfolio
1.) display the Drawdown in % ?
2.) how can I from the code, update the Performance Charts while it is still running? Not every time I run PerformanceUpdate(), but rather every time I like.

Thanks
Mike


Top
 Profile  
 
 Post subject: Re: StatisticsManager
PostPosted: Mon Jul 17, 2017 4:42 pm 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 386
mikembb wrote:
great thanks for that.

Is there a way, to have the performance chart of a portfolio
1.) display the Drawdown in % ?
2.) how can I from the code, update the Performance Charts while it is still running? Not every time I run PerformanceUpdate(), but rather every time I like.

Thanks
Mike

1)it not possible, because calculations did in absolute values.
2)PortfolioPerformance.Update() is only one method which used for updating.
Charts just use results of calculations and cannot affect this calculations.


Top
 Profile  
 
 Post subject: Re: StatisticsManager
PostPosted: Mon Jul 17, 2017 6:25 pm 
Offline

Joined: Tue Oct 13, 2009 12:19 pm
Posts: 204
ok, for 1, could that performance statistic please be added, that OQ calcs Drawdown in % of equity?


Top
 Profile  
 
 Post subject: Re: StatisticsManager
PostPosted: Thu Sep 07, 2017 2:45 pm 
Offline

Joined: Tue Oct 13, 2009 12:19 pm
Posts: 204
Thanks for implementing the drawdown calcs in %. That is helpfull and more adequte for an institutional like product as yours.

To make it more complete, would be great, if you can do the same for these:
AvgTrade
AvgWinTrade
AvgLossTrade

MaxAdverseExcursion
MaxFavorableExcursion

AvgMaxAdverseExcursion
AvgMaxFavorableExcursion

Or at least an option for the user to choose from.

Thanks.
Mike


Top
 Profile  
 
 Post subject: Re: StatisticsManager
PostPosted: Thu Sep 07, 2017 4:29 pm 
Offline

Joined: Tue Oct 13, 2009 12:19 pm
Posts: 204
The error message you describe reads like this:
Quote:
Error: PortfolioStatisticsItem with type:2 not found in StatisticsManager


If I then add then do not remove the statistics with 2, I still get the same error.

I currently want to see these statistics, {5,7,9,10,21,24,43,69,71,72,73,74,75,76}

Maybe you can fix with your next release.


Top
 Profile  
 
 Post subject: Re: StatisticsManager
PostPosted: Fri Sep 08, 2017 2:02 pm 
Offline

Joined: Wed May 05, 2010 9:49 pm
Posts: 386
You should check that items added in StatisticsManager or clear all and add what you want, snippet for scenario:
Code:
         var drawdown = framework.StatisticsManager.Get(PortfolioStatisticsType.Drawdown);
         
         //clear
         StatisticsManager.Statistics.Clear();
         OptimizationManager.ClearStatisticsTypes();
         
         //add
         StatisticsManager.Add(drawdown);
         OptimizationManager.AddStatisticsType(drawdown.Type);


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