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

Method createOrderRequest

js/src/pacifica.js:1318–1427  ·  view source on GitHub ↗
(symbol, type, side, amount, price = undefined, params = {})

Source from the content-addressed store, hash-verified

1316 return this.safeOrder({ 'id': orderId, 'status': status, 'info': response, 'symbol': symbol });
1317 }
1318 createOrderRequest(symbol, type, side, amount, price = undefined, params = {}) {
1319 /**
1320 * @method
1321 * @ignore
1322 * @name pacifica#createOrderRequest
1323 * @description create a trade order
1324 * @see https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-limit-order
1325 * @see https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-market-order
1326 * @see https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-stop-order
1327 * @see https://docs.pacifica.fi/api-documentation/api/rest-api/orders/create-position-tp-sl
1328 * @param {string} symbol unified symbol of the market to create an order in
1329 * @param {string} type 'market' or 'limit'
1330 * @param {string} side 'buy' or 'sell'
1331 * @param {float} amount how much of currency you want to trade in units of base currency
1332 * @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 as limit_price of Trigger Order.
1333 * @param {object} [params] extra parameters specific to the exchange API endpoint
1334 * @param {float} [params.triggerPrice] The price a trigger order is triggered at
1335 * @param {float} [params.stopLossPrice] the price that a stop loss order is triggered at (optional provide stopLossCloid)
1336 * @param {float} [params.takeProfitPrice] the price that a take profit order is triggered at (optional provide takeProfitCloid)
1337 * @param {string} [params.timeInForce] "GTC", "IOC", or "PO" or "ALO" or "PO_TOB" (or "TOB" - PO by top of book)
1338 * @param {boolean} [params.reduceOnly] Ensures that the executed order does not flip the opened position.
1339 * @param {string} [params.clientOrderId] client order id, (optional uuid v4 e.g.: f47ac10b-58cc-4372-a567-0e02b2c3d479)
1340 * @param {int} [params.expiryWindow] time to live in milliseconds
1341 * @returns {object} an [order structure]
1342 */
1343 const market = this.market(symbol);
1344 const sigPayload = {
1345 'symbol': market['id'],
1346 'side': this.mapSide(side),
1347 };
1348 let operationType = undefined;
1349 const reduceOnly = this.safeBool2(params, 'reduceOnly', 'reduce_only', false);
1350 const orderType = type.toUpperCase();
1351 const triggerPrice = this.safeString(params, 'triggerPrice');
1352 const stopLossPrice = this.safeString(params, 'stopLossPrice');
1353 const takeProfitPrice = this.safeString(params, 'takeProfitPrice');
1354 const tifRaw = this.safeStringUpper(params, 'timeInForce');
1355 const isMarket = orderType === 'MARKET';
1356 const isTakeProfitOrder = (takeProfitPrice !== undefined);
1357 const isStopLossOrder = (stopLossPrice !== undefined);
1358 const isStopOrder = (triggerPrice !== undefined);
1359 const timeInForce = this.mapTimeInForce(tifRaw);
1360 if (isMarket) {
1361 operationType = 'create_market_order';
1362 sigPayload['reduce_only'] = reduceOnly;
1363 const defaultSlippage = this.handleOption('createOrder', 'defaultSlippage', '0.5');
1364 const slippage = this.safeString2(params, 'slippage', 'slippage_percent', defaultSlippage);
1365 sigPayload['slippage_percent'] = slippage;
1366 }
1367 else if ((isTakeProfitOrder || isStopLossOrder) && (price === undefined)) { // the tpsl endpoint does not accept a 'price' parameter
1368 operationType = 'set_position_tpsl';
1369 }
1370 else if (isStopOrder) {
1371 operationType = 'create_stop_order';
1372 sigPayload['reduce_only'] = reduceOnly;
1373 const stopClientOrderId = this.safeString(params, 'clientOrderId');
1374 params = this.omit(params, ['clientOrderId']);
1375 const stopPayload = {

Callers 3

createOrderMethod · 0.95
createOrdersRequestMethod · 0.95
createOrderWsMethod · 0.95

Calls 13

mapSideMethod · 0.95
mapTimeInForceMethod · 0.95
postActionRequestMethod · 0.95
marketMethod · 0.45
safeBool2Method · 0.45
safeStringMethod · 0.45
safeStringUpperMethod · 0.45
handleOptionMethod · 0.45
safeString2Method · 0.45
omitMethod · 0.45
amountToPrecisionMethod · 0.45
priceToPrecisionMethod · 0.45

Tested by

no test coverage detected