Skip to main content

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 App Secret.

  • For individual users, please see here.
  • For institutional users, please see here.
Note

Due to security and compliance requirements in Hong Kong, OpenAPI requires not only identity verification with App Key and secret signature, but also an additional Token verification.
For token creation and verification, please refer to Token Creation and Verification.

1. Supported Markets

The Trading API supports the following markets:

MarketProducts
United StatesUS equity products (stocks, options—excluding index options)
Hong KongHong Kong equity products (including stocks, ETFs)
Mainland ChinaStock Connect stocks

2. Base URLs

  • Production Environment: https://api.webull.hk/
  • Sandbox Environment: https://api.sandbox.webull.hk

3. Code Example

3.1 Stock Orders

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.hk. Test env host: api.sanbox.webull.hk
your_app_key = "<your_app_key>"
your_app_secret = "<your_app_secret>"
region_id = "hk"
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"
}
]

# For hk stock place params
new_hk_stock_simple_orders = [
{
"client_order_id": client_order_id,
"symbol": "00700",
"instrument_type": "EQUITY",
"market": "HK",
"order_type": "ENHANCED_LIMIT",
"limit_price": "612",
"quantity": "100",
"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())

3.2 Option Orders

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.hk. Test env host: api.sanbox.webull.hk
your_app_key = "<your_app_key>"
your_app_secret = "<your_app_secret>"
region_id = "hk"
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())