private static Email AddOrderCancellationInEmail(Email email) { var orderCancellation = new OrderCancellation(); email.Content.Add(orderCancellation); return(email); }
public void OnNext(InputPayload data, long sequence, bool endOfBatch) { if (!data.IsOrder) { _cancellation = data.OrderCancellation; _manualResetEvent.Set(); } }
public void PublishCancelOrder_IfCancelOrderIsAddedInPayload_ReceiveCancelOrderInPayloadInConsumer() { _counter = 1;//as sending only one message OrderCancellation cancelOrder = new OrderCancellation(new OrderId("123"), new TraderId("123"), "XBTUSD"); InputPayload payload = InputPayload.CreatePayload(cancelOrder); InputDisruptorPublisher.Publish(payload); _manualResetEvent.WaitOne(2000); Assert.AreEqual(payload.OrderCancellation, cancelOrder); }
/// <summary> /// Receives new order and cancel order requests from disruptor /// </summary> /// <param name="data"></param> /// <param name="sequence"></param> /// <param name="endOfBatch"></param> public void OnNext(InputPayload data, long sequence, bool endOfBatch) { if (data.IsOrder) { Order order = new Order(); data.Order.MemberWiseClone(order); PlaceNewOrder(order); } else { OrderCancellation cancellation = new OrderCancellation(); data.OrderCancellation.MemberWiseClone(cancellation); CancelOrder(cancellation); } }
/// <summary> /// Cancel the order with the given orderId /// </summary> /// <param name="orderCancellation"> </param> /// <returns></returns> public bool CancelOrder(OrderCancellation orderCancellation) { switch (orderCancellation.CurrencyPair) { case CurrencyConstants.BtcLtc: return(_exchangeEssentialsList.First().LimitOrderBook.CancelOrder(orderCancellation.OrderId)); case CurrencyConstants.XbtLtc: return(_exchangeEssentialsList.ToList()[1].LimitOrderBook.CancelOrder(orderCancellation.OrderId)); case CurrencyConstants.BtcLtcSeparated: return(_exchangeEssentialsList.ToList()[2].LimitOrderBook.CancelOrder(orderCancellation.OrderId)); case CurrencyConstants.XbtLtcSeparated: return(_exchangeEssentialsList.ToList()[3].LimitOrderBook.CancelOrder(orderCancellation.OrderId)); } return(false); }
public CancelOrderResponse CancelOrder(CancelOrderCommand cancelOrderCommand) { try { // Verify cancel order command if (_commandValidationService.ValidateCancelOrderCommand(cancelOrderCommand)) { string currencyPair = _commandValidationService.GetCurrencyPair(cancelOrderCommand.OrderId); OrderCancellation cancellation = new OrderCancellation(cancelOrderCommand.OrderId, cancelOrderCommand.TraderId, currencyPair); InputDisruptorPublisher.Publish(InputPayload.CreatePayload(cancellation)); return(new CancelOrderResponse(true, "Cancel Request Accepted")); } return(new CancelOrderResponse(false, new InvalidDataException("Invalid orderid").ToString())); } catch (Exception exception) { return(new CancelOrderResponse(false, exception.Message)); } }
/// <summary> /// Validates the cancellation data /// Sends a cancellation message for a specific order (id should already exist) to Riskified server for status and charge fees update /// </summary> /// <param name="orderCancellation"></param> /// <returns>The order notification result containing status,description and sent order id in case of successful transfer</returns> /// <exception cref="OrderFieldBadFormatException">On bad format of the order (missing fields data or invalid data)</exception> /// <exception cref="RiskifiedTransactionException">On errors with the transaction itself (network errors, bad response data)</exception> public OrderNotification Cancel(OrderCancellation orderCancellation) { return(SendOrder(orderCancellation, HttpUtils.BuildUrl(_env, "/api/cancel"))); }
/// <summary> /// Validates the cancellation data /// Sends a cancellation message for a specific order (id should already exist) to Riskified server for status and charge fees update /// </summary> /// <param name="orderCancellation"></param> /// <returns>The order notification result containing status,description and sent order id in case of successful transfer</returns> /// <exception cref="OrderFieldBadFormatException">On bad format of the order (missing fields data or invalid data)</exception> /// <exception cref="RiskifiedTransactionException">On errors with the transaction itself (network errors, bad response data)</exception> public OrderNotification Cancel(OrderCancellation orderCancellation) { return(SendOrder(orderCancellation, HttpUtils.BuildUrl(_riskifiedBaseWebhookUrl, "/api/cancel"))); }