Orders
Webull provides a Trading API that allows developers to trade and query through the HTTP protocol.
For more details, please refer to the API Reference.
Before calling the Trading API, you need to have an App Key and secret. For more information, please refer to the Individual Application Process.
1. Supported Markets
The Trading API supports the following markets:
| Market | Products |
|---|---|
| United States | US equity products (stocks, options—excluding index options) |
2. Base URLs
- Production Environment:
https://api.webull.com/ - Test Environment:
http://us-openapi-alb.uat.webullbroker.com/
3. Code Example
3.1 Stock Orders
Parameters for Order Types
- Simple
- OTO
- OTOCO
- OCO
- Take-Profit/Stop-Loss
{
"account_id": "<your_account_id>",
"new_orders": [
{
"client_order_id": "<client_order_id>",
"instrument_type": "EQUITY",
"symbol": "BULL",
"market": "US",
"side": "BUY",
"order_type": "LIMIT",
"limit_price": "11.0",
"quantity": "1",
"support_trading_session": "CORE",
"entrust_type": "QTY",
"time_in_force": "DAY",
"combo_type": "NORMAL"
}
]
}
{
"account_id": "<your_account_id>",
"client_combo_order_id":"<client_combo_order_id>",
"new_orders": [
{
"combo_type": "MASTER",
"client_order_id": "<client_order_id>",
"instrument_type": "EQUITY",
"symbol": "BULL",
"market": "US",
"side": "BUY",
"order_type": "LIMIT",
"limit_price": "11.0",
"quantity": "1",
"support_trading_session": "CORE",
"entrust_type": "QTY",
"time_in_force": "DAY"
},
{
"combo_type": "OTO",
"client_order_id": "<client_order_id>",
"instrument_type": "EQUITY",
"symbol": "BULL",
"market": "US",
"side": "BUY",
"order_type": "LIMIT",
"limit_price": "11.0",
"quantity": "1",
"support_trading_session": "CORE",
"entrust_type": "QTY",
"time_in_force": "DAY"
}
]
}
{
"account_id":"<your_account_id>",
"client_combo_order_id": "<client_combo_order_id>",
"new_orders": [
{
"client_order_id": "<client_order_id>",
"combo_type": "MASTER",
"symbol": "AAPL",
"instrument_type": "EQUITY",
"market": "US",
"order_type": "LIMIT",
"quantity": "1",
"support_trading_session": "N",
"limit_price": "180",
"side": "BUY",
"entrust_type": "QTY",
"time_in_force": "DAY"
},
{
"client_order_id": "<client_order_id>",
"combo_type": "OTOCO",
"symbol": "AAPL",
"instrument_type": "EQUITY",
"market": "US",
"order_type": "LIMIT",
"quantity": "1",
"support_trading_session": "N",
"limit_price": "181",
"side": "BUY",
"entrust_type": "QTY",
"time_in_force": "DAY"
},
{
"client_order_id": "<client_order_id>",
"combo_type": "OTOCO",
"symbol": "AAPL",
"instrument_type": "EQUITY",
"market": "US",
"order_type": "LIMIT",
"quantity": "1",
"support_trading_session": "N",
"limit_price": "182",
"side": "BUY",
"entrust_type": "QTY",
"time_in_force": "DAY"
}
]
}
{
"account_id": "<your_account_id>",
"client_combo_order_id": "<client_combo_order_id>",
"new_orders": [
{
"client_order_id": "<client_order_id>",
"combo_type": "OCO",
"symbol": "AAPL",
"instrument_type": "EQUITY",
"market": "US",
"order_type": "LIMIT",
"quantity": "1",
"support_trading_session": "N",
"limit_price": "180",
"side": "BUY",
"entrust_type": "QTY",
"time_in_force": "DAY"
},
{
"client_order_id": "<client_order_id>",
"combo_type": "OCO",
"symbol": "AAPL",
"instrument_type": "EQUITY",
"market": "US",
"order_type": "LIMIT",
"quantity": "1",
"support_trading_session": "N",
"limit_price": "181",
"side": "BUY",
"entrust_type": "QTY",
"time_in_force": "DAY"
},
{
"client_order_id": "<client_order_id>",
"combo_type": "OCO",
"symbol": "AAPL",
"instrument_type": "EQUITY",
"market": "US",
"order_type": "LIMIT",
"quantity": "1",
"support_trading_session": "N",
"limit_price": "182",
"side": "BUY",
"entrust_type": "QTY",
"time_in_force": "DAY"
}
]
}
{
"account_id": "<your_account_id>",
"client_combo_order_id": "<client_combo_order_id>",
"new_orders": [
{
"client_order_id": "<client_order_id>",
"combo_type": "MASTER",
"symbol": "AAPL",
"instrument_type": "EQUITY",
"market": "US",
"order_type": "LIMIT",
"quantity": "1",
"support_trading_session": "N",
"limit_price": "209.23",
"side": "BUY",
"entrust_type": "QTY",
"time_in_force": "DAY"
},
{
"client_order_id": "<client_order_id>",
"combo_type": "STOP_PROFIT",
"symbol": "AAPL",
"instrument_type": "EQUITY",
"market": "US",
"order_type": "LIMIT",
"quantity": "1",
"support_trading_session": "N",
"limit_price": "211.32",
"side": "SELL",
"entrust_type": "QTY",
"time_in_force": "DAY"
},
{
"client_order_id": "<client_order_id>",
"combo_type": "STOP_LOSS",
"symbol": "AAPL",
"instrument_type": "EQUITY",
"market": "US",
"order_type": "STOP_LOSS",
"quantity": "1",
"support_trading_session": "N",
"stop_price": "207.14",
"side": "SELL",
"entrust_type": "QTY",
"time_in_force": "DAY"
}
]
}
SDK Examples
- Python
- Java
import uuid
from webull.core.client import ApiClient
from webull.trade.trade_client import TradeClient
optional_api_endpoint = "<webull_api_host>" # PRD env host: api.webull.com; Test env host: us-openapi-alb.uat.webullbroker.com
your_app_key = "<your_app_key>"
your_app_secret = "<your_app_secret>"
region_id = "us"
account_id = "<your_account_id>" # Use account_list interface to get account info
api_client = ApiClient(your_app_key, your_app_secret, region_id)
api_client.add_endpoint(region_id, optional_api_endpoint)
if __name__ == '__main__':
trade_client = TradeClient(api_client)
# simple order
client_order_id = uuid.uuid4().hex
print('client order id:', client_order_id)
new_simple_orders = [
{
"client_order_id": client_order_id,
"symbol": "BULL",
"instrument_type": "EQUITY",
"market": "US",
"order_type": "LIMIT",
"limit_price": "26",
"quantity": "1",
"support_trading_session": "CORE",
"side": "BUY",
"time_in_force": "DAY",
"entrust_type": "QTY"
}
]
res = trade_client.order_v2.preview_order(account_id, new_simple_orders)
if res.status_code == 200:
print('preview order res:', res.json())
res = trade_client.order_v2.place_order(account_id, new_simple_orders)
if res.status_code == 200:
print('place order res:', res.json())
modify_simple_orders = [
{
"client_order_id": client_order_id,
"quantity": "2",
"limit_price": "25"
}
]
res = trade_client.order_v2.replace_order(account_id, modify_simple_orders)
if res.status_code == 200:
print('replace order res:', res.json())
res = trade_client.order_v2.cancel_order(account_id, client_order_id)
if res.status_code == 200:
print('cancel order res:', res.json())
res = trade_client.order_v2.get_order_detail(account_id, client_order_id)
if res.status_code == 200:
print('order detail:', res.json())
import com.webull.openapi.core.common.Region;
import com.webull.openapi.core.common.dict.*;
import com.webull.openapi.core.http.HttpApiConfig;
import com.webull.openapi.core.logger.Logger;
import com.webull.openapi.core.logger.LoggerFactory;
import com.webull.openapi.core.utils.GUID;
import com.webull.openapi.samples.config.Env;
import com.webull.openapi.trade.request.v2.TradeOrder;
import com.webull.openapi.trade.request.v2.TradeOrderItem;
import com.webull.openapi.trade.response.v2.OrderHistory;
import com.webull.openapi.trade.response.v2.TradeOrderResponse;
import java.util.ArrayList;
import java.util.List;
public class OrderStockTradeClient {
private static final Logger logger = LoggerFactory.getLogger(OrderStockTradeClient.class);
public static void main(String[] args) {
OrderStockTradeClient orderStockTradeClient = new OrderStockTradeClient();
HttpApiConfig apiConfig = HttpApiConfig.builder()
.appKey("<your_app_key>") //<your_app_key>
.appSecret("<your_app_secret>") //<your_app_secret>
.regionId("us") //<your_region_id> @see com.webull.openapi.core.common.Region
.endpoint("<webull_api_host>") //PRD env host: api.webull.com; Test env host: us-openapi-alb.uat.webullbroker.com
.build();
com.webull.openapi.trade.TradeClientV2 apiService = new com.webull.openapi.trade.TradeClientV2(apiConfig);
// Use getAccountList interface to get account info
String accountId = "#{accountId}"; //<your_account_id> from by Account Api
String clientOrderId = GUID.get();
com.webull.openapi.trade.TradeClientV2 apiService = new com.webull.openapi.trade.TradeClientV2(apiConfig);
// build place order params
TradeOrder tradeOrder = orderStockTradeClient.buildPlaceStockParams(clientOrderId);
// place order
TradeOrderResponse placeOrderResp = apiService.placeOrder(accountId,tradeOrder);
logger.info("Place order response: {}", placeOrderResp);
// get order detail
OrderHistory orderDetail = apiService.getOrderDetails(accountId,clientOrderId);
logger.info("Order details response: {}", orderDetail);
// replace order
TradeOrder modifyTradeOrder = orderStockTradeClient.buildReplaceOrderParams(clientOrderId);
TradeOrderResponse modifyOrderResponse = apiService.replaceOrder(accountId, modifyTradeOrder);
logger.info("Order modify response: {}", modifyOrderResponse);
// query order detail after replace order
OrderHistory orderDetail1 = apiService.getOrderDetails(accountId, clientOrderId);
logger.info("Order orderDetail response after replace order: {}", orderDetail1);
// cancel order
TradeOrder cancelOrder = new TradeOrder();
cancelOrder.setClientOrderId(clientOrderId);
TradeOrderResponse cancelOrderResponse = apiService.cancelOrder(accountId, cancelOrder);
logger.info("Order cancel order response: {}", cancelOrderResponse);
// query order detail after cancel order
OrderHistory orderDetail2 = apiService.getOrderDetails(accountId, clientOrderId);
logger.info("Order orderDetail response after cancel: {}", orderDetail2.getOrders().get(0).getStatus());
}
/**
* build your place order object
*
* @param clientOrderId
* @return
*/
private TradeOrder buildPlaceStockParams(String clientOrderId) {
TradeOrder tradeOrder = new TradeOrder();
List<TradeOrderItem> newOrders = new ArrayList<>();
TradeOrderItem placeOne = new TradeOrderItem();
placeOne.setClientOrderId(clientOrderId);
// WebullUS need set combo_type, because WebullUS support combo order
placeOne.setComboType(ComboType.NORMAL.name());
newOrders.add(placeOne);
placeOne.setSymbol("BULL");
placeOne.setInstrumentType(InstrumentSuperType.EQUITY.name());
placeOne.setMarket(Region.us.name().toUpperCase());
placeOne.setOrderType(OrderType.LIMIT.name());
placeOne.setQuantity("1");
placeOne.setLimitPrice("25");
placeOne.setSupportTradingSession("ALL");
placeOne.setSide(OrderSide.BUY.name());
placeOne.setTimeInForce(OrderTIF.DAY.name());
placeOne.setEntrustType(EntrustType.QTY.name());
tradeOrder.setNewOrders(newOrders);
return tradeOrder;
}
/**
* build your replace order params
* @param clientOrderId
* @return replace order object
*/
private TradeOrder buildReplaceOrderParams(String clientOrderId) {
TradeOrder replaceTradeOrder = new TradeOrder();
List<TradeOrderItem> modifyOrders = new ArrayList<>();
TradeOrderItem modifyOne = new TradeOrderItem();
modifyOne.setClientOrderId(clientOrderId);
modifyOne.setLimitPrice("25");
modifyOne.setQuantity("2");
modifyOrders.add(modifyOne);
replaceTradeOrder.setModifyOrders(modifyOrders);
return replaceTradeOrder;
}
}
3.2 Options Orders
Parameters for Order Types
- Single-Leg
- Multi-Leg:COVERED_STOCK
- Take-Profit/Stop-Loss
{
"account_id": "<your_account_id>",
"new_orders": [
{
"client_order_id": "<client_order_id>",
"combo_type": "NORMAL",
"order_type": "LIMIT",
"quantity": "1",
"limit_price": "220.25",
"option_strategy": "SINGLE",
"side": "BUY",
"time_in_force": "DAY",
"entrust_type": "QTY",
"legs": [
{
"side": "BUY",
"quantity": "1",
"symbol": "AAPL",
"strike_price": "220",
"init_exp_date": "2025-11-19",
"instrument_type": "OPTION",
"option_type": "CALL",
"market": "US"
}
]
}
]
}
{
"account_id": "<your_account_id>",
"new_orders": [
{
"client_order_id": "<client_order_id>",
"combo_type": "NORMAL",
"option_strategy": "COVERED_STOCK",
"order_type": "MARKET",
"quantity": "2",
"side": "BUY",
"time_in_force": "DAY",
"entrust_type": "QTY",
"legs": [
{
"side": "BUY",
"quantity": "200",
"symbol": "TSLA",
"instrument_type": "EQUITY",
"market": "US"
},
{
"side": "SELL",
"quantity": "2",
"symbol": "TSLA",
"strike_price": "220",
"init_exp_date": "2025-11-19",
"instrument_type": "OPTION",
"option_type": "CALL",
"market": "US"
}
]
}
]
}
{
"account_id": "<your_account_id>",
"client_combo_order_id": "<client_combo_order_id>",
"new_orders": [
{
"client_order_id": "<client_order_id>",
"combo_type": "MASTER",
"order_type": "LIMIT",
"quantity": "1",
"limit_price": "11.25",
"option_strategy": "SINGLE",
"side": "BUY",
"time_in_force": "DAY",
"entrust_type": "QTY",
"legs": [
{
"side": "BUY",
"quantity": "1",
"symbol": "AAPL",
"strike_price": "270",
"init_exp_date": "2025-11-19",
"instrument_type": "OPTION",
"option_type": "CALL",
"market": "US"
}
]
},
{
"client_order_id": "<client_order_id>",
"combo_type": "STOP_PROFIT",
"order_type": "LIMIT",
"quantity": "1",
"limit_price": "11",
"option_strategy": "SINGLE",
"side": "SELL",
"time_in_force": "DAY",
"entrust_type": "QTY",
"legs": [
{
"side": "SELL",
"quantity": "1",
"symbol": "AAPL",
"strike_price": "270",
"init_exp_date": "2025-11-19",
"instrument_type": "OPTION",
"option_type": "CALL",
"market": "US"
}
]
},
{
"client_order_id": "<client_order_id>",
"combo_type": "STOP_LOSS",
"order_type": "STOP_LOSS",
"quantity": "1",
"stop_price": "11",
"option_strategy": "SINGLE",
"side": "SELL",
"time_in_force": "DAY",
"entrust_type": "QTY",
"legs": [
{
"side": "SELL",
"quantity": "1",
"symbol": "AAPL",
"strike_price": "270",
"init_exp_date": "2025-11-19",
"instrument_type": "OPTION",
"option_type": "CALL",
"market": "US"
}
]
}
]
}
SDK Examples
- Python
- Java
import uuid
from webull.core.client import ApiClient
from webull.trade.trade_client import TradeClient
optional_api_endpoint = "<webull_api_host>" # PRD env host: api.webull.com; Test env host: us-openapi-alb.uat.webullbroker.com
your_app_key = "<your_app_key>"
your_app_secret = "<your_app_secret>"
region_id = "us"
account_id = "<your_account_id>" # Use account_list interface to get account info
api_client = ApiClient(your_app_key, your_app_secret, region_id)
api_client.add_endpoint(region_id, optional_api_endpoint)
if __name__ == '__main__':
trade_client = TradeClient(api_client)
# Options
# For option order inquiries, please use the V2 query interface: api.order_v2.get_order_detail(account_id, client_order_id).
client_order_id = uuid.uuid4().hex
option_new_orders = [
{
"client_order_id": client_order_id,
"combo_type": "NORMAL",
"order_type": "LIMIT",
"quantity": "1",
"limit_price": "21.25",
"option_strategy": "SINGLE",
"side": "BUY",
"time_in_force": "GTC",
"entrust_type": "QTY",
"legs": [
{
"side": "BUY",
"quantity": "1",
"symbol": "TSLA",
"strike_price": "400",
"option_expire_date": "2025-11-26",
"instrument_type": "OPTION",
"option_type": "CALL",
"market": "US"
}
]
}
]
# preview
res = trade_client.order_v2.preview_option(account_id, option_new_orders)
if res.status_code == 200:
print("preview option res:", res.json())
# place
res = trade_client.order_v2.place_option(account_id, option_new_orders)
if res.status_code == 200:
print("place option res:" , res.json())
option_modify_orders = [
{
"client_order_id": client_order_id,
"quantity": "2",
"limit_price": "21.25"
}
]
res = trade_client.order_v2.replace_option(account_id, option_modify_orders)
if res.status_code == 200:
print("Replace option order res:" , res.json())
res = trade_client.order_v2.cancel_option(account_id, client_order_id)
if res.status_code == 200:
print("Replace option order res:" , res.json())
res = trade_client.order_v2.get_order_detail(account_id, client_order_id)
if res.status_code == 200:
print("Option order detail order res:" , res.json())
import com.webull.openapi.core.common.Region;
import com.webull.openapi.core.common.dict.*;
import com.webull.openapi.core.http.HttpApiConfig;
import com.webull.openapi.core.logger.Logger;
import com.webull.openapi.core.logger.LoggerFactory;
import com.webull.openapi.core.utils.GUID;
import com.webull.openapi.samples.config.Env;
import com.webull.openapi.trade.request.v2.TradeOrder;
import com.webull.openapi.trade.request.v2.TradeOrderItem;
import com.webull.openapi.trade.response.v2.OrderHistory;
import com.webull.openapi.trade.response.v2.TradeOrderResponse;
import java.util.ArrayList;
import java.util.List;
public class OrderStockTradeClient {
private static final Logger logger = LoggerFactory.getLogger(OrderStockTradeClient.class);
public static void main(String[] args) {
OrderStockTradeClient orderStockTradeClient = new OrderStockTradeClient();
HttpApiConfig apiConfig = HttpApiConfig.builder()
.appKey("<your_app_key>") //<your_app_key>
.appSecret("<your_app_secret>") //<your_app_secret>
.regionId("us") //<your_region_id> @see com.webull.openapi.core.common.Region
.endpoint("<webull_api_host>") //PRD env host: api.webull.com; Test env host: us-openapi-alb.uat.webullbroker.com
.build();
com.webull.openapi.trade.TradeClientV2 apiService = new com.webull.openapi.trade.TradeClientV2(apiConfig);
// Use getAccountList interface to get account info
String accountId = "#{accountId}"; //<your_account_id> from by Account Api
String clientOrderId = GUID.get();
com.webull.openapi.trade.TradeClientV2 apiService = new com.webull.openapi.trade.TradeClientV2(apiConfig);
// build place order params
TradeOrder tradeOrder = orderStockTradeClient.buildPlaceStockParams(clientOrderId);
// place order
TradeOrderResponse placeOrderResp = apiService.placeOrder(accountId,tradeOrder);
logger.info("Place order response: {}", placeOrderResp);
// get order detail
OrderHistory orderDetail = apiService.getOrderDetails(accountId,clientOrderId);
logger.info("Order details response: {}", orderDetail);
// replace order
TradeOrder modifyTradeOrder = orderStockTradeClient.buildReplaceOrderParams(clientOrderId);
TradeOrderResponse modifyOrderResponse = apiService.replaceOrder(accountId, modifyTradeOrder);
logger.info("Order modify response: {}", modifyOrderResponse);
// query order detail after replace order
OrderHistory orderDetail1 = apiService.getOrderDetails(accountId, clientOrderId);
logger.info("Order orderDetail response after replace order: {}", orderDetail1);
// cancel order
TradeOrder cancelOrder = new TradeOrder();
cancelOrder.setClientOrderId(clientOrderId);
TradeOrderResponse cancelOrderResponse = apiService.cancelOrder(accountId, cancelOrder);
logger.info("Order cancel order response: {}", cancelOrderResponse);
// query order detail after cancel order
OrderHistory orderDetail2 = apiService.getOrderDetails(accountId, clientOrderId);
logger.info("Order orderDetail response after cancel: {}", orderDetail2.getOrders().get(0).getStatus());
}
/**
* build your place order object
*
* @param clientOrderId
* @return
*/
private TradeOrder buildPlaceStockParams(String clientOrderId) {
TradeOrder tradeOrder = new TradeOrder();
List<TradeOrderItem> newOrders = new ArrayList<>();
TradeOrderItem placeOne = new TradeOrderItem();
placeOne.setClientOrderId(clientOrderId);
// WebullUS need set combo_type, because WebullUS support combo order
placeOne.setComboType(ComboType.NORMAL.name());
newOrders.add(placeOne);
placeOne.setSymbol("BULL");
placeOne.setInstrumentType(InstrumentSuperType.EQUITY.name());
placeOne.setMarket(Region.us.name().toUpperCase());
placeOne.setOrderType(OrderType.LIMIT.name());
placeOne.setQuantity("1");
placeOne.setLimitPrice("25");
placeOne.setSupportTradingSession("ALL");
placeOne.setSide(OrderSide.BUY.name());
placeOne.setTimeInForce(OrderTIF.DAY.name());
placeOne.setEntrustType(EntrustType.QTY.name());
tradeOrder.setNewOrders(newOrders);
return tradeOrder;
}
/**
* build your replace order params
* @param clientOrderId
* @return replace order object
*/
private TradeOrder buildReplaceOrderParams(String clientOrderId) {
TradeOrder replaceTradeOrder = new TradeOrder();
List<TradeOrderItem> modifyOrders = new ArrayList<>();
TradeOrderItem modifyOne = new TradeOrderItem();
modifyOne.setClientOrderId(clientOrderId);
modifyOne.setLimitPrice("25");
modifyOne.setQuantity("2");
modifyOrders.add(modifyOne);
replaceTradeOrder.setModifyOrders(modifyOrders);
return replaceTradeOrder;
}
}