create a trade order https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-trade https://developers.binance.com/docs/binance-spot-api-docs/testnet/rest-api/trading-endpoints#test-new-order-trade https://developers.binance.com
(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={})
| 6252 | return self.parse_orders(response) |
| 6253 | |
| 6254 | def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}): |
| 6255 | """ |
| 6256 | create a trade order |
| 6257 | |
| 6258 | https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#new-order-trade |
| 6259 | https://developers.binance.com/docs/binance-spot-api-docs/testnet/rest-api/trading-endpoints#test-new-order-trade |
| 6260 | https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/New-Order |
| 6261 | https://developers.binance.com/docs/derivatives/coin-margined-futures/trade/rest-api |
| 6262 | https://developers.binance.com/docs/derivatives/option/trade/New-Order |
| 6263 | https://developers.binance.com/docs/binance-spot-api-docs/rest-api/trading-endpoints#sor |
| 6264 | https://developers.binance.com/docs/binance-spot-api-docs/testnet/rest-api/trading-endpoints#sor |
| 6265 | https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-UM-Order |
| 6266 | https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-CM-Order |
| 6267 | https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-Margin-Order |
| 6268 | https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-UM-Conditional-Order |
| 6269 | https://developers.binance.com/docs/derivatives/portfolio-margin/trade/New-CM-Conditional-Order |
| 6270 | https://developers.binance.com/docs/derivatives/usds-margined-futures/trade/rest-api/New-Algo-Order |
| 6271 | |
| 6272 | :param str symbol: unified symbol of the market to create an order in |
| 6273 | :param str type: 'market' or 'limit' or 'STOP_LOSS' or 'STOP_LOSS_LIMIT' or 'TAKE_PROFIT' or 'TAKE_PROFIT_LIMIT' or 'STOP' |
| 6274 | :param str side: 'buy' or 'sell' |
| 6275 | :param float amount: how much of you want to trade in units of the base currency |
| 6276 | :param float [price]: the price that the order is to be fulfilled, in units of the quote currency, ignored in market orders |
| 6277 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 6278 | :param str [params.reduceOnly]: for swap and future reduceOnly is a string 'true' or 'false' that cant be sent with close position set to True or in hedge mode. For spot margin and option reduceOnly is a boolean. |
| 6279 | :param str [params.marginMode]: 'cross' or 'isolated', for spot margin trading |
| 6280 | :param boolean [params.sor]: *spot only* whether to use SOR(Smart Order Routing) or not, default is False |
| 6281 | :param boolean [params.test]: *spot only* whether to use the test endpoint or not, default is False |
| 6282 | :param float [params.trailingPercent]: the percent to trail away from the current market price |
| 6283 | :param float [params.trailingTriggerPrice]: the price to trigger a trailing order, default uses the price argument |
| 6284 | :param float [params.triggerPrice]: the price that a trigger order is triggered at |
| 6285 | :param float [params.stopLossPrice]: the price that a stop loss order is triggered at |
| 6286 | :param float [params.takeProfitPrice]: the price that a take profit order is triggered at |
| 6287 | :param boolean [params.portfolioMargin]: set to True if you would like to create an order in a portfolio margin account |
| 6288 | :param str [params.selfTradePrevention]: set unified value for stp, one of NONE, EXPIRE_MAKER, EXPIRE_TAKER or EXPIRE_BOTH |
| 6289 | :param float [params.icebergAmount]: set iceberg amount for limit orders |
| 6290 | :param str [params.stopLossOrTakeProfit]: 'stopLoss' or 'takeProfit', required for spot trailing orders |
| 6291 | :param str [params.positionSide]: *swap and portfolio margin only* "BOTH" for one-way mode, "LONG" for buy side of hedged mode, "SHORT" for sell side of hedged mode |
| 6292 | :param bool [params.hedged]: *swap and portfolio margin only* True for hedged mode, False for one way mode, default is False |
| 6293 | :param str [params.clientOrderId]: the clientOrderId of the order |
| 6294 | :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>` |
| 6295 | """ |
| 6296 | self.load_markets() |
| 6297 | market = self.market(symbol) |
| 6298 | # don't handle/omit params here, omitting happens inside createOrderRequest |
| 6299 | marketType = self.safe_string(params, 'type', market['type']) |
| 6300 | marginMode = self.safe_string(params, 'marginMode') |
| 6301 | porfolioOptionsValue = self.safe_bool_2(self.options, 'papi', 'portfolioMargin', False) |
| 6302 | isPortfolioMargin = self.safe_bool_2(params, 'papi', 'portfolioMargin', porfolioOptionsValue) |
| 6303 | triggerPrice = self.safe_string_2(params, 'triggerPrice', 'stopPrice') |
| 6304 | stopLossPrice = self.safe_string(params, 'stopLossPrice') |
| 6305 | takeProfitPrice = self.safe_string(params, 'takeProfitPrice') |
| 6306 | trailingPercent = self.safe_string_2(params, 'trailingPercent', 'callbackRate') |
| 6307 | isTrailingPercentOrder = trailingPercent is not None |
| 6308 | isStopLoss = stopLossPrice is not None |
| 6309 | isTakeProfit = takeProfitPrice is not None |
| 6310 | isConditional = (triggerPrice is not None) or isTrailingPercentOrder or isStopLoss or isTakeProfit |
| 6311 | sor = self.safe_bool_2(params, 'sor', 'SOR', False) |
no test coverage detected