public ReorderItem(Order up, ContractFuse cf, bool isHandelMax, PositionSummary pos, IMatch matcher) { this.matcher = matcher; Blaster.Log.Info(string.Format("平仓委托重新报价加入队列:{0}-大{1}-边{2},{3}-单{4}", up.Trader.Name, isHandelMax, cf.MaxPrice, cf.MinPrice, up.ToShortString())); this.order = up; this.cf = cf; this.Pos = pos; HisOrderIds = new List <int> { up.Id }; this.isHandleMax = isHandelMax; //引发熔断-- cf.ShouldAccept(up); if (isHandelMax) { cf.OnMaxChanged += cf_OnMaxChanged; } else { cf.OnMinChanged += cf_OnMinChanged; } cf.Excutor.OnFuseOver += Excutor_OnFuseOver; CreateTime = DateTime.Now; checkTimer = new Timer(); checkTimer.Interval = ContractFuse.FuseSpanInMin / 2 * 60 * 1000; checkTimer.Elapsed += checkTimer_Elapsed; checkTimer.Start(); }
void CreateAndReorder(Contract arg1, decimal?arg2, bool isUpChanged) { if (!IsAlive()) { Clear(isUpChanged, "原单已成交"); return; } var ratio = order.Trader.GetMaintainRatio(); if (ratio >= 1) { Clear(isUpChanged, "保证率>=1"); return; } var pos = order.Trader.GetPositionSummary(arg1.Code, PositionType.权利仓); if (pos == null) { Clear(isUpChanged, "已无持仓"); return; } var closable = order.Trader.GetClosableCount(pos); if (closable <= 0) { Clear(isUpChanged, "可平<=0"); return; } if (pos.PositionType == "义务仓") { if (order.Direction == TradeDirectType.卖) { Clear(isUpChanged, "是义务仓但单是卖单"); return; } } else { if (order.Direction == TradeDirectType.买) { Clear(isUpChanged, "是权利仓但单是买单"); return; } } var neworder = new Order { Id = IdService <Order> .Instance.NewId(), OrderPolicy = OrderPolicy.限价申报, Price = isUpChanged? (decimal)cf.MaxPrice:(decimal)cf.MinPrice, Count = closable, ReportCount = closable, Contract = order.Contract, Direction = pos.PositionType == "义务仓" ? TradeDirectType.买 : TradeDirectType.卖, OrderType = order.OrderType, OrderTime = DateTime.Now, Trader = order.Trader, State = OrderState.等待中, IsBySystem = true }; var os = order.ToShortString(); var ps = order.Price.ToString(); var ro = ReOrder(neworder); if (ro != 2) { Blaster.Log.Info(string.Format("{0}限变化重新报价:{1}-原{2}-现{3}-旧{4}-新{5}", isUpChanged ? "上" : "下", order.Trader.Name, ps, neworder.Price, os, neworder.ToShortString())); } if (ro == 1) { //引发下一次熔断事件 cf.ShouldAccept(neworder); } }