public void AddMATrendSelector() { DeltaVolInput input = DeltaVolInput.GetDefaultDeltaVolInput(); input.BaseInvest = 1 * 1000 * 1000 * 1000; EquityDeltaHedger selector = new EquityDeltaHedger(MarketDataSetKey.KospiFuture, input.StartDate, input.EndDate, input.BaseInvest, input.IssueInterval); selector.AddMATrendTester(10, 50); selector.UseMASpreadSwitch(0.2, -0.2); IPnLResult result = selector.ExecuteHedge(); DateTime prevDate = result.StartDate; DateTime curDate = result.StartDate.AddDays(1); while (curDate <= result.EndDate) { if (result.IsExistDate(curDate)) { if (result.GetDailyInvest(curDate) < input.BaseInvest * -2.0) { trendSelectors.Add(curDate, false); } else { trendSelectors.Add(curDate, true); } } curDate = curDate.AddDays(1); } }
public void Start() { //TODO implement Equity Picker PeriodicEquityPicker equityPicker = new PeriodicEquityPicker(_mds, _selectionPeriod, _lookupPeriod, EquityVolPredefinedVariables.EquitySelectionNumber, _startDate, _endDate); equityPicker.UseHighRankMarketCap(); Dictionary<DateTime, List<MarketDataSetKey>> selectedEquities = equityPicker.Select(); List<IPnLResult> pnLResults = new List<IPnLResult>(); //EquityStockDeltaVolExecutor stockTradingExecutor = new EquityStockDeltaVolExecutor(_mds, _input); //Dictionary<MarketDataSetKey, IPnLResult> allEquityPnLResults = stockTradingExecutor.Execute(); EquityStockSimpleExecutor stockTradingExecutor = new EquityStockSimpleExecutor(_mds, _startDate, _endDate, _input.IssueInterval, _input.BaseInvest); Dictionary<MarketDataSetKey, IPnLResult> allEquityPnLResults = stockTradingExecutor.Execute(); Dictionary<MarketDataSetKey, IPnLResult> seletecdEquityPnLResults = GetSelectedEquityPnLResults(allEquityPnLResults, selectedEquities); pnLResults.AddRange(seletecdEquityPnLResults.Values.ToList()); Dictionary<DateTime, double> grossDeltas = AggregateGrossDeltas(pnLResults); EquityDeltaHedger hedger =new EquityDeltaHedger(MarketDataSetKey.KospiFuture, _input.StartDate, _input.EndDate, grossDeltas, _input.BaseInvest, _input.IssueInterval); if (_input.bMATrendHedging) { hedger.AddMATrendTester( EquityVolPredefinedVariables.LeadingMAPeriod, EquityVolPredefinedVariables.BaseMAPeriod); if (_input.bDeltaSwitchUpDown) { hedger.UseMASpreadSwitch( EquityVolPredefinedVariables.MASpreadUpperBound, EquityVolPredefinedVariables.MASpreadLowerBound); } } IPnLResult hedgePnL; if (_input.bVoliatilityHedging) { hedger.UseVolTest(10); } hedgePnL = hedger.ExecuteHedge(); pnLResults.Add(hedgePnL); //BandTradingHedger auxHedger = new BandTradingHedger(MarketDataSetKey.KospiFuture, // _input.StartDate, _input.EndDate, grossDeltas, _input.BaseInvest); //auxHedger.AddMATrendTester(1, 20); //IPnLResult auxHedgePnL = auxHedger.ExecuteHedge(); //pnLResults.Add(auxHedgePnL); IPnLResult sumPnlResult = AggregatePnLResult(pnLResults); HandleResult(sumPnlResult); }