Place Order
Interface Description
Function description: This interface is used by eligible customers to place orders (of U.S. customers and crypto currency only)
URL: /trade/order/place
Method: POST
Rate limit: The calling frequency of each App ID is limited to 2 times per second.
Request Parameters
Parameter | Type | Required fields | Description | Example value |
---|---|---|---|---|
account_id | String | Yes | Account ID | a015d0c1001 |
crypto_order | crypto_order | Yes | crypto Order Parameters | See example codes |
crypto_order:
Parameter | Type | Required fields | Description | Example value |
---|---|---|---|---|
request_id | String | Yes | Custom request ID, Each request must be unique. | 27290e2404e84572b2ffa0f89906525d |
instrument_id | String | Yes | Instrument ID, which can be obtained by querying tradable instrument information(/trade/Query Trade Instrument) | 9056135 |
entrust_type | String | Yes | OrderEntrustType | CASH |
qty | String | No | Order quantity. When entrustType is set to QTY, this field is required | 1 |
amt | String | No | Order amount.When entrustType is set to AMT, this field is required. | 26.5 |
side | String | Yes | OrderSide | BUY |
tif | String | Yes | Time-in-force: the validity period of the order | IOC |
order_type | String | Yes | OrderType | MKT |
limit_price | String | No | The limit price must be greater than 0. Required for Limit and Stop Loss Limit Order order types. Limit price: Must be null for Market order types | 100.49 |
stop_price | String | No | The stop-loss price must be greater than 0. Required for Stop Loss Limit order types. Stop price: Must be null for Limit and Market order types | 100.49 |
Response Parameter
Parameter | Type | Description | Example value |
---|---|---|---|
client_order_id | String | Webull Pay Order ID | 20e220a218ss1907d123dsd4 |
Request Example
- Python
- Java
from webullpaysdktrade.api import API
from webullpaysdkcore.client import ApiClient
from webullpaysdkcore.common.region import Region
your_app_key = "<your_app_key>"
your_app_secret = "<your_app_secret>"
crypto_order = {
"account_id": "abc123",
"crypto_order": {
"request_id": request_id,
"instrument_id": "913256409",
"order_type": "MKT",
"tif": "IOC",
"side": "BUY",
"entrust_type": "QTY",
"qty": "1"
}
}
api_client = ApiClient(your_app_key, your_app_secret, Region.US.value)
api = API(api_client)
response = api.order.place_order(crypto_order['account_id'], **crypto_order['crypto_order'])
if response.status_code == 200:
order_res = response.json()
print(order_res)
HttpApiConfig apiConfig = HttpApiConfig.builder()
.appKey("<your_app_key>")
.appSecret("<your_app_secret>")
.regionId(Region.us.name())
.build();
TradeApiService apiService = new TradeHttpApiService(apiConfig);
CryptoOrder cryptoOrder = new CryptoOrder();
cryptoOrder.setRequestId("A0191646207512192E");
cryptoOrder.setSide("BUY");
cryptoOrder.setTif("IOC");
cryptoOrder.setInstrumentId("950160802");
cryptoOrder.setOrderType("MKT");
cryptoOrder.setEntrustType("QTY");
cryptoOrder.setQty("1");
OrderResponse orderResponse = apiService.placeOrder("accountId", cryptoOrder);
//print
System.out.println(JsonSerializer.toJson(orderResponse, SerializeConfig.builder().underscoresToCamel(true).build()));
Response Example
{
"client_order_id": "01916462123512190"
}
Exception Example
{
"error_code": "TRADE_PLACE_ORDER_REPEAT",
"message": "The order existed"
}