The exchange.CancelOrder()
function is used to cancel the order.
The attribute Id
of the order {@struct/Order Order} structure of the FMZ platform consists of the exchange product code and the exchange original order ID, separated by English commas. For example, the attribute Id
format of the order of the spot trading pair ETH_USDT
of the OKX exchange is: ETH-USDT,1547130415509278720
.
The parameter orderId
passed in when calling the exchange.CancelOrder()
function to cancel an order is consistent with the Id
property of the order {@struct/Order Order} structure.
The exchange.CancelOrder()
function returns a true value, for example true
means that the cancel order request was sent successfully. If it returns a false value, such as false
, means that the cancel order request failed to be sent. The return value only represents the success or failure of the request sent to determine whether the exchange cancels the order. You can call exchange.GetOrders()
to determine if the order is cancelled.
bool
exchange.CancelOrder(orderId) exchange.CancelOrder(orderId, …args)
The orderId
parameter is used to specify the order to be cancelled.
orderId
true
number, string
Extended parameters, you can output the attached information to this withdrawal log, arg
parameters can be passed more than one.
arg
false
string, number, bool, object, array, null and any other type supported by the system
function main(){
var id = exchange.Sell(99999, 1)
exchange.CancelOrder(id)
}
def main():
id = exchange.Sell(99999, 1)
exchange.CancelOrder(id)
void main() {
auto id = exchange.Sell(99999, 1);
exchange.CancelOrder(id);
}
Cancel the order.
function main() {
if (exchange.GetName().includes("Futures_")) {
Log("Set the contract as: perpetual contract, set the trade direction as: open long position.")
exchange.SetContractType("swap")
exchange.SetDirection("buy")
}
var ticker = exchange.GetTicker()
exchange.Buy(ticker.Last * 0.5, 0.1)
var orders = exchange.GetOrders()
for (var i = 0 ; i < orders.length ; i++) {
exchange.CancelOrder(orders[i].Id, "Cancelled orders:", orders[i])
Sleep(500)
}
}
def main():
if exchange.GetName().find("Futures_") != -1:
Log("Set the contract as: perpetual contract, set the trade direction as: open long position.")
exchange.SetContractType("swap")
exchange.SetDirection("buy")
ticker = exchange.GetTicker()
exchange.Buy(ticker["Last"] * 0.5, 0.1)
orders = exchange.GetOrders()
for i in range(len(orders)):
exchange.CancelOrder(orders[i]["Id"], "Cancelled orders:", orders[i])
Sleep(500)
void main() {
if (exchange.GetName().find("Futures_") != std::string::npos) {
Log("Set the contract as: perpetual contract, set the trade direction as: open long position.");
exchange.SetContractType("swap");
exchange.SetDirection("buy");
}
auto ticker = exchange.GetTicker();
exchange.Buy(ticker.Last * 0.5, 0.1);
auto orders = exchange.GetOrders();
for (int i = 0 ; i < orders.size() ; i++) {
exchange.CancelOrder(orders[i].Id, "Cancelled orders:", orders[i]);
Sleep(500);
}
}
FMZ API functions that can produce log output functions such as: Log()
, exchange.Buy()
, exchange.CancelOrder()
can be followed by some accompanying output parameters after the necessary parameters. For example: exchange.CancelOrder(orders[i].Id, orders[i])
, so that when canceling the order whose Id is orders[i].Id
, the order’s information is output with it. That is, the {@struct/Order Order} structure of orders[i]
.
If you are using an older version of the docker, the orderId parameter of the exchange.CancelOrder() function may be different from the orderId described in the current document.
{@fun/Trade/exchange.Buy exchange.Buy}, {@fun/Trade/exchange.Sell exchange.Sell}, {@fun/Trade/exchange.GetOrders exchange.GetOrders}
exchange.CreateOrder exchange.GetOrder