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

Method create_order

python/ccxt/latoken.py:1305–1362  ·  view source on GitHub ↗

create a trade order https://api.latoken.com/doc/v2/#tag/Order/operation/placeOrder https://api.latoken.com/doc/v2/#tag/StopOrder/operation/placeStopOrder # stop :param str symbol: unified symbol of the market to create an order in :param str type: 'market

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

Source from the content-addressed store, hash-verified

1303 return self.parse_order(response)
1304
1305 def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}):
1306 """
1307 create a trade order
1308
1309 https://api.latoken.com/doc/v2/#tag/Order/operation/placeOrder
1310 https://api.latoken.com/doc/v2/#tag/StopOrder/operation/placeStopOrder # stop
1311
1312 :param str symbol: unified symbol of the market to create an order in
1313 :param str type: 'market' or 'limit'
1314 :param str side: 'buy' or 'sell'
1315 :param float amount: how much of currency you want to trade in units of base currency
1316 :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders
1317 :param dict [params]: extra parameters specific to the exchange API endpoint
1318 :param float [params.triggerPrice]: the price at which a trigger order is triggered at
1319
1320 EXCHANGE SPECIFIC PARAMETERS
1321 :param str [params.condition]: "GTC", "IOC", or "FOK"
1322 :param str [params.clientOrderId]: [0 .. 50] characters, client's custom order id(free field for your convenience)
1323 :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>`
1324 """
1325 self.load_markets()
1326 market = self.market(symbol)
1327 uppercaseType = type.upper()
1328 request = {
1329 'baseCurrency': market['baseId'],
1330 'quoteCurrency': market['quoteId'],
1331 'side': side.upper(), # "BUY", "BID", "SELL", "ASK"
1332 'condition': 'GTC', # "GTC", "GOOD_TILL_CANCELLED", "IOC", "IMMEDIATE_OR_CANCEL", "FOK", "FILL_OR_KILL"
1333 'type': uppercaseType, # "LIMIT", "MARKET"
1334 'clientOrderId': self.uuid(), # 50 characters max
1335 # 'price': self.price_to_precision(symbol, price),
1336 # 'quantity': self.amount_to_precision(symbol, amount),
1337 'quantity': self.amount_to_precision(symbol, amount),
1338 'timestamp': self.seconds(),
1339 }
1340 if uppercaseType == 'LIMIT':
1341 request['price'] = self.price_to_precision(symbol, price)
1342 triggerPrice = self.safe_string_2(params, 'triggerPrice', 'stopPrice')
1343 params = self.omit(params, ['triggerPrice', 'stopPrice'])
1344 response: dict
1345 if triggerPrice is not None:
1346 request['stopPrice'] = self.price_to_precision(symbol, triggerPrice)
1347 response = self.privatePostAuthStopOrderPlace(self.extend(request, params))
1348 else:
1349 response = self.privatePostAuthOrderPlace(self.extend(request, params))
1350 #
1351 # {
1352 # "baseCurrency": "f7dac554-8139-4ff6-841f-0e586a5984a0",
1353 # "quoteCurrency": "a5a7a7a9-e2a3-43f9-8754-29a02f6b709b",
1354 # "side": "BID",
1355 # "clientOrderId": "my-wonderful-order-number-71566",
1356 # "price": "10103.19",
1357 # "stopPrice": "10103.19",
1358 # "quantity": "3.21",
1359 # "timestamp": 1568185507
1360 # }
1361 #
1362 return self.parse_order(response, market)

Callers

nothing calls this directly

Calls 12

parse_orderMethod · 0.95
safe_string_2Method · 0.80
load_marketsMethod · 0.45
marketMethod · 0.45
uuidMethod · 0.45
amount_to_precisionMethod · 0.45
secondsMethod · 0.45
price_to_precisionMethod · 0.45
omitMethod · 0.45
extendMethod · 0.45

Tested by

no test coverage detected