public AssetWeightLog Execute(long caseNumber) { DateTime curDate = this.Input.StartDate; AssetWeightLog log = new AssetWeightLog(); _opSet.SetOpFlag(caseNumber); this._adjustment.Clear(); while (curDate <= this.Input.EndDate) { if (this._readyData.IsExistDate(curDate)) { AssetWeight aw = this._allocBase.CalculateAssetWeight(curDate, this._readyData); AssetAdjustment aa = this._adjustment.CalculateAssetWeight(_opSet, curDate, _readyData); aw.Multiply(aa); aw.SetScale(); log.Add(curDate, aw); } curDate = curDate.AddDays(1); } return log; }
public AssetWeightLog Execute(long caseNumber) { IAllocBase allocBase = this._allocBases[(int)caseNumber]; DateTime curDate = this.Input.StartDate; AssetWeightLog log = new AssetWeightLog(); _curKey = String.Format("SAO({0})", allocBase.GetKey()); while (curDate <= this.Input.EndDate) { if (this._readyData.IsExistDate(curDate)) { AssetWeight aw = allocBase.CalculateAssetWeight(curDate, this._readyData); AssetAdjustment aa = new AssetAdjustment(1, 1, 1); aw.Multiply(aa); aw.SetScale(); log.Add(curDate, aw); } curDate = curDate.AddDays(1); } return log; }
public AssetWeightLog Execute(long caseNumber) { DateTime curDate = this.Input.StartDate; AssetWeightLog log = new AssetWeightLog(); IAdjustment adj = this._adjs[(int)caseNumber]; log.ExperimentKey = _descriptions[(int)caseNumber]; while (curDate <= this.Input.EndDate) { if (this._readyData.IsExistDate(curDate)) { AssetWeight aw = this._allocBase.CalculateAssetWeight(curDate, this._readyData); AssetAdjustment aa = adj.CalculateAssetWeight(null, curDate, _readyData); aw.Multiply(aa); aw.SetScale(); log.Add(curDate, aw); } curDate = curDate.AddDays(1); } return log; }
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; }
public void CalculatePnL(AssetWeightLog log, MarketDataSet marketDataSet) { DateTime prevDate = log.StartDate; DateTime curDate = log.StartDate.AddDays(1); _cumPnL.Add(prevDate, 0); while (curDate <= log.EndDate) { if (log.IsExistDate(curDate)) { AssetWeight awPrev = log.GetData(prevDate); Tuple<double, double, double, double> dailyPnL = GetDailyPnL( awPrev, prevDate, curDate, InitInvestAmount, marketDataSet); AddDailyPnL(curDate, dailyPnL); AddCumPnL(prevDate, curDate, dailyPnL.Item1); ChangeCurDateAndPrevDate(ref prevDate, ref curDate); continue; } curDate = curDate.AddDays(1); } double total = TotalPnL; }