public static double GetPnLRatePerYear(ProfitAndLossResult input) { double totalYear = (input.EndDate - input.StartDate).Days / 365; double totalPnLRate = GetPnLRateTotal(input); return totalPnLRate / totalYear; }
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; }
public ProfitAndLossResult GetResult(AssetWeightLog log) { ProfitAndLossResult result = new ProfitAndLossResult(_opSet.GetKey(), this.Input.InitInvestAmount); result.CalculatePnL(log, _readyData); result.AvgPnLPerYear = MathUtil.GetAvgPnLPerYear(result); result.PPM = MathUtil.GetYearPnLPerMDD(result); return result; }
void AddNewResult_Raw(ExperimentData experimentData, ProfitAndLossResult result) { _result.Add(result); UpdateDataGridView(experimentData); }
public void HandleResult(ExperimentData experimentData, ProfitAndLossResult result) { this.Invoke(new AddNewResult(AddNewResult_Raw), new object[] { experimentData, result }); //this.Invoke(new AddNewResult(AddNewResult_Raw), result); }
static DrawDown GetDrawDown(DateTime startDate, DateTime endDate, ProfitAndLossResult 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; }
public static double GetYearPnLPerMDD(ProfitAndLossResult input) { DrawDown mdd = GetMaxDrawDown(input); double pnl = GetAvgPnLPerYear(input); return Math.Abs(pnl / mdd.Value); }
public static double GetPnLRateTotal(ProfitAndLossResult input) { return input.TotalPnL / input.InitInvestAmount; }
public static double GetAvgPnLPerYear(ProfitAndLossResult input) { double totalYear = (input.EndDate - input.StartDate).Days / 365; double pnlPerYear = input.TotalPnL / totalYear; return pnlPerYear; }