Exemplo n.º 1
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;
        }
Exemplo n.º 2
0
 void HandleResult(IPnLResult result)
 {
     foreach (IPnLResultHandler handler in this._resultHandlers)
     {
         SimCaseResultOverview overview = new SimCaseResultOverview(_input, 1, 1);
         handler.HandleResult(overview, result);
     }
 }
Exemplo n.º 3
0
 public static double GetPPM(IPnLResult input)
 {
     DrawDown mdd = GetMaxDrawDown(input);
     double pnl = GetAvgPnLPerYear(input);
     return pnl / Math.Abs(mdd.Value);
 }
Exemplo n.º 4
0
 public static double GetAvgPnLPerYear(IPnLResult input)
 {
     double totalYear = (double)((input.EndDate - input.StartDate).Days) / 365.00;
     double pnlPerYear = input.TotalPnL / totalYear;
     return pnlPerYear;
 }
Exemplo n.º 5
0
        public static DrawDown GetMaxDrawDown(IPnLResult 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;
        }
Exemplo n.º 6
0
 void AddNewResult_Raw(SimCaseResultOverview experimentData, IPnLResult result)
 {
     _result.Add(result);
     UpdateDataGridView(experimentData);
 }
Exemplo n.º 7
0
 public void HandleResult(SimCaseResultOverview experimentData, IPnLResult result)
 {
     this.Invoke(new AddNewResult(AddNewResult_Raw), new object[] { experimentData, result });
     //this.Invoke(new AddNewResult(AddNewResult_Raw), result);
 }