(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={})
| 1256 | return r |
| 1257 | |
| 1258 | def create_order_request(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}): |
| 1259 | reduceOnly = self.safe_bool_2(params, 'reduceOnly', 'reduce_only', False) |
| 1260 | orderType = type.upper() |
| 1261 | market = self.market(symbol) |
| 1262 | orderSide = side.upper() |
| 1263 | subaccountId = 0 |
| 1264 | subaccountId, params = self.handle_option_and_params(params, 'createOrder', 'subAccountId', subaccountId) |
| 1265 | triggerPrice = self.safe_string_2(params, 'triggerPrice', 'stopPrice') |
| 1266 | stopLossPrice = self.safe_value(params, 'stopLossPrice', triggerPrice) |
| 1267 | takeProfitPrice = self.safe_value(params, 'takeProfitPrice') |
| 1268 | isConditional = triggerPrice is not None or stopLossPrice is not None or takeProfitPrice is not None |
| 1269 | isMarket = orderType == 'MARKET' |
| 1270 | timeInForce = self.safe_string_upper(params, 'timeInForce', 'GTT') |
| 1271 | postOnly = self.is_post_only(isMarket, None, params) |
| 1272 | amountStr = self.amount_to_precision(symbol, amount) |
| 1273 | priceStr = self.price_to_precision(symbol, price) |
| 1274 | marketInfo = self.safe_dict(market, 'info', {}) |
| 1275 | atomicResolution = marketInfo['atomicResolution'] |
| 1276 | quantumScale = self.pow('10', Precise.string_neg(atomicResolution)) |
| 1277 | quantums = Precise.string_mul(amountStr, quantumScale) |
| 1278 | quantumConversionExponent = marketInfo['quantumConversionExponent'] |
| 1279 | priceScale = self.pow('10', Precise.string_sub(Precise.string_sub(atomicResolution, quantumConversionExponent), '-6')) |
| 1280 | subticks = Precise.string_mul(priceStr, priceScale) |
| 1281 | clientMetadata = 0 |
| 1282 | conditionalType = 0 |
| 1283 | conditionalOrderTriggerSubticks = '0' |
| 1284 | orderFlag = None |
| 1285 | timeInForceNumber = None |
| 1286 | if timeInForce == 'FOK': |
| 1287 | raise InvalidOrder(self.id + ' timeInForce fok has been deprecated') |
| 1288 | if orderType == 'MARKET': |
| 1289 | # short-term |
| 1290 | orderFlag = 0 |
| 1291 | clientMetadata = 1 # STOP_MARKET / TAKE_PROFIT_MARKET |
| 1292 | if timeInForce is not None: |
| 1293 | # default is ioc |
| 1294 | timeInForceNumber = 1 |
| 1295 | elif orderType == 'LIMIT': |
| 1296 | if timeInForce == 'GTT': |
| 1297 | # long-term |
| 1298 | orderFlag = 64 |
| 1299 | if postOnly: |
| 1300 | timeInForceNumber = 2 |
| 1301 | else: |
| 1302 | timeInForceNumber = 0 |
| 1303 | else: |
| 1304 | orderFlag = 0 |
| 1305 | if timeInForce == 'IOC': |
| 1306 | timeInForceNumber = 1 |
| 1307 | else: |
| 1308 | raise InvalidOrder('unexpected code path: timeInForce') |
| 1309 | if isConditional: |
| 1310 | # conditional |
| 1311 | orderFlag = 32 |
| 1312 | if stopLossPrice is not None: |
| 1313 | conditionalType = 1 |
| 1314 | conditionalOrderTriggerSubticks = self.price_to_precision(symbol, stopLossPrice) |
| 1315 | elif takeProfitPrice is not None: |
no test coverage detected