资源加载中... loading...

exchange.CreateOrder

The exchange.CreateOrder() function is used to place an order.

If the order is successfully placed, the order ID is returned; if the order fails, a null value is returned. 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. When calling the exchange.CreateOrder(symbol, side, price, amount) function to place an order, the return value of the order Id is consistent with the Id property of the order {@struct/Order Order} structure. string, null value

exchange.CreateOrder(symbol, side, price, amount) exchange.CreateOrder(symbol, side, price, amount, …args)

The parameter symbol is used to specify the specific trading pair and contract code of the order. When calling the exchange.CreateOrder(symbol, side, price, amount) function to place an order, exchange is the spot exchange object. If the order denominated currency is USDT and the tranding currency is BTC, the parameter symbol is: "BTC_USDT", in the format of the trading pair defined by the FMZ platform. When calling the exchange.CreateOrder(symbol, side, price, amount) function to place an order, exchange is the futures exchange object. If the order is a BTC’s U-standard perpetual contract order, the parameter symbol is: "BTC_USDT.swap", and the format is a combination of the trading pair and contract code defined by the FMZ platform, separated by the character “.”. When calling the exchange.CreateOrder(symbol, side, price, amount) function to place an order, exchange is the futures exchange object. If the order is a BTC’s U-standard option contract order, the parameter symbol is: "BTC_USDT.BTC-240108-40000-C" (taking Binance Option BTC-240108-40000-C as an example), and the format is a combination of the trading pair defined by the FMZ platform and the specific option contract code defined by the exchange, separated by the character “.”. symbol true string The side parameter is used to specify the trading direction of the order. For spot exchange objects, the optional values of the side parameter are: buy, sell. buy means buying, and sell means selling. For futures exchange objects, the optional values of the side parameter are: buy, closebuy, sell, closesell. buy means opening a long position, closebuy means closing a long position, sell means opening a short position, and closesell means closing a short position.

side true string The parameter price is used to set the price of the order. A price of -1 indicates that the order is a market order. price true number The parameter amount is used to set the order quantity. Please note that when the order is a market buy order, the order quantity is the purchase amount; the order quantity of the market buy order of some spot exchanges is the number of trading coins. For details, please refer to the Special Instructions for Exchanges in the “User Guide”. amount true number Extended parameters can output additional information to this order log. Multiple arg parameters can be passed. arg false Any type supported by the system, such as string, number, bool, object, array, null value, etc.

function main() {
    var id = exchange.CreateOrder("BTC_USDT", "buy", 60000, 0.01)           // Spot exchange objects place orders for currency-to-currency transactions BTC_USDT trading pairs
    // var id = exchange.CreateOrder("BTC_USDT.swap", "buy", 60000, 0.01)   // Futures exchange objects place orders for BTC's U-standard perpetual contracts
    Log("Order Id:", id)
}
def main():
    id = exchange.CreateOrder("BTC_USDT", "buy", 60000, 0.01)          # Spot exchange objects place orders for currency-to-currency transactions BTC_USDT trading pairs
    # id = exchange.CreateOrder("BTC_USDT.swap", "buy", 60000, 0.01)   # Futures exchange objects place orders for BTC's U-standard perpetual contracts
    Log("Order Id:", id)
void main() {
    auto id = exchange.CreateOrder("BTC_USDT", "buy", 60000, 0.01);           // Spot exchange objects place orders for currency-to-currency transactions BTC_USDT trading pairs
    // auto id = exchange.CreateOrder("BTC_USDT.swap", "buy", 60000, 0.01);   // Futures exchange objects place orders for BTC's U-standard perpetual contracts
    Log("Order Id:", id);
}

Spot exchange objects and futures exchange objects call the exchange.CreateOrder() function to place an order.

{@fun/Trade/exchange.Buy exchange.Buy}, {@fun/Trade/exchange.Sell exchange.Sell}

exchange.Sell exchange.CancelOrder