Webull is a D library for the Webull OpenAPI, providing authenticated access to market data plus typed account access for account lists, balances, profiles, and positions.
- HMAC-SHA1 Signing - Automatic request signing with app key/secret
- Token Lifecycle - Create, poll, and cache authentication tokens with MFA support
- Permission Detection - Runtime probing of available API permissions
- Configurable Endpoint - Switch between production, UAT, or local dummy endpoints via
Client.endpoint
- Bars - OHLCV candlestick data with configurable timespans (M1 through yearly)
- Snapshots - Real-time price, volume, and change data with extended/overnight hours
- Order Book - Level-2 quotes with configurable depth
- Ticks - Individual trade records with volume and direction
- Footprint - Delta volume analysis with buy/sell level breakdowns
- Account List - Discover all accounts available to the app key
- Account Profile - Fetch static account metadata like account number, type, and status
- Account Balance - Retrieve total assets, buying power, and per-currency balances
- Account Positions - Auto-paginate holdings into typed position records
- US Stocks -
US_STOCK - US Options -
US_OPTION - Hong Kong Stocks -
HK_STOCK - China Stocks -
CN_STOCK - Cryptocurrency -
CRYPTO - Futures -
FUTURES
Requirements:
- D compiler (DMD/LDC)
- Webull OpenAPI credentials (key + secret)
Setup:
import webull.client;
import webull.account;
// Configure credentials
Client.key = "your_app_key";
Client.secret = "your_app_secret";
Client.endpoint = "https://api.webull.com";
// Access accounts
auto accounts = getAccounts();
foreach (account; accounts)
{
getAccountProfile(account);
getAccountBalance(account, "USD");
getAccountPositions(account, 100);
writeln(account.accountId, " => ", account.balance("USD").totalAsset);
}createToken()- Initiate authentication with optional polling callbackcheckToken()- Validate current token statusdetectPermissions()- Probe available API endpointsaccounts()- Convenience helper that returns account IDsendpoint- Override the API base URL, e.g.https://api.webull.com
autoUpdate- Automatic refresh of cached market databars()- Retrieve OHLCV historysnapshot()- Current quote dataorderBook()- Bid/ask levelsticks()- Recent trades
getAccounts()- Retrieve typed account objectsgetAccountProfile()- Populate static account metadatagetAccountBalance()- Populate balance and per-currency asset detailsgetAccountPositions()- Retrieve all holdings with pagination handled internallyAccount.profile()/Account.balance()/Account.positions()- Lazy convenience accessors
getBars()- Single or batch bar retrievalgetSnapshot()- Single or batch snapshotsgetOrderBook()- Level-2 market depthgetTicks()- Trade tick historygetFootprint()- Volume delta analysis
webull.client- Authentication state and token managementwebull.account- Typed account, balance, profile, and position accesswebull.security- Security objects with auto-updating data accessorswebull.market- Market data endpoints (bars, quotes, ticks, snapshots, footprint)webull.orchestrate- HMAC-SHA1 request signing and HTTP orchestration
- Run the account console demo:
dub run -c account-console-demo - Force the demo into simulated screenshot mode:
WEBULL_DEMO_MODE=simulate dub run -c account-console-demo - Render a specific screenshot-ready view:
WEBULL_DEMO_MODE=simulate WEBULL_DEMO_VIEW=overview dub run -c account-console-demo - Available views:
overview,margin,cash,holdings - Unmask digits in the demo output:
WEBULL_MASK_NUMBERS=0 dub run -c account-console-demo - Run dummy tests against the local validation server:
dub test -c dummy-tests - Run live tests if you have credentials available:
dub test -c live-tests - Run both suites together:
dub test -c full-tests
- HMAC-SHA1 authentication
- Token lifecycle management
- Bars API (single + batch)
- Snapshots API (single + batch)
- Order book API
- Tick data API
- Footprint API
- Account list API
- Account balance API
- Account profile API
- Account positions API
- WebSocket streaming
- Order placement API
Webull is licensed under the AGPL-3.0 license.