/// <summary> /// Cancel all orders for given pair /// </summary> /// <param name="base_name">The type of trading base-currency of which information you want to query for.</param> /// <param name="quote_name">The type of trading quote-currency of which information you want to query for.</param> /// <param name="order_ids"></param> /// <param name="args">Add additional attributes for each exchange</param> /// <returns></returns> public override async Task <MyOrders> CancelOrders(string base_name, string quote_name, string[] order_ids, Dictionary <string, object> args = null) { var _result = new MyOrders(base_name, quote_name); var _market = await publicApi.LoadMarket(_result.marketId); if (_market.success == true) { tradeClient.ExchangeInfo.ApiCallWait(TradeType.Trade); var _params = tradeClient.MergeParamsAndArgs(args); var _json_value = await tradeClient.CallApiPost1Async($"/cancel_orders/{_market.result.symbol}", _params); #if DEBUG _result.rawJson = _json_value.Content; #endif var _json_result = tradeClient.GetResponseMessage(_json_value.Response); if (_json_result.success == true) { var _json_data = tradeClient.DeserializeObject <CCancelOrders>(_json_value.Content); { foreach (var _o in _json_data.result) { var _order = new CMyOrderItem { orderId = _o.orderId, symbol = _market.result.symbol, timestamp = CUnixTime.NowMilli, orderStatus = _json_data.message == "ok" ? OrderStatus.Canceled : OrderStatus.Unknown, orderType = OrderType.Limit }; _result.result.Add(_order); } } } _result.SetResult(_json_result); } else { _result.SetResult(_market); } return(_result); }
/// <summary> /// Cancel order /// </summary> /// <param name="base_name">The type of trading base-currency of which information you want to query for.</param> /// <param name="quote_name">The type of trading quote-currency of which information you want to query for.</param> /// <param name="order_id">Order number registered for sale or purchase</param> /// <param name="quantity">amount of coin</param> /// <param name="price">price of coin</param> /// <param name="sideType">type of buy(bid) or sell(ask)</param> /// <param name="args">Add additional attributes for each exchange</param> /// <returns></returns> public override async Task <MyOrder> CancelOrder(string base_name, string quote_name, string order_id, decimal quantity, decimal price, SideType sideType, Dictionary <string, object> args = null) { var _result = new MyOrder(base_name, quote_name); var _market = await publicApi.LoadMarket(_result.marketId); if (_market.success == true) { tradeClient.ExchangeInfo.ApiCallWait(TradeType.Trade); var _params = new Dictionary <string, object>(); { _params.Add("id", Convert.ToInt64(order_id)); tradeClient.MergeParamsAndArgs(_params, args); } var _json_value = await tradeClient.CallApiPost1Async($"/cancel_order/", _params); #if DEBUG _result.rawJson = _json_value.Content; #endif var _json_result = tradeClient.GetResponseMessage(_json_value.Response); if (_json_result.success == true) { var _json_data = tradeClient.DeserializeObject <bool>(_json_value.Content); { if (_json_data == true) { var _order = new CMyOrderItem { symbol = _market.result.symbol, orderId = order_id, orderType = OrderType.Limit, orderStatus = OrderStatus.Canceled, sideType = sideType, quantity = quantity, price = price, amount = quantity * price, //fee = quantity * price * publicApi.ExchangeInfo.Fees.trading.maker, timestamp = CUnixTime.NowMilli }; _result.result = _order; } else { _json_result.SetFailure(); } } } _result.SetResult(_json_result); } else { _result.SetResult(_market); } return(_result); }