Preview Order(v2)
Interface description
Function description: Calculate the estimated amount and cost based on the incoming information, and support simple orders.
Applicable objects: Customers who integrate into Webull through Webull OpenAPI
Request URL:
/openapi/account/orders/preview?account_id={account_id}
Request method: POST
Frequency limit: The calling frequency of each AppId is limited to 2 time per second.
Parameters
Parameter | Type | Required | Description | Values/Example |
---|---|---|---|---|
account_id | String | Required | Account ID | CASH_10004248 |
new_orders | []order_item | Required | Order Details |
order_item:
Parameter | Type | Required | Description | Values/Example |
---|---|---|---|---|
instrument_type | String | Required | Instrument Types | EQUITY |
symbol | String | Required | Symbol | AAPL |
market | String | Required | market | AAPL |
side | String | Required | Side | BUY |
order_type | String | Required | Order Types | MARKET |
stop_price | String | Optional | Stop loss price When the market price is greater than or equal to 1, the precision is 2, and when the market price is less than 1, the precision is 4 | 11.00 |
limit_price | String | Optional | Limited price When the market price is greater than or equal to 1, the precision is 2, and when the market price is less than 1, the precision is 4 | 11.00 |
quantity | String | Required | Quantity | 1 |
support_trading_session | String | Required | Trading Hours | N |
entrust_type | String | Required | Entrust Type Currently, only QTY is supported | QTY |
time_in_force | String | Required | Time In Force | DAY |
account_tax_type | String | Required | Account Tax Type | GENERAL |
margin_type | String | Optional | Margin type, refers to the dictionary value MarginType. When the specified contract is closed, the marginType of the contract must be the same type. Get the marginType type reference of the contract: Account Position. | ONE_DAY |
close_contracts | []CloseContract | Optional | List of contracts, if the position is closed with the field passed in (with a maximum of 10 contracts), the position will be closed according to the contract dimension. If contract id is not passed, the position will be closed according to the first-in-first-out rule. |
close_contracts:
Parameter | Type | Required | Description | Values/Example |
---|---|---|---|---|
contract_id | String | Optional | Contract id | 2022021819071234 |
quantity | String | Optional | The quantities of orders to be closed under each contract ID. | 10 |
Response
Parameter | Type | Required | Description | Values/Example |
---|---|---|---|---|
estimated_cost | String | Required | Estimated Cost | 100 |
estimated_transaction_fee | String | Required | Estimated Transaction Fee | 1 |
Request example
- python
- Java
from webullsdkcore.client import ApiClient
from webullsdktrade.api import API
api_client = ApiClient(your_app_key, your_app_secret, Region.JP.value)
api = API(api_client)
preview_orders = {
"symbol": "7011",
"instrument_type": "EQUITY",
"market": "JP",
"order_type": "LIMIT",
"limit_price": "2070",
"quantity": "100",
"support_trading_session": "N",
"side": "BUY",
"time_in_force": "DAY",
"entrust_type": "QTY",
"account_tax_type": "GENERAL"
}
res = api.order_v2.preview_order(account_id=account_id, preview_orders=preview_orders)
if res.status_code == 200:
print("preview_res=" + json.dumps(res.json(), indent=4))
HttpApiConfig apiConfig = HttpApiConfig.builder()
.appKey(Env.APP_KEY)
.appSecret(Env.APP_SECRET)
.regionId(Region.jp.name())
.build();
TradeApiService apiService = new TradeHttpApiService(apiConfig);
TradeOrder tradeOrder = new TradeOrder();
List<TradeOrderItem> previewOrders = new ArrayList<>();
TradeOrderItem placeOne = new TradeOrderItem();
placeOne.setSymbol(symbol);
placeOne.setInstrumentType(instrumentType);
placeOne.setMarket(market);
placeOne.setOrderType(orderType);
placeOne.setQuantity(quantity);
placeOne.setLimitPrice(limitPrice);
placeOne.setStopPrice(stopPrice);
placeOne.setSupportTradingSession(supportTradingSession);
placeOne.setSide(side);
placeOne.setTimeInForce(timeInFore);
placeOne.setEntrustType(entrustType);
placeOne.setAccountTaxType(accountTaxType);
placeOne.setMarginType(marginType);
placeOne.setCloseContract(closeContract);
previewOrders.add(placeOne);
tradeOrder.setNewOrders(previewOrders);
PreviewOrderResponse previewOrderResponse = apiService.previewOrder(accountId, tradeOrder);