private void Cancel(SingleOrder order) { if (order == null) { return; } if (!_bTdConnected) { EmitError(-1, -1, "交易服务器没有连接,无法撤单"); tdlog.Error("交易服务器没有连接,无法撤单"); return; } DFITCOrderRspDataRtnField pOrderRtn; if (_Orders4Cancel.TryGetValue(order, out pOrderRtn)) { Instrument inst = InstrumentManager.Instruments[order.Symbol]; string altSymbol = inst.GetSymbol(Name); int localOrderID = pOrderRtn.localOrderID; int spdOrderID = pOrderRtn.spdOrderID; if (spdOrderID >= 0) { localOrderID = -1; } else { spdOrderID = -1; } TraderApi.TD_CancelOrder(m_pTdApi, altSymbol, localOrderID, spdOrderID); } }
internal void Cancel() { this.Disconnect(); this.fProvider.fProcessors.Remove(this.fOrder.ClOrdID); SingleOrder singleOrder = this.fOrder as SingleOrder; ExecutionReport executionReport = new ExecutionReport(); executionReport.TransactTime = Clock.Now; executionReport.ClOrdID = singleOrder.ClOrdID; executionReport.OrigClOrdID = singleOrder.ClOrdID; executionReport.ExecType = ExecType.Cancelled; executionReport.OrdStatus = OrdStatus.Cancelled; executionReport.Symbol = singleOrder.Symbol; executionReport.Side = singleOrder.Side; executionReport.OrdType = singleOrder.OrdType; executionReport.AvgPx = singleOrder.AvgPx; executionReport.LeavesQty = singleOrder.LeavesQty; executionReport.CumQty = singleOrder.CumQty; executionReport.OrderQty = singleOrder.OrderQty; executionReport.Price = singleOrder.Price; executionReport.StopPx = singleOrder.StopPx; executionReport.Currency = singleOrder.Currency; executionReport.Text = singleOrder.Text; this.fProvider.EmitExecutionReport(executionReport); }
public void Enter(Quote quote, SingleOrder order) { latestQuote = quote; order.ExecutionReport += new ExecutionReportEventHandler(order_ExecutionReport); EntryOrder = order; if (State.Created == state) { } else { Console.WriteLine("*** {0} RoundTrip.Enter in {1}", instrument.Symbol, state); } //Console.WriteLine( "setting entry submitted" ); state = State.EntrySubmitted; dtEntryInitiation = quote.DateTime; quoteEntryInitiation = quote; if (order.Side == Side.Buy) { side = PositionSide.Long; } if (order.Side == Side.Sell || order.Side == Side.SellShort) { side = PositionSide.Short; } // need an error condition here }
public void SendNewOrderSingle(NewOrderSingle order) { SingleOrder singleOrder = order as SingleOrder; if (singleOrder.IsFilled || singleOrder.IsCancelled) { return; } this.EmitExecutionReport(new ExecutionReport { TransactTime = Clock.Now, ClOrdID = order.ClOrdID, ExecType = ExecType.New, OrdStatus = OrdStatus.New, Symbol = order.Symbol, OrdType = order.OrdType, Side = order.Side, Price = order.Price, StopPx = order.StopPx, OrderQty = order.OrderQty, CumQty = 0.0, LeavesQty = order.OrderQty, Currency = order.Currency, Text = order.Text }); new SimulationExecutionProcessor(this, order); }
private void Cancel(SingleOrder order) { if (!_bTdConnected) { EmitError(-1, -1, "交易服务器没有连接,无法撤单"); tdlog.Error("交易服务器没有连接,无法撤单"); return; } Dictionary<string, CZQThostFtdcOrderField> _Ref2Action; if (_Orders4Cancel.TryGetValue(order, out _Ref2Action)) { // 标记下正在撤单 _PendingCancelFlags[order] = order.OrdStatus; lock (_Ref2Action) { CZQThostFtdcOrderField __Order; foreach (CZQThostFtdcOrderField _Order in _Ref2Action.Values) { __Order = _Order; //这地方要是过滤下就好了 TraderApi.TD_CancelOrder(m_pTdApi, ref __Order); } } } }
protected override void OnExecutionReport(SingleOrder order, ExecutionReport report) { Instrument instrument = order.Instrument; /*---------------------------------------*/ Exit exit = this.exits[instrument]; if (exit != null) { exit.OnExecutionReport(order, report); } Entry entry = this.entries[instrument]; if (entry != null) { entry.OnExecutionReport(order, report); } MoneyManager moneyManager = this.moneyManagers[instrument]; if (moneyManager != null) { moneyManager.OnExecutionReport(order, report); } RiskManager riskManager = this.riskManagers[instrument]; if (riskManager != null) { riskManager.OnExecutionReport(order, report); } /*---------------------------------------*/ /*this.runtimeCrossEntry.OnExecutionReport(order, report); * this.runtimeCrossExit.OnExecutionReport(order, report); * this.entries[instrument].OnExecutionReport(order, report); * this.exits[instrument].OnExecutionReport(order, report);*/ }
internal void Replace(FIXOrderCancelReplaceRequest request) { this.Disconnect(); this.fProvider.fProcessors.Remove(request.OrigClOrdID); SingleOrder singleOrder = this.fOrder as SingleOrder; ExecutionReport executionReport = new ExecutionReport(); executionReport.TransactTime = Clock.Now; executionReport.ClOrdID = request.ClOrdID; executionReport.OrigClOrdID = request.OrigClOrdID; executionReport.ExecType = ExecType.Replace; executionReport.OrdStatus = OrdStatus.Replaced; executionReport.Symbol = singleOrder.Symbol; executionReport.Side = singleOrder.Side; executionReport.OrdType = FIXOrdType.FromFIX(request.OrdType); executionReport.CumQty = singleOrder.CumQty; executionReport.OrderQty = request.OrderQty; executionReport.LeavesQty = request.OrderQty - singleOrder.CumQty; executionReport.Price = request.Price; executionReport.StopPx = request.StopPx; executionReport.Currency = singleOrder.Currency; executionReport.TimeInForce = FIXTimeInForce.FromFIX(request.TimeInForce); executionReport.Text = singleOrder.Text; this.fProvider.EmitExecutionReport(executionReport); new SimulationExecutionProcessor(this.fProvider, singleOrder); }
internal void SetOrderDone(SingleOrder order) { OrdStatus ordStatus = order.OrdStatus; switch (ordStatus) { case OrdStatus.Filled: this.OnOrderFilled(order); break; case OrdStatus.DoneForDay: break; case OrdStatus.Cancelled: this.OnOrderCancelled(order); break; default: if (ordStatus == OrdStatus.Rejected) { this.OnOrderRejected(order); } break; } this.OnOrderDone(order); }
// Methods public OrderRecord(SingleOrder order) { this.order = order; this.avgPx = 0.0; this.leavesQty = (int)order.OrderQty; this.cumQty = 0; }
private void Cancel(SingleOrder order) { if (null == order) { return; } if (!_bTdConnected) { EmitError(-1, -1, "交易服务器没有连接,无法撤单"); tdlog.Error("交易服务器没有连接,无法撤单"); return; } GenericOrderItem item; if (orderMap.TryGetValue(order, out item)) { CThostFtdcOrderField _order; if (orderMap.TryGetValue(item, out _order)) { // 标记下正在撤单 orderMap.Order_OrdStatus[order] = order.OrdStatus; EmitExecutionReport(order, OrdStatus.PendingCancel); TraderApi.TD_CancelOrder(m_pTdApi, ref _order); } } }
internal void XNWFfvowtr() { this.D7GFelmgQp(); this.A8bFJItyyx.MyIPdEI7fi.Remove((object)this.PYBF7sahqY.ClOrdID); SingleOrder singleOrder = this.PYBF7sahqY as SingleOrder; ExecutionReport executionReport = new ExecutionReport(); executionReport.TransactTime = Clock.Now; executionReport.ClOrdID = singleOrder.ClOrdID; executionReport.OrigClOrdID = singleOrder.ClOrdID; executionReport.ExecType = ExecType.Cancelled; executionReport.OrdStatus = OrdStatus.Cancelled; executionReport.Symbol = singleOrder.Symbol; executionReport.Side = singleOrder.Side; executionReport.OrdType = singleOrder.OrdType; executionReport.AvgPx = singleOrder.AvgPx; executionReport.LeavesQty = singleOrder.LeavesQty; executionReport.CumQty = singleOrder.CumQty; executionReport.OrderQty = singleOrder.OrderQty; executionReport.Price = singleOrder.Price; executionReport.StopPx = singleOrder.StopPx; executionReport.Currency = singleOrder.Currency; executionReport.Text = singleOrder.Text; this.A8bFJItyyx.JPVPJSWclF(executionReport); }
private void Cancel(SingleOrder order) { if (null == order) return; if (!_bTdConnected) { EmitError(-1, -1, "交易服务器没有连接,无法撤单"); tdlog.Error("交易服务器没有连接,无法撤单"); return; } GenericOrderItem item; if(orderMap.TryGetValue(order,out item)) { CThostFtdcOrderField _order; if (orderMap.TryGetValue(item, out _order)) { // 标记下正在撤单 orderMap.Order_OrdStatus[order] = order.OrdStatus; EmitExecutionReport(order, OrdStatus.PendingCancel); TraderApi.TD_CancelOrder(m_pTdApi, ref _order); } } }
internal void CfcFBQBLXe(FIXOrderCancelReplaceRequest obj0) { SingleOrder singleOrder = this.PYBF7sahqY as SingleOrder; this.D7GFelmgQp(); this.A8bFJItyyx.MyIPdEI7fi.Remove((object)obj0.OrigClOrdID); ExecutionReport executionReport = new ExecutionReport(); executionReport.TransactTime = Clock.Now; executionReport.ClOrdID = obj0.ClOrdID; executionReport.OrigClOrdID = obj0.OrigClOrdID; executionReport.ExecType = ExecType.Replace; executionReport.OrdStatus = OrdStatus.Replaced; executionReport.Symbol = singleOrder.Symbol; executionReport.Side = singleOrder.Side; executionReport.OrdType = FIXOrdType.FromFIX(obj0.OrdType); executionReport.CumQty = singleOrder.CumQty; executionReport.OrderQty = obj0.OrderQty; executionReport.LeavesQty = obj0.OrderQty - singleOrder.CumQty; executionReport.AvgPx = singleOrder.AvgPx; executionReport.Price = obj0.Price; executionReport.StopPx = obj0.StopPx; executionReport.TrailingAmt = obj0.TrailingAmt; executionReport.Currency = singleOrder.Currency; executionReport.TimeInForce = FIXTimeInForce.FromFIX(obj0.TimeInForce); executionReport.Text = singleOrder.Text; this.A8bFJItyyx.JPVPJSWclF(executionReport); zo21q6cy3fImtUHATQ zo21q6cy3fImtUhatq = new zo21q6cy3fImtUHATQ(this.A8bFJItyyx, (FIXNewOrderSingle)singleOrder); }
private void MakeOrder(Side side, OrdType ordType) { Instrument instrument = (this.dgvQuotes.SelectedRows[0] as QuoteViewRow).Instrument; byte route = (byte)0; if (this.executionProvider is IMultiRouteExecutionProvider) { route = this.SelectedRoute; } OrderMiniBlotterForm orderMiniBlotterForm = new OrderMiniBlotterForm(); orderMiniBlotterForm.Init(instrument, ordType, side, route); if (orderMiniBlotterForm.ShowDialog((IWin32Window)this) == DialogResult.OK) { SingleOrder singleOrder = null; switch (ordType) { case OrdType.Market: singleOrder = new MarketOrder(this.executionProvider, this.portfolio, instrument, side, (double)orderMiniBlotterForm.Qty); break; case OrdType.Limit: singleOrder = new LimitOrder(this.executionProvider, this.portfolio, instrument, side, (double)orderMiniBlotterForm.Qty, orderMiniBlotterForm.LimitPrice); break; case OrdType.Stop: singleOrder = new StopOrder(this.executionProvider, this.portfolio, instrument, side, (double)orderMiniBlotterForm.Qty, orderMiniBlotterForm.StopPrice); break; case OrdType.StopLimit: singleOrder = new StopLimitOrder(this.executionProvider, this.portfolio, instrument, side, (double)orderMiniBlotterForm.Qty, orderMiniBlotterForm.LimitPrice, orderMiniBlotterForm.StopPrice); break; } ((NewOrderSingle)singleOrder).TimeInForce = orderMiniBlotterForm.TimeInForce; ((FIXNewOrderSingle)singleOrder).Route = (int)orderMiniBlotterForm.Route; singleOrder.Persistent = this.portfolio.Persistent; if (!((IProvider)this.executionProvider).IsConnected) { bool flag = false; if (MessageBox.Show(this, "Cannot send the order, because provider is not connected." + Environment.NewLine + "Do you want to connect to " + ((IProvider)this.executionProvider).Name + "?", "Error", MessageBoxButtons.YesNo, MessageBoxIcon.Exclamation) == DialogResult.Yes) { flag = true; ((IProvider)this.executionProvider).Connect(15000); } if (flag && !((IProvider)this.marketDataProvider).IsConnected) { MessageBox.Show(this, "Unable to connect to " + this.marketDataProvider.Name, "Error", MessageBoxButtons.OK, MessageBoxIcon.Hand); } } if (((IProvider)this.executionProvider).IsConnected) { singleOrder.Send(); } if ((int)orderMiniBlotterForm.Route > 0) { this.SelectedRoute = orderMiniBlotterForm.Route; } } orderMiniBlotterForm.Dispose(); }
private void OyPFEsHGL2(object obj0, BarEventArgs obj1) { if (!this.A8bFJItyyx.BarFilter.Contains(obj1.Bar.BarType, obj1.Bar.Size)) { return; } SingleOrder singleOrder = this.PYBF7sahqY as SingleOrder; if (singleOrder.OrdType == OrdType.Market) { this.Y18FFPmDy5((Quote)null, (Trade)null, obj1.Bar); } else { if (obj1.Bar == null || !this.A8bFJItyyx.FillOnBar) { return; } double open = obj1.Bar.Open; if (open == 0.0) { return; } this.wYBFLwFB4S(open, singleOrder.OrderQty); } }
private double GetQty(SingleOrder order, Quote quote, Trade trade, Bar bar) { if (quote != null && this.fProvider.PartialFills) { switch (order.Side) { case Side.Buy: if (quote.AskSize > 0) { return((double)quote.AskSize); } goto IL_5E; case Side.Sell: case Side.SellShort: if (quote.BidSize > 0) { return((double)quote.BidSize); } goto IL_5E; } return(order.OrderQty); } IL_5E: return(order.OrderQty); }
private List <SellingPack> MakeProductPackage(SingleOrder so) { var sellingList = new List <SellingPack>(); var product = this.catalog.Products.First(p => p.Code == so.ProductCode); var packs = product.Packs.OrderByDescending(p => p.Units).ToArray(); Pack[] clonedPacks; int rest = 1; for (int x = packs.Length; x >= 0; x--) { if (x == packs.Length) { clonedPacks = packs.ToArray(); } else { clonedPacks = packs.ToArray().Where(p => p.Id != packs[x].Id).ToArray(); } rest = this.MakePackageAndReturnRest(clonedPacks, so, sellingList); if (rest == 0) { break; } else { sellingList = sellingList.Where(p => p.ProductCode != product.Code).ToList(); } } return(sellingList); }
private void Cancel(SingleOrder order) { if (null == order) { return; } if (!_bTdConnected) { EmitError(-1, -1, "交易服务器没有连接,无法撤单"); tdlog.Error("交易服务器没有连接,无法撤单"); return; } Dictionary <string, CThostFtdcOrderField> _Ref2Action; if (_Orders4Cancel.TryGetValue(order, out _Ref2Action)) { lock (_Ref2Action) { CThostFtdcOrderField __Order; foreach (CThostFtdcOrderField _Order in _Ref2Action.Values) { __Order = _Order; //这地方要是过滤下就好了 TraderApi.TD_CancelOrder(m_pTdApi, ref __Order); } } } }
public void SetOrderDone(SingleOrder order) { try { Strategy strategy = (Strategy)null; if (!this.strategies.TryGetValue(order.Instrument, out strategy)) { return; } switch (order.OrdStatus) { case OrdStatus.Filled: strategy.OnOrderFilled(Map.FQ_OQ_Order[(object)order] as Order); break; case OrdStatus.Cancelled: strategy.OnOrderCancelled(Map.FQ_OQ_Order[(object)order] as Order); break; case OrdStatus.Rejected: strategy.OnOrderRejected(Map.FQ_OQ_Order[(object)order] as Order); break; case OrdStatus.Expired: strategy.OnOrderExpired(Map.FQ_OQ_Order[(object)order] as Order); break; } strategy.OnOrderDone(Map.FQ_OQ_Order[(object)order] as Order); } catch (Exception ex) { this.EmitError(ex); } }
private void OnRtnTrade(IntPtr pTraderApi, ref CThostFtdcTradeField pTrade) { tdlog.Info("时{0},合约{1},方向{2},开平{3},价{4},量{5},引用{6},成交编号{7}", pTrade.TradeTime, pTrade.InstrumentID, pTrade.Direction, pTrade.OffsetFlag, pTrade.Price, pTrade.Volume, pTrade.OrderRef, pTrade.TradeID); //找到自己发送的订单,标记成交 string strSysID = string.Format("{0}:{1}", pTrade.ExchangeID, pTrade.OrderSysID); string strKey; if (!orderMap.TryGetValue(strSysID, out strKey)) { return; } GenericOrderItem item; if (orderMap.TryGetValue(strKey, out item)) { MultiOrderLeg leg = item.GetLeg(CTPAPI.FromCTP(pTrade.Direction), pTrade.InstrumentID); SingleOrder order = leg.Order; #if CTP double Price = pTrade.Price; #elif CTPZQ double Price = Convert.ToDouble(pTrade.Price); #endif int Volume = pTrade.Volume; int LeavesQty = (int)order.LeavesQty - Volume; EmitFilled(order, Price, Volume, CommType.Absolute, 0); // 成交完成,清理数据 OnRtnTradeLastStatus(item, pTrade, strSysID, strKey); } }
//DeliverId int identity(1,1) not null primary key, // OrderId int foreign key references SingleOrder(OrderId), //CustomerId int foreign key references Customer(CustomerId), //RiderId int foreign key references Rider(RiderId), //IsAdminConfirmed BIT, // IsRiderConfirmed BIT, //PaymentStatus nvarchar(20), private Boolean Deliver(SingleOrder order, long orderid) { using (IDbConnection dbConnection = Connection) { String sQuery = "INSERT INTO Deliver(OrderId,CustomerId,IsAdminConfirmed,PaymentStatus)" + "VAlUES(@OrderId,@CustomerId,@IsAdminConfirmed,@PaymentStatus)"; String sQuery1 = "INSERT INTO CustomerHasLocation(CustomerId,CurrentLng,CurrentLat) " + "VALUES(@CustomerId,@CurrentLng,@CurrentLat)"; dbConnection.Open(); dbConnection.Execute(sQuery, new { OrderID = orderid, CustomerId = order.Customer.CustomerId, IsAdminConfirmed = false, PaymentStatus = "Not paid", }); dbConnection.Close(); dbConnection.Open(); dbConnection.Execute(sQuery1, new { CustomerId = order.Customer.CustomerId, CurrentLng = order.Customer.CurrentLng, CurrentLat = order.Customer.CurrentLat, }); dbConnection.Close(); } return(true); }
private void Cancel(SingleOrder order) { if (order == null) return; if (!_bTdConnected) { EmitError(-1, -1, "交易服务器没有连接,无法撤单"); tdlog.Error("交易服务器没有连接,无法撤单"); return; } DFITCOrderRspDataRtnField pOrderRtn; if (_Orders4Cancel.TryGetValue(order, out pOrderRtn)) { Instrument inst = InstrumentManager.Instruments[order.Symbol]; string altSymbol = inst.GetSymbol(Name); int localOrderID = pOrderRtn.localOrderID; int spdOrderID = pOrderRtn.spdOrderID; if (spdOrderID >= 0) { localOrderID = -1; } else { spdOrderID = -1; } TraderApi.TD_CancelOrder(m_pTdApi, altSymbol, localOrderID, spdOrderID); } }
private void OrderManager_ExecutionReport(object sender, ExecutionReportEventArgs args) { FreeQuant.FIX.ExecutionReport executionReport = args.ExecutionReport; if (executionReport.ExecType == ExecType.PartialFill) { SingleOrder order = ((InstrumentOrderListTable)OrderManager.Orders).All[executionReport.ClOrdID] as SingleOrder; StrategyRunner strategyRunner = (StrategyRunner)null; if (this.strategies.TryGetValue(order.Strategy, out strategyRunner) && strategyRunner.Enabled) { strategyRunner.SetPartiallyFilled(order); } } if ((executionReport.ExecType == ExecType.Fill || executionReport.ExecType == ExecType.Trade) && executionReport.LeavesQty > 0.0) { SingleOrder order = ((InstrumentOrderListTable)OrderManager.Orders).All[executionReport.ClOrdID] as SingleOrder; StrategyRunner strategyRunner = (StrategyRunner)null; if (this.strategies.TryGetValue(order.Strategy, out strategyRunner) && strategyRunner.Enabled) { strategyRunner.SetPartiallyFilled(order); } } if (executionReport.ExecType != ExecType.Replace) { return; } SingleOrder order1 = ((InstrumentOrderListTable)OrderManager.Orders).All[executionReport.ClOrdID] as SingleOrder; StrategyRunner strategyRunner1 = (StrategyRunner)null; if (!this.strategies.TryGetValue(order1.Strategy, out strategyRunner1) || !strategyRunner1.Enabled) { return; } strategyRunner1.SetOrderReplaced(order1); }
private int MakePackageAndReturnRest(Pack[] packs, SingleOrder o, List <SellingPack> sellingList) { var units = o.ProductUnits; int rest = 1; for (int i = 0; i < packs.Length; i++) { var packUnits = packs[i].Units; if (units < packUnits) { continue; } rest = this.AddPacksToListAndReturnRest(packs, o, sellingList, units, i, packUnits); if (rest == 0) { break; } else { units = units % packUnits; } } return(rest); }
public void SendOrderCancelRequest(FIXOrderCancelRequest request) { IOrder order = OrderManager.Orders.All[request.OrigClOrdID]; SingleOrder order2 = order as SingleOrder; Cancel(order2); }
public void SendNewOrderSingle(NewOrderSingle order) { SingleOrder key = order as SingleOrder; orderRecords.Add(key, new OrderRecord(key)); Send(key); }
protected override void OnOrderPartiallyFilled(SingleOrder order) { Instrument instrument = order.Instrument; /*---------------------------------------*/ Exit exit = this.exits[instrument]; if (exit != null) { exit.OnOrderPartiallyFilled(order); } Entry entry = this.entries[instrument]; if (entry != null) { entry.OnOrderPartiallyFilled(order); } MoneyManager moneyManager = this.moneyManagers[instrument]; if (moneyManager != null) { moneyManager.OnOrderPartiallyFilled(order); } RiskManager riskManager = this.riskManagers[instrument]; if (riskManager != null) { riskManager.OnOrderPartiallyFilled(order); } /*---------------------------------------*/ /*this.runtimeCrossEntry.OnOrderPartiallyFilled(order); * this.runtimeCrossExit.OnOrderPartiallyFilled(order); * this.entries[instrument].OnOrderPartiallyFilled(order); * this.exits[instrument].OnOrderPartiallyFilled(order);*/ }
public void InstantiatingASingleOrderWithValidDescription() { Mock.Get(this.catalogFactory).Setup(f => f.CreateCatalog()).Returns(this.catalog); var singleOrder = new SingleOrder(this.catalogFactory, "10 VS5"); Assert.IsTrue(singleOrder.ProductUnits != 0); Assert.IsTrue(!string.IsNullOrWhiteSpace(singleOrder.ProductCode)); }
internal void acOvnqFOo(SingleOrder obj0) { if (!this.isActive) { return; } this.OnNewClientOrder(obj0); }
internal void SetNewClientOrder(SingleOrder order) { if (!this.isActive) { return; } this.OnNewClientOrder(order); }
/// <summary> /// /// </summary> /// <param name="order"></param> public OrderRecord(SingleOrder order) { this.Order = order; LeavesQty = order.OrderQty; CumQty = 0; AvgPx = 0; }
public override void Add(SingleOrder order, TextCommon t) { if (Index >= GetLegNum()) return; Leg[Index] = new MultiOrderLeg { Order = order, OpenClose = t.OpenClose }; ++Index; }
public void OnNewShortExit(Instrument instrument, int Size, string sComment) { marketOrder = MarketOrder(instrument, Side.Buy, Size); //marketOrder = MarketOrder( Side.Buy, intSize ); marketOrder.Text = sComment; marketOrder.Send(); // Console.WriteLine( instrument.Symbol + " " + sComment ); }
internal static Order CreateWrapper(SingleOrder order) { return(new Order { order = order, instrument = Map.SQ_OQ_Instrument[order.Instrument] as Instrument, ibEx = new IBEx(order) }); }
public override void Add(SingleOrder order, TextCommon t) { if (order.Side == Side.Buy) { Buy = new MultiOrderLeg() { Order = order, OpenClose = t.OpenClose }; } else { Sell = new MultiOrderLeg() { Order = order, OpenClose = t.OpenClose }; } }
public CommonOrderItem Add(SingleOrder order, TextRequest t) { if(item == null || item.IsDone()) { item = new CommonOrderItem(); } item.Add(order, t); if (item.IsDone()) { return item; } return null; }
public SPOrderItem Add(SingleOrder order, TextSP t) { if (item == null || item.IsDone()) { item = new SPOrderItem(t); } item.Add(order, t); if (item.IsDone()) { return item; } return null; }
public bool OnTrade(ref SingleOrder order, ref CThostFtdcTradeField pTrade, ref double Price, ref int Volume) { #if CTP //先保存到两个队例,排序是为了配对 if (TThostFtdcDirectionType.Buy == pTrade.Direction) { qBuy.Add(pTrade); qBuy.Sort(SortCThostFtdcTradeField); } else { qSell.Add(pTrade); qSell.Sort(SortCThostFtdcTradeField); } //取已经配对好的 if (qBuy.Count > 0 && qSell.Count > 0) { // 有网友说可能成交时不成对,这地方是否改动一下 if (qBuy[0].Volume == qSell[0].Volume)//如果不等就有问题了 { Volume = qBuy[0].Volume; if (order.Side == Side.Buy) { Price = qBuy[0].Price - qSell[0].Price; } else { Price = qSell[0].Price - qBuy[0].Price; } //用完就清除 qBuy.RemoveAt(0); qSell.RemoveAt(0); return true; } } #endif return false; }
public bool OnTrade(ref SingleOrder order, ref CZQThostFtdcTradeField pTrade, ref double Price, ref int Volume) { //先保存到两个队例,排序是为了配对 //if (TZQThostFtdcDirectionType.Buy == pTrade.Direction) //{ // qBuy.Add(pTrade); // qBuy.Sort(SortCZQThostFtdcTradeField); //} //else //{ // qSell.Add(pTrade); // qSell.Sort(SortCZQThostFtdcTradeField); //} ////取已经配对好的 //if (qBuy.Count > 0 && qSell.Count > 0) //{ // if (qBuy[0].Volume == qSell[0].Volume)//如果不等就有问题了 // { // Volume = qBuy[0].Volume; // if (order.Side == Side.Buy) // { // Price = qBuy[0].Price - qSell[0].Price; // } // else // { // Price = qSell[0].Price - qBuy[0].Price; // } // //用完就清除 // qBuy.RemoveAt(0); // qSell.RemoveAt(0); // return true; // } //} return false; }
protected void EmitCancelled(SingleOrder order) { EmitExecutionReport(order, OrdStatus.Cancelled); }
protected void EmitAccepted(SingleOrder order) { EmitExecutionReport(order, OrdStatus.New); }
private void Cancel(SingleOrder order) { if (!_bTdConnected) { EmitError(-1,-1,"交易服务器没有连接,无法撤单"); return; } Dictionary<string, CThostFtdcOrderField> _Ref2Action; if (_Orders4Cancel.TryGetValue(order, out _Ref2Action)) { lock (_Ref2Action) { CThostFtdcOrderField __Order; foreach (CThostFtdcOrderField _Order in _Ref2Action.Values) { __Order = _Order; //这地方要是过滤下就好了 TraderApi.TD_CancelOrder(m_pTdApi, ref __Order); } } } }
public OrderEventArgs(SingleOrder order) { this.Order = order; }
public void EmitExecutionReport(SingleOrder order, double price, int quantity, CommType commType, double commission) { OrderRecord record = orderRecords[order]; EmitExecutionReport(record, OrdStatus.Undefined, price, quantity, "", commType, commission); }
public void EmitExecutionReport(SingleOrder order, OrdStatus status, string text) { OrderRecord record = this.orderRecords[order]; EmitExecutionReport(record, status, 0.0, 0, text); }
protected void EmitRejected(SingleOrder order, string message) { EmitExecutionReport(order, OrdStatus.Rejected, message); }
public OrderMarker(SingleOrder order) { this.order = order; }
public void EmitExecutionReport(SingleOrder order, OrdStatus status, string text) { OrderRecord record = orderRecords[order]; EmitExecutionReport(record, status, 0.0, 0, text, CommType.Absolute, 0); }
protected void EmitFilled(SingleOrder order, double price, int quantity, CommType commType, double commission) { EmitExecutionReport(order, price, quantity, commType, commission); }
protected void EmitCancelReject(SingleOrder order, OrdStatus status, string message) { OrderCancelReject reject = new OrderCancelReject { TransactTime = Clock.Now, ClOrdID = order.ClOrdID, OrigClOrdID = order.ClOrdID, OrderID = order.OrderID, CxlRejReason = CxlRejReason.BrokerOption, CxlRejResponseTo = CxlRejResponseTo.CancelRequest, OrdStatus = status }; EmitOrderCancelReject(reject); }
protected void EmitPendingCancel(SingleOrder order) { EmitExecutionReport(order, OrdStatus.PendingCancel); }
protected void EmitExpired(SingleOrder order) { EmitExecutionReport(order, OrdStatus.Expired); }
protected void EmitCancelReject(SingleOrder order, string message) { //EmitCancelReject(order, message); }
protected void EmitFilled(SingleOrder order, double price, int quantity) { EmitExecutionReport(order, price, quantity); }
private void OnLastStatus(SingleOrder order) { // 一个单子成交完成,报单组可能还没有完,这个地方一定要留意 if (!order.IsDone) return; GenericOrderItem item; if (orderMap.TryGetValue(order, out item)) { CThostFtdcOrderField _order; if (orderMap.TryGetValue(item, out _order)) { OnLastStatus(item, _order.OrderSysID, _order.OrderRef); } } }
public void EmitExecutionReport(SingleOrder order, OrdStatus status) { EmitExecutionReport(order, status, ""); }
public override void Add(SingleOrder order, TextCommon t) { Leg = new MultiOrderLeg { Order = order, OpenClose = t.OpenClose }; }
public void EmitExecutionReport(SingleOrder order, double price, int quantity) { OrderRecord record = this.orderRecords[order]; EmitExecutionReport(record, OrdStatus.Undefined, price, quantity, ""); }
public void EmitExecutionReport(SingleOrder order, double price, int quantity) { OrderRecord record = orderRecords[order]; EmitExecutionReport(record, OrdStatus.Undefined, price, quantity, "", CommType.Absolute, 0); }