create a trade order https://docs.derive.xyz/reference/post_private-order :param str symbol: unified symbol of the market to create an order in :param str type: 'market' or 'limit' :param str side: 'buy' or 'sell' :param float amount: how much of cu
(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={})
| 1151 | return Precise.string_mul(num, dec) |
| 1152 | |
| 1153 | def create_order(self, symbol: str, type: OrderType, side: OrderSide, amount: float, price: Num = None, params={}): |
| 1154 | """ |
| 1155 | create a trade order |
| 1156 | |
| 1157 | https://docs.derive.xyz/reference/post_private-order |
| 1158 | |
| 1159 | :param str symbol: unified symbol of the market to create an order in |
| 1160 | :param str type: 'market' or 'limit' |
| 1161 | :param str side: 'buy' or 'sell' |
| 1162 | :param float amount: how much of currency you want to trade in units of base currency |
| 1163 | :param float [price]: the price at which the order is to be fulfilled, in units of the quote currency, ignored in market orders |
| 1164 | :param dict [params]: extra parameters specific to the exchange API endpoint |
| 1165 | :param str [params.subaccount_id]: *required* the subaccount id |
| 1166 | :param float [params.triggerPrice]: The price a trigger order is triggered at |
| 1167 | :param dict [params.takeProfit]: *takeProfit object in params* containing the triggerPrice at which the attached take profit order will be triggered(perpetual swap markets only) |
| 1168 | :param float [params.takeProfit.triggerPrice]: take profit trigger price |
| 1169 | :param dict [params.stopLoss]: *stopLoss object in params* containing the triggerPrice at which the attached stop loss order will be triggered(perpetual swap markets only) |
| 1170 | :param float [params.stopLoss.triggerPrice]: stop loss trigger price |
| 1171 | :param float [params.max_fee]: *required* the maximum fee you are willing to pay for the order |
| 1172 | :returns dict: an `order structure <https://docs.ccxt.com/?id=order-structure>` |
| 1173 | """ |
| 1174 | self.load_markets() |
| 1175 | market = self.market(symbol) |
| 1176 | if price is None: |
| 1177 | raise ArgumentsRequired(self.id + ' createOrder() requires a price argument') |
| 1178 | subaccountId = None |
| 1179 | subaccountId, params = self.handle_derive_subaccount_id('createOrder', params) |
| 1180 | test = self.safe_bool(params, 'test', False) |
| 1181 | reduceOnly = self.safe_bool_2(params, 'reduceOnly', 'reduce_only') |
| 1182 | timeInForce = self.safe_string_lower_2(params, 'timeInForce', 'time_in_force') |
| 1183 | postOnly = self.safe_bool(params, 'postOnly') |
| 1184 | orderType = type.lower() |
| 1185 | orderSide = side.lower() |
| 1186 | nonce = self.milliseconds() |
| 1187 | # Order signature expiry must be between 2592000 and 7776000 sec from now |
| 1188 | signatureExpiry = self.safe_integer(params, 'signature_expiry_sec', self.seconds() + 7776000) |
| 1189 | ACTION_TYPEHASH = self.base16_to_binary('4d7a9f27c403ff9c0f19bce61d76d82f9aa29f8d6d4b0c5474607d9770d1af17') |
| 1190 | sandboxMode = self.safe_bool(self.options, 'sandboxMode', False) |
| 1191 | TRADE_MODULE_ADDRESS = '0x87F2863866D85E3192a35A73b388BD625D83f2be' if (sandboxMode) else '0xB8D20c2B7a1Ad2EE33Bc50eF10876eD3035b5e7b' |
| 1192 | priceString = self.number_to_string(price) |
| 1193 | maxFee = None |
| 1194 | maxFee, params = self.handle_option_and_params(params, 'createOrder', 'max_fee') |
| 1195 | if maxFee is None: |
| 1196 | raise ArgumentsRequired(self.id + ' createOrder() requires a max_fee argument in params') |
| 1197 | maxFeeString = self.number_to_string(maxFee) |
| 1198 | amountString = self.number_to_string(amount) |
| 1199 | tradeModuleDataHash = self.hash(self.eth_abi_encode([ |
| 1200 | 'address', 'uint', 'int', 'int', 'uint', 'uint', 'bool', |
| 1201 | ], [ |
| 1202 | market['info']['base_asset_address'], |
| 1203 | self.parse_to_numeric(market['info']['base_asset_sub_id']), |
| 1204 | self.convert_to_big_int((self.parse_units(priceString))), |
| 1205 | self.convert_to_big_int((self.parse_units((self.amount_to_precision(symbol, amountString))))), |
| 1206 | self.convert_to_big_int((self.parse_units(maxFeeString))), |
| 1207 | subaccountId, |
| 1208 | orderSide == 'buy', |
| 1209 | ]), 'keccak', 'binary') |
| 1210 | deriveWalletAddress = None |
nothing calls this directly
no test coverage detected