cancelOrder method
Will ask to cancel a given order.
API Key required : yes (+ signature)
Query weight : 1
Returns a BinanceOrderStatus
containing all returned data when request is a success.
Throws a BinanceApiError if an error occurs.
Other info from docs:
- Either orderId or origClientOrderId must be sent.
Implementation
Future<BinanceOrderStatus> cancelOrder({
String baseUri = defaultUri,
required String symbol,
int? orderId,
String? origClientOrderId,
/// Used to uniquely identify this cancel. Automatically generated by default.
String? newClientOrderId,
int recvWindow = 5000,
}) async {
if (null == orderId && null == origClientOrderId) {
throw ArgumentError('Either orderId or origClientOrderId must be sent.');
}
final queryParameters = {
'symbol': symbol,
'recvWindow': '$recvWindow',
};
if (null != orderId) {
queryParameters['orderId'] = '$orderId';
}
if (null != origClientOrderId) {
queryParameters['origClientOrderId'] = origClientOrderId;
}
if (null != newClientOrderId) {
queryParameters['newClientOrderId'] = newClientOrderId;
}
return BinanceOrderStatus.fromJson(await sendRequest(
baseUri,
tradeOrderPath,
queryParameters: queryParameters,
requestMethod: RequestMethod.delete,
withSignature: true,
));
}