public static double GetPnLRatePerYear(ProfitAndLossResult input) { double totalYear = ((double)(input.EndDate - input.StartDate).Days) / 365.00; double totalPnLRate = GetPnLRateTotal(input); return totalPnLRate / totalYear; }
public void HandleResult(SimCaseResultOverview experimentData, ProfitAndLossResult result) { String fileName = String.Format("pnl_{0}.csv", result.Key); CsvUtil.CsvOut(fileName, result); DrawDown mdd = MathUtil.GetMaxDrawDown(result); double pnLRateTotal = MathUtil.GetPnLRateTotal(result); double pnlRatePerYear = MathUtil.GetPnLRatePerYear(result); double ppm = MathUtil.GetPPM(result); }
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(AssetRateDataLog log) { ProfitAndLossResult result = new ProfitAndLossResult(_opSet.GetKey(), this.Input.InitInvestAmount); result.CalculatePnL(log, _readyData); return result; }
void AddNewResult_Raw(SimCaseResultOverview overview, ProfitAndLossResult result) { _result.Add(result); // UpdateDataGridView(experimentData); UpdateOverview(overview); }
public void HandleResult(SimCaseResultOverview experimentData, ProfitAndLossResult result) { this.Invoke(new AddNewResult(AddNewResult_Raw), new object[] { experimentData, result }); //this.Invoke(new AddNewResult(AddNewResult_Raw), result); }
ProfitAndLossResult CalculatePnL(AssetRateDataLog log, MarketDataSet marketData) { ProfitAndLossResult pnl = new ProfitAndLossResult(String.Format("{0}", this.Name), this.InputData.InitInvestAmount); pnl.CalculatePnL(log, marketData); return pnl; }
public static double GetPPM(ProfitAndLossResult input) { DrawDown mdd = GetMaxDrawDown(input); double pnl = GetAvgPnLPerYear(input); return pnl / Math.Abs(mdd.Value); }
public static double GetPnLRateTotal(ProfitAndLossResult input) { return input.TotalPnL / input.InitInvestAmount; }
public static double GetAvgPnLPerYear(ProfitAndLossResult input) { double totalYear = ((double) (input.EndDate - input.StartDate).Days) / 365.00; double pnlPerYear = input.TotalPnL / totalYear; return pnlPerYear; }
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; }