OKX
A leading cryptocurrency exchange with a unified trading account that supports spot, margin, perpetuals, futures, and options.
Overview
| Property | Value |
|---|---|
| Website | okx.com |
| Account Model | Unified account |
| Passphrase Required | Yes |
| API Documentation | OKX API Docs |
Credential Requirements
| Field | Required | Description |
|---|---|---|
apiKey | ✓ | API Key from OKX |
apiSecret | ✓ | Secret Key from OKX |
apiPassphrase | ✓ | Passphrase set during API creation |
note
OKX requires a passphrase that you set when creating the API key. Store it securely as you'll need it when creating credentials in Cadenza.
Account Types
OKX uses a unified account model. All trading products share the same collateral.
| External ID | Account Type | Description |
|---|---|---|
trading | UNIFIED | Unified trading account (spot, margin, derivatives) |
funding | FUNDING | Funding account for deposits/withdrawals |
Trading Features
| Feature | Supported | Notes |
|---|---|---|
| Spot Trading | ✓ | |
| Cross Margin | ✓ | Unified account margin |
| Isolated Margin | ✓ | Per-position margin |
| Perpetual Swaps | ✓ | USDT and Crypto margined |
| Expiring Futures | ✓ | Weekly, bi-weekly, quarterly |
| Options | ✓ | European-style options |
Margin Modes
OKX unified account supports multiple margin modes:
| Mode | Description |
|---|---|
| Cross | All positions share account margin |
| Isolated | Each position has dedicated margin |
| Portfolio | Cross-product margining with correlation benefits |
Supported Order Types
| Order Type | Spot | Margin | Derivatives |
|---|---|---|---|
| Market | ✓ | ✓ | ✓ |
| Limit | ✓ | ✓ | ✓ |
| Stop Limit | ✓ | ✓ | ✓ |
| Stop Market | ✓ | ✓ | ✓ |
| Trailing Stop | - | - | ✓ |
| Iceberg | ✓ | ✓ | ✓ |
| TWAP | ✓ | ✓ | ✓ |
API Key Setup
Step 1: Access API Management
- Log in to OKX
- Click on your profile icon
- Select API from the dropdown
Step 2: Create API Key
- Click Create API Key
- Select Trading as the purpose
- Set a Passphrase (required, save it securely!)
- Complete verification
Step 3: Configure Permissions
| Permission | Description | Required For |
|---|---|---|
| Read | Read account info, balances, orders | All operations |
| Trade | Execute orders | Trading |
warning
Never enable "Withdraw" - Cadenza does not require withdrawal permissions.
Step 4: IP Restrictions (Recommended)
- Enable IP restriction
- Add Cadenza's IP addresses
- Click Confirm
Step 5: Save Credentials
Save all three values securely:
- API Key
- Secret Key
- Passphrase
Rate Limits
| Endpoint Type | Limit |
|---|---|
| Order placement | 60 requests/2 seconds |
| Order cancellation | 60 requests/2 seconds |
| Order query | 20 requests/2 seconds |
Example: Create OKX Credential
- Python
- TypeScript
- Go
response = credential_api.create_trading_account_credential(
cadenza_client.CreateTradingAccountCredentialRequest(
venue=cadenza_client.Venue.OKX,
credential_type=cadenza_client.CredentialType.EXCHANGE,
api_key="your-okx-api-key",
api_secret="your-okx-secret-key",
api_passphrase="your-okx-passphrase", # Required for OKX
nickname="My OKX API"
)
)
const response = await credentialApi.createTradingAccountCredential({
venue: 'OKX',
credentialType: 'EXCHANGE',
apiKey: 'your-okx-api-key',
apiSecret: 'your-okx-secret-key',
apiPassphrase: 'your-okx-passphrase', // Required for OKX
nickname: 'My OKX API',
})
response, _, err := apiClient.TradingAccountCredentialAPI.CreateTradingAccountCredential(ctx).
CreateTradingAccountCredentialRequest(client.CreateTradingAccountCredentialRequest{
Venue: client.VENUE_OKX,
CredentialType: client.CREDENTIALTYPE_EXCHANGE,
ApiKey: client.PtrString("your-okx-api-key"),
ApiSecret: client.PtrString("your-okx-secret-key"),
ApiPassphrase: client.PtrString("your-okx-passphrase"), // Required for OKX
Nickname: client.PtrString("My OKX API"),
}).Execute()
Example: Connect OKX Account
- Python
- TypeScript
- Go
# Connect unified trading account
response = trading_account_api.connect_trading_account(
cadenza_client.ConnectTradingAccountRequest(
credential_ids=[credential_id],
external_trading_account_id="trading",
nickname="OKX Trading"
)
)
trading_account_id = response.data.trading_account_id
print(f"Connected: {trading_account_id}")
// Connect unified trading account
const response = await tradingAccountApi.connectTradingAccount({
credentialIds: [credentialId],
externalTradingAccountId: 'trading',
nickname: 'OKX Trading',
})
const tradingAccountId = response.data.data.tradingAccountId
console.log('Connected:', tradingAccountId)
// Connect unified trading account
response, _, err := apiClient.TradingAccountAPI.ConnectTradingAccount(ctx).
ConnectTradingAccountRequest(client.ConnectTradingAccountRequest{
CredentialIds: []string{credentialId},
ExternalTradingAccountId: "trading",
Nickname: client.PtrString("OKX Trading"),
}).Execute()
tradingAccountId := *response.Data.TradingAccountId
fmt.Printf("Connected: %s\n", tradingAccountId)
Instrument ID Format
OKX instruments use the format: OKX:{BASE}/{QUOTE}
| Instrument Type | Example |
|---|---|
| Spot | OKX:BTC/USDT |
| Perpetual (USDT) | OKX:BTC/USDT:USDT |
| Perpetual (Crypto) | OKX:BTC/USD:BTC |
| Futures | OKX:BTC/USD:BTC-240329 |
| Options | OKX:BTC/USD:BTC-240329-50000-C |
Unified Account Benefits
- Single margin pool - All positions share collateral
- Cross-product hedging - Offset risk across products
- No transfers needed - Trade any product instantly
- Better capital efficiency - Lower margin requirements