void tl_newOrderCancelRequest(long number) { int orderid = Convert.ToInt32(number); if (orderid == 0) { return; } if (!socketOrderServer.sitemOrder.sordermap.ContainsKey(Convert.ToInt32(number))) { return; } itemOrder porder = socketOrderServer.sitemOrder.sordermap[orderid]; if (!porder.IsOpenOrder()) { return; } if (porder.mlvsqty > 0) { iManager im = new iManager(socketOrderServer); im.Send_CancelOrder(porder, 0); tl.newCancel(number); } }
void tl_newOrderCancelRequest(long number) { int orderid = Convert.ToInt32(number); if (orderid == 0) { v("ignoring cancel for invalid id: 0"); return; } if (!socketOrderServer.sitemOrder.sordermap.ContainsKey(Convert.ToInt32(number))) { v("ignoring cancel for unknown order: " + number); return; } itemOrder porder = socketOrderServer.sitemOrder.sordermap[orderid]; if (!porder.IsOpenOrder()) { v("ignoring cancel for closed order, tlid: " + number + " sym: " + porder.msecsym + " ord: " + porder.ToString()); return; } if (porder.mlvsqty > 0) { try { iManager im = new iManager(socketOrderServer); im.Send_CancelOrder(porder, 0); v("requested cancel for: " + number + " sym: " + porder.msecsym + " ord: " + porder.ToString()); } catch (Exception ex) { debug("DAS error canceling order: " + number + " err: " + ex.Message + ex.StackTrace); } tl.newCancel(number); } else { v("ignoring cancel for order with zero size, tlid: " + number + " sym: " + porder.msecsym + " ord: " + porder.ToString()); } }
void SimBroker_GotOrderCancel(string sym, bool side, long id) { // if we get an order cancel notify from the broker, pass along to our clients tl.newCancel(id); // send the updated book to our clients for same side as order Tick book = OrderToTick(SimBroker.BestBidOrOffer(sym, side)); tl.newTick(book); }
void bwOrder_BWOrderUpdateEvent(object sender, BWOrderStatus BWOrderStatus) { BWOrder bwo = (BWOrder)sender; long id = (long)bwo.CustomID; Order o = new OrderImpl(bwo.Symbol, (int)bwo.Size); o.id = (long)bwo.CustomID; o.side = (bwo.OrderSide == ORDER_SIDE.SIDE_BUY) || (bwo.OrderSide == ORDER_SIDE.SIDE_COVER); o.price = (decimal)bwo.LimitPrice; o.stopp = (decimal)bwo.StopPrice; o.Account = bwo.UserID.ToString(); o.ex = bwo.Venue.ToString(); switch (BWOrderStatus) { case BWOrderStatus.ACCEPTED: { tl.newOrder(o); v(o.symbol + " sent order acknowledgement for: " + o.ToString()); if (_bwOrdIds.ContainsKey(o.id)) { _bwOrdIds[o.id] = bwo.OrderID; } } break; case BWOrderStatus.CANCELED: { tl.newCancel(id); v("sent cancel notification for order: " + id); } break; case BWOrderStatus.REJECTED: { tl.newCancel(id); debug("Rejected: " + bwo.CustomID.ToString() + bwo.RejectReason); } break; } }
void tl_newOrderCancelRequest(long number) { string result = "error"; long id; string orderid = ""; if (idmap.TryGetValue(number, out id)) { orderid = id.ToString(); } api.TD_CancelOrder(api._accountid, orderid, _user.Text, _pass.Text, AmeritradeBrokerAPI.SOURCEID, APIVER, ref result); if (result == string.Empty) { tl.newCancel(number); } }
void doorderupdate(ref structSTIOrderUpdate structOrderUpdate) { Order o = new OrderImpl(); o.symbol = structOrderUpdate.bstrSymbol; long id = 0; // see if the order id is unknown if (!long.TryParse(structOrderUpdate.bstrClOrderId, out id)) { // use the norderrecordid as our order id id = (long)structOrderUpdate.nOrderRecordId; // ensure this is not a secondary notification of same order string tmp; if (!idacct.TryGetValue(id, out tmp)) { // save the id debug("manual order: " + id + " " + structOrderUpdate.bstrAccount); idacct.Add(id, structOrderUpdate.bstrAccount); ismanorder.Add(id, true); } } // if this is a cancel notification, pass along if (structOrderUpdate.nOrderStatus == (int)STIOrderStatus.osSTICanceled) { // if it's a cancel, we'll have cancel id rather than order id // get new id long orderid = 0; if (_cancel2order.TryGetValue(id, out orderid)) { tl.newCancel(orderid); if (VerboseDebugging) { debug("cancel received for: " + orderid); } } else { debug("manual cancel sent with id: " + id); } return; } // don't notify for same order more than once if (_onotified.Contains(id)) { return; } if (structOrderUpdate.bstrLogMessage.Contains("REJ")) { debug(id + " " + structOrderUpdate.bstrLogMessage); } o.id = id; o.size = structOrderUpdate.nQuantity; o.side = structOrderUpdate.bstrSide == "B"; o.price = (decimal)structOrderUpdate.fLmtPrice; o.stopp = (decimal)structOrderUpdate.fStpPrice; o.TIF = structOrderUpdate.bstrTif; o.Account = structOrderUpdate.bstrAccount; o.ex = structOrderUpdate.bstrDestination; long now = Convert.ToInt64(structOrderUpdate.bstrUpdateTime); int xsec = (int)(now % 100); long rem = (now - xsec) / 100; o.time = ((int)(rem % 10000)) * 100 + xsec; o.date = (int)((rem - o.time) / 10000); _onotified.Add(o.id); if (VerboseDebugging) { debug("order acknowledgement: " + o.ToString()); } tl.newOrder(o); }