Skip to main content

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:

  1. Preview — Estimate costs and fees before committing
  2. Place — Submit the order
  3. Replace — Modify price or quantity while the order is open
  4. 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

ParameterRequiredDescription
account_idYesTrading account identifier
client_order_idYesUnique client-defined order ID (max 32 chars, must be unique per account)
combo_typeYesNORMAL for standard single orders
symbolYesTrading symbol (e.g., AAPL, 7203)
instrument_typeYesEQUITY for stock orders
marketYesUS or JP
order_typeYesOrder type — see table below
sideYesBUY or SELL
quantityYesNumber of shares
entrust_typeYesQTY (by quantity)
time_in_forceYesDAY or GTC
limit_priceConditionalRequired for LIMIT, STOP_LOSS_LIMIT
stop_priceConditionalRequired for STOP_LOSS, STOP_LOSS_LIMIT

Supported Order Types

Order TypeDescription
MARKETExecute immediately at the best available price
LIMITExecute at the specified price or better
STOP_LOSSTrigger a market order when the stop price is reached
STOP_LOSS_LIMITTrigger a limit order when the stop price is reached

Time in Force

ValueDescription
DAYValid for the current trading day only
GTCGood till cancelled — remains active until filled or manually cancelled

Request Examples

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"
}
]
}

What's Next