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

Method create_order_request

python/ccxt/async_support/pacifica.py:1278–1369  ·  view source on GitHub ↗

@ignore create a trade order https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-limit-order https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-market-order https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-st

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

Source from the content-addressed store, hash-verified

1276 return self.safe_order({'id': orderId, 'status': status, 'info': response, 'symbol': symbol})
1277
1278 def create_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}) -> list:
1279 """
1280 @ignore
1281 create a trade order
1282 https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-limit-order
1283 https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-market-order
1284 https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-stop-order
1285 https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-position-tp-sl
1286 :param str symbol: unified symbol of the market to create an order in
1287 :param str type: 'market' or 'limit'
1288 :param str side: 'buy' or 'sell'
1289 :param float amount: how much of currency you want to trade in units of base currency
1290 :param float [price]: the price at which the order is to be fullfilled, in units of the quote currency, ignored in market orders, but can be used of Trigger Order.
1291 :param dict [params]: extra parameters specific to the exchange API endpoint
1292 :param float [params.triggerPrice]: The price a trigger order is triggered at
1293 :param float [params.stopLossPrice]: the price that a stop loss order is triggered at(optional provide stopLossCloid)
1294 :param float [params.takeProfitPrice]: the price that a take profit order is triggered at(optional provide takeProfitCloid)
1295 :param str [params.timeInForce]: "GTC", "IOC", or "PO" or "ALO" or "PO_TOB"(or "TOB" - PO by top of book)
1296 :param boolean [params.reduceOnly]: Ensures that the executed order does not flip the opened position.
1297 :param str [params.clientOrderId]: client order id,(optional uuid v4 e.g.: f47ac10b-58cc-4372-a567-0e02b2c3d479)
1298 :param int [params.expiryWindow]: time to live in milliseconds
1299 :returns dict: an [order structure]
1300 """
1301 market = self.market(symbol)
1302 sigPayload = {
1303 'symbol': market['id'],
1304 'side': self.map_side(side),
1305 }
1306 operationType = None
1307 reduceOnly = self.safe_bool_2(params, 'reduceOnly', 'reduce_only', False)
1308 orderType = type.upper()
1309 triggerPrice = self.safe_string(params, 'triggerPrice')
1310 stopLossPrice = self.safe_string(params, 'stopLossPrice')
1311 takeProfitPrice = self.safe_string(params, 'takeProfitPrice')
1312 tifRaw = self.safe_string_upper(params, 'timeInForce')
1313 isMarket = orderType == 'MARKET'
1314 isTakeProfitOrder = (takeProfitPrice is not None)
1315 isStopLossOrder = (stopLossPrice is not None)
1316 isStopOrder = (triggerPrice is not None)
1317 timeInForce = self.map_time_in_force(tifRaw)
1318 if isMarket:
1319 operationType = 'create_market_order'
1320 sigPayload['reduce_only'] = reduceOnly
1321 defaultSlippage = self.handle_option('createOrder', 'defaultSlippage', '0.5')
1322 slippage = self.safe_string_2(params, 'slippage', 'slippage_percent', defaultSlippage)
1323 sigPayload['slippage_percent'] = slippage
1324 elif (isTakeProfitOrder or isStopLossOrder) and (price is None): # the tpsl endpoint does not accept a 'price' parameter
1325 operationType = 'set_position_tpsl'
1326 elif isStopOrder:
1327 operationType = 'create_stop_order'
1328 sigPayload['reduce_only'] = reduceOnly
1329 stopClientOrderId = self.safe_string(params, 'clientOrderId')
1330 params = self.omit(params, ['clientOrderId'])
1331 stopPayload = {
1332 'amount': self.amount_to_precision(symbol, amount),
1333 'stop_price': self.price_to_precision(symbol, triggerPrice),
1334 }
1335 if stopClientOrderId is not None:

Callers 3

create_orderMethod · 0.95
create_orders_requestMethod · 0.95
create_order_wsMethod · 0.95

Calls 13

map_sideMethod · 0.95
map_time_in_forceMethod · 0.95
post_action_requestMethod · 0.95
safe_bool_2Method · 0.80
safe_stringMethod · 0.80
safe_string_upperMethod · 0.80
handle_optionMethod · 0.80
safe_string_2Method · 0.80
safe_string_nMethod · 0.80
marketMethod · 0.45
omitMethod · 0.45
amount_to_precisionMethod · 0.45

Tested by

no test coverage detected