public void FillOutputs(EachDynamicPropSim parent, DateTime cur, Boolean bFirstRow) { Trace.Assert(parent.Incs.ContainsKey(cur)); double curInc = parent.Incs[cur]; DateTime prev = cur.AddDays(-1); double pnl = 0; double prevCumPnl = 0; if (!bFirstRow) { Trace.Assert(parent.Investments.ContainsKey(prev)); Trace.Assert(parent.CumPnls.ContainsKey(prev)); double prevInvestment = parent.Investments[prev]; prevCumPnl = parent.CumPnls[prev]; pnl = prevInvestment * curInc; } double curCumPnl = prevCumPnl + pnl; double investment = _investment; parent.Pnls.Add(cur, pnl); parent.CumPnls.Add(cur, curCumPnl); parent.Investments.Add(cur, investment); }
public void Execute(SortedList<DateTime, double> marketData) { List<Tuple<DateTime, DateTime>> simDateList = GetSimDateList(this._from, this._until, _startGapMonth, _durationMonth); _marketData = marketData; //_marketData = MarketDataManager.Ins().Get_PX_LAST_Data( // this._ticker, this._currency); if (_marketData.Count == 0) { logger.Error("Fatal error"); return; } foreach (Tuple<DateTime, DateTime> eachSimDate in simDateList) { // each simulation을 진행할 클래스를 만들어서 진행하고 결과를 받도록 한다. EachDynamicPropSim eachSim = new EachDynamicPropSim( this.Key, this._ticker, eachSimDate, _marketData, this._lossCutEach, this._leverageEach, this._maxInvestmentEach, _policy); eachSim.ExecuteSim(); EachSims.Add(eachSim); } SetStatisticData(); }
double GetInvestment(double cumPnl, EachDynamicPropSim parent) { return Math.Min((cumPnl - parent.LossCut) * parent.Leverage, parent.MaxInvestment); }