SmartQuant Discussion
http://www.smartquant.com/forums/

OQ2014:Logging addition statistics for each optimization
http://www.smartquant.com/forums/viewtopic.php?f=64&t=10972
Page 1 of 1

Author:  prashant [ Tue Jul 21, 2015 9:45 am ]
Post subject:  OQ2014:Logging addition statistics for each optimization

Hi Support,

Along with Objective value, I want to log multiple statistics such as Sharpe Ratio, MaxDrawDawn etc. for each optimization. I tried to write a text file in append mode on OnStrategyStop() but because of multithreaded Optimization all the stats values were showing as 0 or NaN.

I also thought to override Objective function and return a concatenated string of statistics but this is also not possible as Objective function only returns double value.

Please help to show how i can collect multiple statistics for each optimization loop at one place.

Thanks

Author:  prashant [ Wed Jul 22, 2015 8:08 am ]
Post subject:  Re: OQ2014:Logging addition statistics for each optimization

Someone know how to do this please?

Cheers

Author:  skuvv [ Wed Jul 22, 2015 9:54 am ]
Post subject:  Re: OQ2014:Logging addition statistics for each optimization

Can you please prepare simple strategy to reproduce this bug?
We cannot reproduce this in our examples.

Author:  skuvv [ Wed Jul 22, 2015 9:58 am ]
Post subject:  Re: OQ2014:Logging addition statistics for each optimization

Additionally, I output statistics onStrategyStop using this code:
Code:
        protected override void OnStrategyStop()
        {
            Portfolio portfolio = Portfolio;

            //show ParentStatistic
            if (false)
                portfolio = Portfolio.Parent;

            string timeFmt = "dd.MM.yyyy HH:mm:ss.fff";
            string message = "******************** " + Instrument + " Length1: " + Length1 + " Length2: " + Length2 + " Time: " + framework.Clock.DateTime.ToString(timeFmt) + "\r\n";

            var maxDrawdownStatistics = portfolio.Statistics.Items.GetByType(PortfolioStatisticsType.MaxDrawdown);
            int maxDrawdownCount = maxDrawdownStatistics.TotalValues.Count;
            double maxDrawdown = Math.Round(maxDrawdownStatistics.TotalValue, 2);
            message += "MaxDrawdown: " + maxDrawdown + " itemsCount: " + maxDrawdownCount + "\r\n";

            var sharpeRatioStatistics = portfolio.Statistics.Items.GetByType(PortfolioStatisticsType.SharpeRatio);
            int sharpeRatioCount = sharpeRatioStatistics.TotalValues.Count;
            double sharpeRatio = Math.Round(sharpeRatioStatistics.TotalValue, 2);
            message += "SharpeRatio: " + sharpeRatio + " itemsCount: " + sharpeRatioCount + "\r\n";

            double equity = Math.Round(portfolio.Value, 2);
            message += "Equity: " + equity + "\r\n";

            message.Trim();

            Console.WriteLine(message);
        }

Page 1 of 1 All times are UTC + 3 hours
Powered by phpBB® Forum Software © phpBB Group
https://www.phpbb.com/