Stock Trading
The Stock Orders API supports placing, modifying, and cancelling orders for stocks and ETFs across US and JP markets. The unified order interface handles market-specific rules automatically based on the market parameter you specify.
For the full list of supported order types and features by market, see the Feature Matrix in the Trading API Overview.
Order Lifecycle
Every order follows this lifecycle:
- Preview — Estimate costs and fees before committing
- Place — Submit the order
- Replace — Modify price or quantity while the order is open
- Cancel — Cancel a pending order
Sample Code
The following example demonstrates the full order lifecycle using the Webull Python SDK.
Before running, replace the following placeholders with your own values:
import uuid
from time import sleep
from webull.core.client import ApiClient
from webull.trade.trade_client import TradeClient
# Configuration — Replace these values before running
API_ENDPOINT = "<api_endpoint>" # UAT: jp-openapi-alb.pre.webullbroker.com | Production: api.webull.co.jp
YOUR_APP_KEY = "<your_app_key>"
YOUR_APP_SECRET = "<your_app_secret>"
REGION_ID = "jp"
ACCOUNT_ID = "<your_account_id>"
api_client = ApiClient(YOUR_APP_KEY, YOUR_APP_SECRET, REGION_ID)
api_client.add_endpoint(REGION_ID, API_ENDPOINT)
trade_client = TradeClient(api_client)
# Generate a unique client order ID
client_order_id = uuid.uuid4().hex
# Define the order
new_orders = [
{
"combo_type": "NORMAL",
"client_order_id": client_order_id,
"symbol": "AAPL",
"instrument_type": "EQUITY",
"market": "US",
"order_type": "LIMIT",
"limit_price": "180",
"quantity": "1",
"side": "BUY",
"time_in_force": "DAY",
"entrust_type": "QTY",
"support_trading_session": "CORE",
"account_tax_type": "GENERAL"
}
]
# Step 1: Preview the order
res = trade_client.order_v3.preview_order(ACCOUNT_ID, new_orders)
if res.status_code == 200:
print("Preview:", res.json())
# Step 2: Place the order
res = trade_client.order_v3.place_order(ACCOUNT_ID, new_orders)
if res.status_code == 200:
print("Placed:", res.json())
sleep(3)
# Query order after placing
res = trade_client.order_v3.get_order_detail(ACCOUNT_ID, client_order_id)
if res.status_code == 200:
print("Detail after place:", res.json())
# Step 3: Replace (modify) the order
replace_orders = [
{
"client_order_id": client_order_id,
"quantity": "5",
"limit_price": "180"
}
]
res = trade_client.order_v3.replace_order(ACCOUNT_ID, replace_orders)
if res.status_code == 200:
print("Replaced:", res.json())
sleep(3)
# Query order after replacing
res = trade_client.order_v3.get_order_detail(ACCOUNT_ID, client_order_id)
if res.status_code == 200:
print("Detail after replace:", res.json())
# Step 4: Cancel the order
res = trade_client.order_v3.cancel_order(ACCOUNT_ID, client_order_id)
if res.status_code == 200:
print("Cancelled:", res.json())
sleep(3)
# Query order after cancelling
res = trade_client.order_v3.get_order_detail(ACCOUNT_ID, client_order_id)
if res.status_code == 200:
print("Detail after cancel:", res.json())
Key Parameters
| Parameter | Required | Description |
|---|---|---|
account_id | Yes | Trading account identifier |
client_order_id | Yes | Unique client-defined order ID (max 32 chars, must be unique per account) |
combo_type | Yes | NORMAL for standard single orders |
symbol | Yes | Trading symbol (e.g., AAPL, 7203) |
instrument_type | Yes | EQUITY for stock orders |
market | Yes | US or JP |
order_type | Yes | Order type — see table below |
side | Yes | BUY or SELL |
quantity | Yes | Number of shares |
entrust_type | Yes | QTY (by quantity) |
time_in_force | Yes | DAY or GTC |
limit_price | Conditional | Required for LIMIT, STOP_LOSS_LIMIT |
stop_price | Conditional | Required for STOP_LOSS, STOP_LOSS_LIMIT |
Supported Order Types
| Order Type | Description |
|---|---|
MARKET | Execute immediately at the best available price |
LIMIT | Execute at the specified price or better |
STOP_LOSS | Trigger a market order when the stop price is reached |
STOP_LOSS_LIMIT | Trigger a limit order when the stop price is reached |
Time in Force
| Value | Description |
|---|---|
DAY | Valid for the current trading day only |
GTC | Good till cancelled — remains active until filled or manually cancelled |
Request Examples
- Limit
- Market
- Stop Loss
- Stop Loss Limit
Buy 10 shares of AAPL at a limit price of $180, valid for the current trading day.
{
"account_id": "<your_account_id>",
"new_orders": [
{
"client_order_id": "<unique_id>",
"combo_type": "NORMAL",
"symbol": "AAPL",
"instrument_type": "EQUITY",
"market": "US",
"order_type": "LIMIT",
"limit_price": "180.00",
"quantity": "10",
"side": "BUY",
"time_in_force": "DAY",
"entrust_type": "QTY"
}
]
}
Buy 5 shares of TSLA at market price.
{
"account_id": "<your_account_id>",
"new_orders": [
{
"client_order_id": "<unique_id>",
"combo_type": "NORMAL",
"symbol": "TSLA",
"instrument_type": "EQUITY",
"market": "US",
"order_type": "MARKET",
"quantity": "5",
"side": "BUY",
"time_in_force": "DAY",
"entrust_type": "QTY"
}
]
}
Sell 20 shares of NVDA when the price drops to $100 (triggers a market order).
{
"account_id": "<your_account_id>",
"new_orders": [
{
"client_order_id": "<unique_id>",
"combo_type": "NORMAL",
"symbol": "NVDA",
"instrument_type": "EQUITY",
"market": "US",
"order_type": "STOP_LOSS",
"stop_price": "100.00",
"quantity": "20",
"side": "SELL",
"time_in_force": "GTC",
"entrust_type": "QTY"
}
]
}
Sell 10 shares of AMZN when the price drops to $180 (stop), then place a limit order at $178.
{
"account_id": "<your_account_id>",
"new_orders": [
{
"client_order_id": "<unique_id>",
"combo_type": "NORMAL",
"symbol": "AMZN",
"instrument_type": "EQUITY",
"market": "US",
"order_type": "STOP_LOSS_LIMIT",
"stop_price": "180.00",
"limit_price": "178.00",
"quantity": "10",
"side": "SELL",
"time_in_force": "GTC",
"entrust_type": "QTY"
}
]
}
What's Next
- Trading API Overview — Full feature matrix by market
- Trading API FAQ — Common questions and troubleshooting