private double getChangePercentage(bool isTick) { if (isTick) { if (_tickA == null) { _tickA = LastFutureTick(_instrumentA); } if (_tickB == null) { _tickB = LastFutureTick(_instrumentB); } if (_tickA == null || _tickB == null) { return(0.0); } double delta = StrategyExHelper.Change(_tickA) - StrategyExHelper.Change(_tickB); if (DebugChangePercentage) { Print("涨幅差(DA-DB): " + delta); } return(delta); } Print("不支持K先驱动方式"); return(0); }
public override void OnTrade(Trade trade) { Print("===========成交回报==========="); OrderHelper.PrintOnTradeStatus(this, trade); if (trade.InstrumentID.Equals(_futureA.ID)) { _tradeA = trade; } else if (trade.InstrumentID.Equals(_futureB.ID)) { _tradeB = trade; } if (_tradeA != null && _tradeA.OpenOrClose == EnumOpenClose.平仓 && _tradeB != null && _tradeB.OpenOrClose == EnumOpenClose.平仓) { _tradeA = _tradeB = null; } if (PrintPositionStatusOnTradeDeal) { StrategyExHelper.PrintPositionStatus(this); } }
public override void Exit() { Print("策略停止运行!" + CurrentTime); _orderStatusTracerA.PrintHitStatus(); _orderStatusTracerB.PrintHitStatus(); Order[] ods = new Order[] { _orderStatusTracerA.Order, _orderStatusTracerB.Order }; StrategyExHelper.PrintPositionStatus(this, ods, true); }
// 更新策略状态 public void Update(object state) { StrategyExHelper.PrintRunningDate(this); updateTradeSlice(); updateTradeDay(); StrategyExHelper.PrintRuntimeStatus(this); }
public override void onCustomInit() { if (AllFutures.Count != 2) { SwitchRunningState(ERunningState.InitFailed); } _futureA = AllFutures[0]; _futureB = AllFutures[1]; _instrumentA = _futureA.ID; _instrumentB = _futureB.ID; StrategyExHelper.PrintRunningDate(this); setupDeadline(); setupHedgeStatusTracer(); SwitchRunningState(ERunningState.DurationWatch); }