public void Start() { MarketData md = GetMarketPriceData(); CreateTradingData(md); //손익 및 누적 손익 계산 _tradingDataList.Sort(); bool bAmoutBasis = false; SinglePnLResult profitAndLossResult = new SinglePnLResult( Key, "KospiTrendTrading", TradingDirection.Short, bAmoutBasis, _tradingDataList); //profitAndLossResult.EnableLog(); profitAndLossResult.CalculatePnL(); HandleResult(profitAndLossResult); }
Dictionary<MarketDataSetKey, IPnLResult> GetSelectedEquityPnLResults( Dictionary<MarketDataSetKey, IPnLResult> allEquityPnLResults, Dictionary<DateTime, List<MarketDataSetKey>> selectedEquities) { if (selectedEquities.Count == 0) { return allEquityPnLResults; } Dictionary<MarketDataSetKey, IPnLResult> selectedEquityPnLResults = new Dictionary<MarketDataSetKey, IPnLResult>(); foreach (KeyValuePair<MarketDataSetKey, IPnLResult> pair in allEquityPnLResults) { SinglePnLResult result = pair.Value as SinglePnLResult; List<RawTradingData> selectedTradingList = SelectTradingDataList(result.Key, result.TradingDataList, selectedEquities); if (selectedTradingList.Count == 0) { continue; } SinglePnLResult selectedResult = new SinglePnLResult(result.Key, result.Name, result.Direction, true, selectedTradingList); selectedResult.CostRate = EquityVolPredefinedVariables.CostRate; if (EquityVolPredefinedVariables.BLogEnabled) { selectedResult.EnableLog(); } selectedResult.CalculatePnL(); selectedEquityPnLResults.Add(pair.Key, selectedResult); } return selectedEquityPnLResults; }
SinglePnLResult CalculateHedgePnLResult() { _tradingDataList.Sort(); bool bAmoutBasis = false; SinglePnLResult profitAndLossResult = new SinglePnLResult( HedgingInstKey, "EquityDeltaHedging", TradingDirection.Short, bAmoutBasis, _tradingDataList); if (EquityVolPredefinedVariables.BLogEnabled) { profitAndLossResult.EnableLog(); } profitAndLossResult.CalculatePnL(); return profitAndLossResult; }
SinglePnLResult SingleSimulate(MarketData md) { List<RawTradingData> tradingList = new List<RawTradingData>(); MarketDataSetKey key= (DataUtil.GetMarketDataKeyFromTicker(md.Ticker)); DateTime curDate = _startDate; int index = 0; double curSize = 0; while (curDate <= _endDate) { if (md.IsExistDate(curDate)) { double curPrice = md.GetData(curDate).OHLC.Close; if (index % _rebalancingPeriod == 0) { curSize = _baseInvest / curPrice; } if (curPrice < 50000) { curSize = Math.Round(curSize / 10, 0) * 10; } RawTradingData tradingData = new RawTradingData(key, curDate, curPrice, curSize); tradingData.AddDelta(curSize * curPrice / _baseInvest); tradingList.Add(tradingData); index++; } curDate = curDate.AddDays(1); } SinglePnLResult profitAndLossResult = new SinglePnLResult(key, key.ToString(), TradingDirection.Long, true, tradingList); profitAndLossResult.CalculatePnL(); return profitAndLossResult; }