Example #1
0
        public static DrawDown GetMaxDrawDown(ProfitAndLossResult input)
        {
            DateTime curDate = input.StartDate;

            DrawDown mdd = new DrawDown();

            while (curDate <= input.EndDate)
            {
                if (input.IsExistDate(curDate))
                {
                    DrawDown dd = GetDrawDown(curDate, input.EndDate, input);

                    if (dd.Value < mdd.Value)
                    {
                        mdd = dd;
                    }
                }
                curDate = curDate.AddDays(1);
            }
            return mdd;
        }
Example #2
0
        static DrawDown GetDrawDown(DateTime startDate, DateTime endDate, IPnLResult input)
        {
            DateTime curDate = startDate;

            double startDateCumPnL = input.GetCumPnL(startDate);
            DrawDown dd = new DrawDown();
            dd.StartDate = startDate;
            dd.EndDate = endDate;

            while (curDate <= endDate)
            {
                if (input.IsExistDate(curDate))
                {
                    double curDateCumPnL = input.GetCumPnL(curDate);
                    double diff = curDateCumPnL - startDateCumPnL;

                    if (diff <= dd.Value)
                    {
                        //update
                        dd.Value = diff;
                        dd.EndDate = curDate;
                    }
                }
                curDate = curDate.AddDays(1);
            }

            return dd;
        }