public override void Notify(Guid tradeGuid, OpenStatus status, double dealQty = 0, double dealPrice = 0, string weituobianhao = "", string pendWeituobianhao = "") { lock (lock_tps) { for (int i = 0; i < tps.ToArray().Count(); i++) { var t = tps[i]; if (t.TradeGuid == tradeGuid) { if (status == OpenStatus.Opened) { t.EnterPoint.OpenPrice = dealPrice; decimal realDealQty = (decimal)dealQty + (decimal)t.EnterPoint.PartDealQty - (decimal)t.EnterPoint.DealQty; holdHands += realDealQty; t.Status = OpenStatus.Opened; frozenBuyHands -= realDealQty; t.EnterPoint.DealQty = (double)((decimal)dealQty + (decimal)t.EnterPoint.PartDealQty); RaiseMessage(new PolicyMessageEventArgs("策略已接受开仓通知")); if (t.EnterPoint.SecInfo.Key == eosbtcsi.Key) { double huanbiqty = Math.Floor(dealPrice * (double)realDealQty * SecInfo.JingDu) / SecInfo.JingDu; double eosqty = Math.Floor((double)realDealQty * eosusdtsi.JingDu) / eosusdtsi.JingDu; if (t.EnterPoint.OpenType == OpenType.Buy) { if ((double)realDealQty > eosusdtsi.MinQty) { OpenArgs oa = new OpenArgs( eosusdt.Bid, eosqty, OpenType.Sell, eosusdtsi, eosusdt, t.TpRemark); OpenDelete od = new OpenDelete(OpenThread); od.BeginInvoke(oa, null, null); EosUsdtStatus = false; } if (huanbiqty >= SecInfo.MinQty) { OpenArgs oa2 = new OpenArgs( currentTick.Ask, huanbiqty, OpenType.Buy, SecInfo, currentTick, t.TpRemark); OpenDelete od2 = new OpenDelete(OpenThread); od2.BeginInvoke(oa2, null, null); BtcUsdtStatus = false; } } else { if ((double)realDealQty > eosusdtsi.MinQty) { OpenArgs oa = new OpenArgs( eosusdt.Ask, eosqty, OpenType.Buy, eosusdtsi, eosusdt, t.TpRemark); OpenDelete od = new OpenDelete(OpenThread); od.BeginInvoke(oa, null, null); EosUsdtStatus = false; } if (huanbiqty >= SecInfo.MinQty) { OpenArgs oa2 = new OpenArgs( currentTick.Bid, huanbiqty, OpenType.Sell, SecInfo, currentTick, t.TpRemark); OpenDelete od2 = new OpenDelete(OpenThread); od2.BeginInvoke(oa2, null, null); BtcUsdtStatus = false; } } EosBtcStatus = true; } else if (t.EnterPoint.SecInfo.Key == eosusdtsi.Key) { EosUsdtStatus = true; } else if (t.EnterPoint.SecInfo.Key == SecInfo.Key) { BtcUsdtStatus = true; } } else if (status == OpenStatus.Open) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受开仓下单通知", this.policyName))); } else if (status == OpenStatus.Close) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受平仓下单通知", this.policyName))); } else if (status == OpenStatus.Closed) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受平仓通知", this.policyName))); } else if (status == OpenStatus.OpenPending) { t.EnterPoint.PartDealQty = t.EnterPoint.DealQty; RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略HoldHands:{1}", this.policyName, holdHands))); } else if (status == OpenStatus.ClosePending) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略HoldHands:{1}", this.policyName, holdHands))); } else if (status == OpenStatus.Failed) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受失败通知", this.policyName))); } else if (status == OpenStatus.PartOpend) { if (dealQty > (t.EnterPoint.DealQty - t.EnterPoint.PartDealQty)) { decimal realDealQty = (decimal)dealQty + (decimal)t.EnterPoint.PartDealQty - (decimal)t.EnterPoint.DealQty; holdHands += realDealQty; frozenBuyHands -= realDealQty; t.EnterPoint.DealQty = dealQty + t.EnterPoint.PartDealQty; if (t.EnterPoint.SecInfo.Key == eosbtcsi.Key) { double huanbiqty = Math.Floor(dealPrice * (double)realDealQty * SecInfo.JingDu) / SecInfo.JingDu; double eosqty = Math.Floor((double)realDealQty * eosusdtsi.JingDu) / eosusdtsi.JingDu; if (t.EnterPoint.OpenType == OpenType.Buy) { if ((double)realDealQty > eosusdtsi.MinQty) { OpenArgs oa = new OpenArgs( eosusdt.Bid, eosqty, OpenType.Sell, eosusdtsi, eosusdt, t.TpRemark); OpenDelete od = new OpenDelete(OpenThread); od.BeginInvoke(oa, null, null); EosUsdtStatus = false; } if (huanbiqty >= SecInfo.MinQty) { OpenArgs oa2 = new OpenArgs( currentTick.Ask, huanbiqty, OpenType.Buy, SecInfo, currentTick, t.TpRemark); OpenDelete od2 = new OpenDelete(OpenThread); od2.BeginInvoke(oa2, null, null); BtcUsdtStatus = false; } } else { if ((double)realDealQty > eosusdtsi.MinQty) { OpenArgs oa = new OpenArgs( eosusdt.Ask, eosqty, OpenType.Buy, eosusdtsi, eosusdt, t.TpRemark); OpenDelete od = new OpenDelete(OpenThread); od.BeginInvoke(oa, null, null); EosUsdtStatus = false; } if (huanbiqty >= SecInfo.MinQty) { OpenArgs oa2 = new OpenArgs( currentTick.Bid, huanbiqty, OpenType.Sell, SecInfo, currentTick, t.TpRemark); OpenDelete od2 = new OpenDelete(OpenThread); od2.BeginInvoke(oa2, null, null); BtcUsdtStatus = false; } } EosBtcStatus = true; } RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受部分入场成交通知,成交数量:{1}", this.policyName, dealQty))); } } else if (status == OpenStatus.PartClosed) { if (dealQty > (t.OutPoint.DealQty - t.OutPoint.PartDealQty)) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受部分出场成交通知,成交数量:{1}", this.policyName, dealQty))); decimal realDealQty = (decimal)dealQty + (decimal)t.OutPoint.PartDealQty - (decimal)t.OutPoint.DealQty; holdHands -= realDealQty; frozenSellHands -= realDealQty; t.OutPoint.DealQty = dealQty + t.OutPoint.PartDealQty; } } else if (status == OpenStatus.OpenCanceled) { if (t.EnterPoint.SecInfo.Key == eosbtcsi.Key) { EosBtcStatus = true; } RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受入场撤单通知", this.policyName))); } else if (status == OpenStatus.CloseCanceled) { frozenSellHands -= (decimal)dealQty; RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接受出场撤单通知", this.policyName))); } else if (status == OpenStatus.OpenRest) { RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接收开仓剩余通知,数量:{1}", this.policyName, dealQty))); } else if (status == OpenStatus.CloseRest) { holdHands -= (decimal)dealQty; frozenSellHands -= (decimal)dealQty; RaiseMessage(new PolicyMessageEventArgs(string.Format("{0}-策略已接收平仓剩余通知,数量:{1}", this.policyName, dealQty))); } } } } }
private void OpenThread(OpenArgs oa) { Open(oa.Price, oa.Qty, oa.Opentype, oa.Si, oa.Tickdata, oa.Tr); }