MCPcopy Create free account
hub / github.com/ccxt/ccxt / create_order

Method create_order

python/ccxt/bydfi.py:1121–1185  ·  view source on GitHub ↗

create a trade order https://developers.bydfi.com/en/futures/trade#placing-an-order :param str symbol: unified symbol of the market to create an order in :param str type: 'market' or 'limit' :param str side: 'buy' or 'sell' :param float amount: how

(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={})

Source from the content-addressed store, hash-verified

1119 }
1120
1121 def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}) -> Order:
1122 """
1123 create a trade order
1124
1125 https://developers.bydfi.com/en/futures/trade#placing-an-order
1126
1127 :param str symbol: unified symbol of the market to create an order in
1128 :param str type: 'market' or 'limit'
1129 :param str side: 'buy' or 'sell'
1130 :param float amount: how much of currency you want to trade in units of base currency
1131 :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders
1132 :param dict [params]: extra parameters specific to the exchange API endpoint
1133 :param str [params.wallet]: The unique code of a sub-wallet. W001 is the default wallet and the main wallet code of the contract
1134 :param bool [params.hedged]: True for hedged mode, False for one way mode, default is False
1135 :param str [params.clientOrderId]: Custom order ID, must be unique for open orders
1136 :param str [params.timeInForce]: 'GTC'(Good Till Cancelled), 'FOK'(Fill Or Kill), 'IOC'(Immediate Or Cancel), 'PO'(Post Only)
1137 :param bool [params.postOnly]: True or False, whether the order is post-only
1138 :param bool [params.reduceOnly]: True or False, True or False whether the order is reduce-only
1139 :param float [params.stopLossPrice]: The price a stop loss order is triggered at
1140 :param float [params.takeProfitPrice]: The price a take profit order is triggered at
1141 :param float [params.trailingTriggerPrice]: the price to activate a trailing order, default uses the price argument or market price if price is not provided
1142 :param float [params.trailingPercent]: the percent to trail away from the current market price
1143 :param str [params.triggerPriceType]: 'MARK_PRICE' or 'CONTRACT_PRICE', default is 'CONTRACT_PRICE', the price type used to trigger stop orders
1144 :param bool [params.closePosition]: True or False, whether to close all positions after triggering, only supported in STOP_MARKET and TAKE_PROFIT_MARKET; not used with quantity
1145 :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
1146 """
1147 self.load_markets()
1148 market = self.market(symbol)
1149 orderRequest = self.create_order_request(symbol, type, side, amount, price, params)
1150 wallet = 'W001'
1151 wallet, params = self.handle_option_and_params(params, 'createOrder', 'wallet', wallet)
1152 orderRequest = self.extend(orderRequest, {'wallet': wallet})
1153 response = self.privatePostV1FapiTradePlaceOrder(orderRequest)
1154 #
1155 # {
1156 # "code": 200,
1157 # "message": "success",
1158 # "data": {
1159 # "wallet": "W001",
1160 # "symbol": "ETH-USDT",
1161 # "orderId": "7408875768086683648",
1162 # "clientOrderId": "7408875768086683648",
1163 # "price": "1000",
1164 # "origQty": "10",
1165 # "avgPrice": null,
1166 # "executedQty": "0",
1167 # "orderType": "LIMIT",
1168 # "side": "BUY",
1169 # "status": "NEW",
1170 # "stopPrice": null,
1171 # "activatePrice": null,
1172 # "timeInForce": null,
1173 # "workingType": "CONTRACT_PRICE",
1174 # "positionSide": "BOTH",
1175 # "priceProtect": False,
1176 # "reduceOnly": False,
1177 # "closePosition": False,
1178 # "createTime": "1766413633367",

Callers

nothing calls this directly

Calls 8

create_order_requestMethod · 0.95
parse_orderMethod · 0.95
safe_dictMethod · 0.80
load_marketsMethod · 0.45
marketMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected