| Title: | R Interface to the 'OKX' REST API |
|---|---|
| Description: | Provides lightweight R wrappers for the 'OKX' REST API, covering endpoints for market data, trading, account management, asset balances, and copy trading. The upstream API reference is available at <https://www.okx.com/docs-v5/en/>. |
| Authors: | Oliver Zhou [aut, cre], Lily Li [aut] |
| Maintainer: | Oliver Zhou <[email protected]> |
| License: | MIT + file LICENSE |
| Version: | 0.4.5 |
| Built: | 2026-06-07 06:47:23 UTC |
| Source: | https://github.com/oliverlds/okxr |
'okxr' provides lightweight wrappers for selected OKX REST API endpoints, including market data, account information, asset metadata, order-book trade queries, trading actions, and copy-trading endpoints.
Public market and public reference endpoints can be called without credentials. Private account, asset, trade, and copy-trading endpoints require an OKX API credential list with 'api_key', 'secret_key', and 'passphrase' entries.
If ‘config$demo' is 'TRUE', signed requests include OKX’s simulated trading header. Request timeout defaults to 10 seconds and can be set globally with 'set_okxr_options(timeout = 15)' or per request with 'config$timeout'.
By default, wrappers return parsed 'data.table' objects. Use 'set_okxr_options(raw_data = TRUE)' to return raw API 'data' payloads instead.
Network failures, request timeouts, OKX error responses, or empty API 'data' payloads may return 'NULL' with a warning. Live API examples are intentionally non-running because they require credentials, network access, and may have account-specific side effects.
Maintainer: Oliver Zhou [email protected]
Authors:
Lily Li [email protected]
[set_okxr_options()], [get_market_candles()], [post_trade_order()]
Assemble URL, headers, and body for an OKX API call.
.build_request( httr_method, base_url, api_path, query_string, config = NULL, body_json = "", auth = TRUE ).build_request( httr_method, base_url, api_path, query_string, config = NULL, body_json = "", auth = TRUE )
httr_method |
HTTP method ("GET" or "POST"). |
base_url |
Base URL of the OKX API. |
api_path |
API path (e.g., "/api/v5/account/balance"). |
query_string |
Query string starting with "?" or empty. |
config |
List with API credentials. |
body_json |
Optional JSON string for POST body. |
auth |
Logical. Whether to sign the request with OKX credentials. |
A list with elements: 'method', 'url', 'full_path', 'headers', and 'body_json'.
Perform a signed GET call to the OKX API.
.execute_get_action( api_path, query_string, config = NULL, auth = TRUE ).execute_get_action( api_path, query_string, config = NULL, auth = TRUE )
api_path |
API path (e.g., "/api/v5/account/balance"). |
query_string |
Query string starting with "?" or empty. |
config |
List with API credentials. |
auth |
Logical. Whether to sign the request with OKX credentials. |
An 'httr' response object, or 'NULL' if the request fails.
Perform a signed POST call to the OKX API.
.execute_post_action(api_path, body_list, config).execute_post_action(api_path, body_list, config)
api_path |
API path (e.g., "/api/v5/trade/order"). |
body_list |
List to be converted to JSON for the request body. |
config |
List with API credentials. |
An 'httr' response object, or 'NULL' if the request fails.
Generate the required signed headers for an OKX REST request.
.get_headers(config, httr_method, httr_path, body_json = "").get_headers(config, httr_method, httr_path, body_json = "")
config |
List with 'api_key', 'secret_key', and 'passphrase'. |
httr_method |
HTTP method as a string (e.g., "GET" or "POST"). |
httr_path |
Path portion of the API endpoint. |
body_json |
Optional JSON string of the request body. |
A 'httr::add_headers' object containing the signed headers.
Estimate account effects under a target leverage.
get_account_adjust_leverage_info( inst_type, mgn_mode, lever, inst_id = NULL, ccy = NULL, pos_side = NULL, config, tz = .okx_default_tz )get_account_adjust_leverage_info( inst_type, mgn_mode, lever, inst_id = NULL, ccy = NULL, pos_side = NULL, config, tz = .okx_default_tz )
inst_type |
Character. Instrument type: '"MARGIN"', '"SWAP"', or '"FUTURES"'. |
mgn_mode |
Character. Margin mode: '"cross"' or '"isolated"'. |
lever |
Character or numeric. Target leverage. |
inst_id |
Character or 'NULL'. Instrument ID. |
ccy |
Character or 'NULL'. Margin currency. |
pos_side |
Character or 'NULL'. Position side. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A one-row 'data.frame' with estimated leverage-adjustment metrics.
Retrieve account-level margin and equity information for your OKX account.
get_account_balance(config, tz = .okx_default_tz)get_account_balance(config, tz = .okx_default_tz)
config |
List. API credentials/config, typically containing 'api_key', 'secret_key', and 'passphrase'. May also include 'base_url'. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
This wraps '/api/v5/account/balance'. Returns one row per account-level equity snapshot. Timestamps are parsed into 'POSIXct' in the given 'tz'.
A 'data.frame' with account balance and margin metrics (e.g., 'totalEq', 'isoEq', 'adjEq', 'availEq', 'ordFroz', 'imr', 'mmr', 'upl', 'mgnRatio', ...). Timestamp columns ('uTime') are 'POSIXct'.
Since okxr 0.1.1
[get_account_positions()], [get_account_leverage_info()]
## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") bal <- get_account_balance(config = cfg) head(bal) ## End(Not run)## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") bal <- get_account_balance(config = cfg) head(bal) ## End(Not run)
Retrieve account bill details from the last 7 days.
get_account_bills( inst_type = NULL, ccy = NULL, mgn_mode = NULL, ct_type = NULL, type = NULL, sub_type = NULL, after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )get_account_bills( inst_type = NULL, ccy = NULL, mgn_mode = NULL, ct_type = NULL, type = NULL, sub_type = NULL, after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )
inst_type |
Character or 'NULL'. Instrument type filter. |
ccy |
Character or 'NULL'. Currency filter. |
mgn_mode |
Character or 'NULL'. Margin mode filter. |
ct_type |
Character or 'NULL'. Contract type filter. |
type |
Character or 'NULL'. Bill type filter. |
sub_type |
Character or 'NULL'. Bill subtype filter. |
after |
Character or 'NULL'. Pagination cursor for earlier records. |
before |
Character or 'NULL'. Pagination cursor for newer records. |
limit |
Integer or 'NULL'. Number of rows to request. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with account bill rows.
Retrieve archived account bill details.
get_account_bills_archive( inst_type = NULL, ccy = NULL, mgn_mode = NULL, ct_type = NULL, type = NULL, sub_type = NULL, after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )get_account_bills_archive( inst_type = NULL, ccy = NULL, mgn_mode = NULL, ct_type = NULL, type = NULL, sub_type = NULL, after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )
inst_type |
Character or 'NULL'. Instrument type filter. |
ccy |
Character or 'NULL'. Currency filter. |
mgn_mode |
Character or 'NULL'. Margin mode filter. |
ct_type |
Character or 'NULL'. Contract type filter. |
type |
Character or 'NULL'. Bill type filter. |
sub_type |
Character or 'NULL'. Bill subtype filter. |
after |
Character or 'NULL'. Pagination cursor for earlier records. |
before |
Character or 'NULL'. Pagination cursor for newer records. |
limit |
Integer or 'NULL'. Number of rows to request. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with archived account bill rows.
Retrieve the generated CSV export link for historical account bills since 2021.
get_account_bills_history_archive( year, quarter, type = NULL, config, tz = .okx_default_tz )get_account_bills_history_archive( year, quarter, type = NULL, config, tz = .okx_default_tz )
year |
Character or numeric. Four-digit year. |
quarter |
Character. Quarter code, one of '"Q1"' to '"Q4"'. |
type |
Character or 'NULL'. Optional comma-separated bill type filter. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with file-link status rows.
Retrieve collateral-enabled status for one or more currencies.
get_account_collateral_assets( ccy = NULL, collateral_enabled = NULL, config, tz = .okx_default_tz )get_account_collateral_assets( ccy = NULL, collateral_enabled = NULL, config, tz = .okx_default_tz )
ccy |
Character or 'NULL'. One currency or a comma-separated list of up to 20 currencies. |
collateral_enabled |
Logical, character, or 'NULL'. Filter by collateral status. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with currency-level collateral flags.
Retrieve account-level configuration information.
get_account_config(config, tz = .okx_default_tz)get_account_config(config, tz = .okx_default_tz)
config |
List. API credentials/config, typically containing 'api_key', 'secret_key', and 'passphrase'. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
Wraps '/api/v5/account/config'. Includes account ID, mode, and position mode flags. Returns one row.
A 'data.frame' with columns like 'uid', 'mainUid', 'acctLv', 'posMode', 'autoLoan', etc.
Since okxr 0.1.2
[get_account_balance()], [get_account_leverage_info()]
## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") cfg_info <- get_account_config(config = cfg) cfg_info ## End(Not run)## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") cfg_info <- get_account_config(config = cfg) cfg_info ## End(Not run)
Retrieve currency-level Greeks across the account.
get_account_greeks(ccy = NULL, config, tz = .okx_default_tz)get_account_greeks(ccy = NULL, config, tz = .okx_default_tz)
ccy |
Character or 'NULL'. Currency filter. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with one row per currency and Greek metrics in both Black-Scholes and coin terms.
Retrieve available instruments for the current account and instrument type.
get_account_instruments( inst_type, uly = NULL, inst_family = NULL, inst_id = NULL, config, tz = .okx_default_tz )get_account_instruments( inst_type, uly = NULL, inst_family = NULL, inst_id = NULL, config, tz = .okx_default_tz )
inst_type |
Character. Instrument type. One of '"SPOT"', '"MARGIN"', '"SWAP"', '"FUTURES"', '"OPTION"'. |
uly |
Character or 'NULL'. Underlying, where applicable. |
inst_family |
Character or 'NULL'. Instrument family filter. |
inst_id |
Character or 'NULL'. Specific instrument ID filter. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
Wraps '/api/v5/account/instruments'. This endpoint is account-scoped and may return a subset of instruments available to the authenticated account.
A 'data.frame' with account-available instrument metadata, including identifiers, currencies, tick size, lot size, leverage, expiry/listing timestamps, and state where returned by OKX.
Retrieve accrued borrowing interest records for the past year.
get_account_interest_accrued( type = NULL, ccy = NULL, inst_id = NULL, mgn_mode = NULL, after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )get_account_interest_accrued( type = NULL, ccy = NULL, inst_id = NULL, mgn_mode = NULL, after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )
type |
Character or 'NULL'. Loan type. Currently '"2"' for market loans. |
ccy |
Character or 'NULL'. Loan currency. |
inst_id |
Character or 'NULL'. Instrument ID. |
mgn_mode |
Character or 'NULL'. Margin mode. |
after |
Character or 'NULL'. Pagination cursor for earlier rows. |
before |
Character or 'NULL'. Pagination cursor for newer rows. |
limit |
Integer or 'NULL'. Number of rows to request. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with one row per accrued-interest event.
Retrieve account-level debt, next accrual timestamps, and nested per-currency borrowing-limit records.
get_account_interest_limits( type = NULL, ccy = NULL, config, tz = .okx_default_tz )get_account_interest_limits( type = NULL, ccy = NULL, config, tz = .okx_default_tz )
type |
Character or 'NULL'. Loan type. Currently '"2"' for market loans. |
ccy |
Character or 'NULL'. Loan currency. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with account-level limit fields; nested per-currency 'records' are JSON-encoded.
Retrieve the current leveraged currency borrowing market interest rate for one currency or for all eligible currencies.
get_account_interest_rate( ccy = NULL, config, tz = .okx_default_tz )get_account_interest_rate( ccy = NULL, config, tz = .okx_default_tz )
ccy |
Character or 'NULL'. Currency filter, e.g. '"BTC"'. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with 'ccy' and 'interestRate'.
Retrieve leverage configuration for a given instrument and margin mode.
get_account_leverage_info( inst_id, mgn_mode, config, tz = .okx_default_tz )get_account_leverage_info( inst_id, mgn_mode, config, tz = .okx_default_tz )
inst_id |
Character. Instrument ID, e.g. '"BTC-USDT"'. |
mgn_mode |
Character. Margin mode. One of '"cross"' or '"isolated"'. |
config |
List. API credentials/config, typically containing 'api_key', 'secret_key', and 'passphrase'. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
Wraps '/api/v5/account/leverage-info'. Requires both 'inst_id' and 'mgn_mode'. Returns current leverage values (numeric).
A 'data.frame' with columns 'instId', 'mgnMode', 'posSide', and 'lever'.
Since okxr 0.1.1
[get_account_balance()], [get_account_positions()]
## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") get_account_leverage_info( inst_id = "BTC-USDT", mgn_mode = "cross", config = cfg ) ## End(Not run)## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") get_account_leverage_info( inst_id = "BTC-USDT", mgn_mode = "cross", config = cfg ) ## End(Not run)
Retrieve the maximum available buy and sell amount for an instrument under the requested trade mode.
get_account_max_avail_size( inst_id, td_mode, ccy = NULL, reduce_only = NULL, px = NULL, trade_quote_ccy = NULL, config, tz = .okx_default_tz )get_account_max_avail_size( inst_id, td_mode, ccy = NULL, reduce_only = NULL, px = NULL, trade_quote_ccy = NULL, config, tz = .okx_default_tz )
inst_id |
Character. One instrument ID or a comma-separated list of up to five IDs. |
td_mode |
Character. Trade mode: '"cross"', '"isolated"', '"cash"', or '"spot_isolated"'. |
ccy |
Character or 'NULL'. Margin currency where applicable. |
reduce_only |
Logical, character, or 'NULL'. Whether to reduce position only. Only applicable to margin endpoints that support it. |
px |
Character, numeric, or 'NULL'. Optional closing price, when supported by OKX. |
trade_quote_ccy |
Character or 'NULL'. Quote currency used for trading for spot instruments. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with 'instId', 'availBuy', and 'availSell'.
Retrieve the maximum loan for manual borrow or margin borrowing scenarios.
get_account_max_loan( mgn_mode, inst_id = NULL, ccy = NULL, mgn_ccy = NULL, trade_quote_ccy = NULL, config, tz = .okx_default_tz )get_account_max_loan( mgn_mode, inst_id = NULL, ccy = NULL, mgn_ccy = NULL, trade_quote_ccy = NULL, config, tz = .okx_default_tz )
mgn_mode |
Character. Margin mode: '"cross"' or '"isolated"'. |
inst_id |
Character or 'NULL'. Instrument ID(s). |
ccy |
Character or 'NULL'. Currency. |
mgn_ccy |
Character or 'NULL'. Margin currency. |
trade_quote_ccy |
Character or 'NULL'. Quote currency for trading. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with 'instId', 'mgnMode', 'mgnCcy', 'maxLoan', 'ccy', and 'side'.
Retrieve the maximum order quantity allowed for one or more instruments under the requested trade mode.
get_account_max_size( inst_id, td_mode, ccy = NULL, px = NULL, leverage = NULL, trade_quote_ccy = NULL, outcome = NULL, config, tz = .okx_default_tz )get_account_max_size( inst_id, td_mode, ccy = NULL, px = NULL, leverage = NULL, trade_quote_ccy = NULL, outcome = NULL, config, tz = .okx_default_tz )
inst_id |
Character. One instrument ID or a comma-separated list of up to five IDs in the same instrument type. |
td_mode |
Character. Trade mode: '"cross"', '"isolated"', '"cash"', or '"spot_isolated"'. |
ccy |
Character or 'NULL'. Margin currency where applicable. |
px |
Character, numeric, or 'NULL'. Optional price override. |
leverage |
Character, numeric, or 'NULL'. Optional leverage override. |
trade_quote_ccy |
Character or 'NULL'. Quote currency used for trading for spot instruments. |
outcome |
Character or 'NULL'. Events market outcome, '"yes"' or '"no"'. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with 'instId', 'ccy', 'maxBuy', and 'maxSell'.
Retrieve the maximum transferable amount from trading to funding account.
get_account_max_withdrawal( ccy = NULL, config, tz = .okx_default_tz )get_account_max_withdrawal( ccy = NULL, config, tz = .okx_default_tz )
ccy |
Character or 'NULL'. One currency or a comma-separated list of up to 20 currencies. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with per-currency maximum withdrawal values.
Retrieve option-market-maker-protection configuration for one or more instrument families.
get_account_mmp_config( inst_family = NULL, config, tz = .okx_default_tz )get_account_mmp_config( inst_family = NULL, config, tz = .okx_default_tz )
inst_family |
Character or 'NULL'. Instrument family filter. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with MMP configuration fields.
Retrieve move-position requests from the last three days.
get_account_move_positions_history( block_td_id = NULL, client_id = NULL, begin_ts = NULL, end_ts = NULL, limit = NULL, state = NULL, config, tz = .okx_default_tz )get_account_move_positions_history( block_td_id = NULL, client_id = NULL, begin_ts = NULL, end_ts = NULL, limit = NULL, state = NULL, config, tz = .okx_default_tz )
block_td_id |
Character or 'NULL'. OKX block trade identifier. |
client_id |
Character or 'NULL'. Client-supplied identifier. |
begin_ts |
Character or 'NULL'. Inclusive start timestamp in milliseconds. |
end_ts |
Character or 'NULL'. Inclusive end timestamp in milliseconds. |
limit |
Integer or 'NULL'. Number of rows to request. |
state |
Character or 'NULL'. Transfer state filter, '"filled"' or '"pending"'. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with top-level move-position metadata; nested 'legs' are JSON-encoded.
Retrieve account-level adjusted equity together with same-snapshot balance and position risk payloads.
get_account_position_risk( inst_type = NULL, config, tz = .okx_default_tz )get_account_position_risk( inst_type = NULL, config, tz = .okx_default_tz )
inst_type |
Character or 'NULL'. Instrument type filter. One of '"MARGIN"', '"SWAP"', '"FUTURES"', or '"OPTION"'. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with one row per OKX risk snapshot. Nested balance and position payloads are returned as JSON strings in 'balData' and 'posData'.
Retrieve portfolio-margin position limits for one or more instrument families.
get_account_position_tiers( inst_type, inst_family, config, tz = .okx_default_tz )get_account_position_tiers( inst_type, inst_family, config, tz = .okx_default_tz )
inst_type |
Character. Instrument type: '"SWAP"', '"FUTURES"', or '"OPTION"'. |
inst_family |
Character. One instrument family or a comma-separated list of up to five families. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with instrument-family position limits.
Retrieve all currently open positions under the account.
get_account_positions(config, tz = .okx_default_tz)get_account_positions(config, tz = .okx_default_tz)
config |
List. API credentials/config, typically containing 'api_key', 'secret_key', and 'passphrase'. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
Wraps '/api/v5/account/positions'. Returns one row per open position.
A 'data.frame' with columns such as 'instId', 'posId', 'posSide', 'pos', 'lever', 'avgPx', 'markPx', 'upl', 'realizedPnl', etc. Timestamps ('cTime', 'uTime') are 'POSIXct'.
Since okxr 0.1.1
[get_account_balance()], [get_account_positions_history()]
## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") pos <- get_account_positions(config = cfg) pos ## End(Not run)## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") pos <- get_account_positions(config = cfg) pos ## End(Not run)
Retrieve historical records of closed or adjusted positions.
get_account_positions_history(config, tz = .okx_default_tz)get_account_positions_history(config, tz = .okx_default_tz)
config |
List. API credentials/config, typically containing 'api_key', 'secret_key', and 'passphrase'. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
Wraps '/api/v5/account/positions-history'. Includes closed positions and their realized PnL. Returns one row per historical record.
A 'data.frame' with columns such as 'instId', 'posId', 'posSide', 'pos', 'lever', 'realizedPnl', 'fee', plus timestamp fields ('cTime', 'uTime').
Since okxr 0.1.1
[get_account_positions()]
## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") hist <- get_account_positions_history(config = cfg) tail(hist) ## End(Not run)## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") hist <- get_account_positions_history(config = cfg) tail(hist) ## End(Not run)
Retrieve unmatched information that blocks switching into the requested strategy type.
get_account_precheck_set_delta_neutral( stgy_type, config, tz = .okx_default_tz )get_account_precheck_set_delta_neutral( stgy_type, config, tz = .okx_default_tz )
stgy_type |
Character or numeric. Strategy type. '"0"' for general or '"1"' for delta neutral. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A one-row 'data.frame' with JSON-encoded unmatched information.
Retrieve portfolio-margin account risk flags and affected risk units.
get_account_risk_state(config, tz = .okx_default_tz)get_account_risk_state(config, tz = .okx_default_tz)
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A one-row 'data.frame' with the account risk flag and JSON-encoded risk-unit arrays.
Retrieve precheck information and any unmatched requirements for switching to a target account mode.
get_account_set_account_switch_precheck( acct_lv, config, tz = .okx_default_tz )get_account_set_account_switch_precheck( acct_lv, config, tz = .okx_default_tz )
acct_lv |
Character or numeric. Target account mode. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with switch-precheck fields; nested margin and unmatched-information structures are JSON-encoded.
Retrieve spot-mode borrow and repay history.
get_account_spot_borrow_repay_history( ccy = NULL, type = NULL, after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )get_account_spot_borrow_repay_history( ccy = NULL, type = NULL, after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )
ccy |
Character or 'NULL'. Currency filter. |
type |
Character or 'NULL'. Event type filter. |
after |
Character or 'NULL'. Pagination cursor for earlier rows. |
before |
Character or 'NULL'. Pagination cursor for newer rows. |
limit |
Integer or 'NULL'. Number of rows to request. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with one row per borrow or repay event.
Retrieve account-level trading balances for a sub-account from the master account.
get_account_subaccount_balances( sub_acct, config, tz = .okx_default_tz )get_account_subaccount_balances( sub_acct, config, tz = .okx_default_tz )
sub_acct |
Character. Sub-account name. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with account-level balance fields; nested per-currency 'details' are JSON-encoded.
Retrieve the maximum withdrawal information for a sub-account from the master account.
get_account_subaccount_max_withdrawal( sub_acct, ccy = NULL, config, tz = .okx_default_tz )get_account_subaccount_max_withdrawal( sub_acct, ccy = NULL, config, tz = .okx_default_tz )
sub_acct |
Character. Sub-account name. |
ccy |
Character or 'NULL'. One currency or a comma-separated list of up to 20 currencies. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with per-currency maximum withdrawal values.
Retrieve available account bill types and subtype descriptions.
get_account_subtypes(type = NULL, config, tz = .okx_default_tz)get_account_subtypes(type = NULL, config, tz = .okx_default_tz)
type |
Character or 'NULL'. Bill type filter. Multiple values may be provided as a comma-separated string. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with bill type descriptions and JSON-encoded 'subTypeDetails'.
Retrieve the account's trade fee schedule for a specific instrument type and optional instrument, instrument family, or trading fee group.
get_account_trade_fee( inst_type, inst_id = NULL, inst_family = NULL, group_id = NULL, config, tz = .okx_default_tz )get_account_trade_fee( inst_type, inst_id = NULL, inst_family = NULL, group_id = NULL, config, tz = .okx_default_tz )
inst_type |
Character. Instrument type. One of '"SPOT"', '"MARGIN"', '"SWAP"', '"FUTURES"', '"OPTION"', or '"EVENTS"'. |
inst_id |
Character or 'NULL'. Instrument ID for spot or margin. |
inst_family |
Character or 'NULL'. Instrument family for futures, swaps, or options. |
group_id |
Character or 'NULL'. Trading fee group ID. Use this by itself. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with fee level, fee-rate columns, and any nested 'feeGroup' or deprecated 'fiat' details JSON-encoded as strings.
Retrieve total account valuation for funding assets.
get_asset_asset_valuation( ccy = NULL, config, tz = .okx_default_tz )get_asset_asset_valuation( ccy = NULL, config, tz = .okx_default_tz )
ccy |
Character or 'NULL'. Valuation currency filter. |
config |
API credentials as a list with |
tz |
Timezone string. |
A data.frame with valuation summary rows.
Retrieves the available, total, and frozen balance for each asset in the account.
get_asset_balances(config, tz = .okx_default_tz)get_asset_balances(config, tz = .okx_default_tz)
config |
API credentials as a list with |
tz |
Timezone string (default: |
A data.frame with balances per currency.
Retrieve recent funding account bills.
get_asset_bills( ccy = NULL, type = NULL, client_id = NULL, after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )get_asset_bills( ccy = NULL, type = NULL, client_id = NULL, after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )
ccy |
Character or 'NULL'. Currency filter. |
type |
Character or 'NULL'. Bill type filter. |
client_id |
Character or 'NULL'. Client-supplied transfer or withdrawal ID. |
after |
Character or 'NULL'. Pagination cursor for earlier records. |
before |
Character or 'NULL'. Pagination cursor for newer records. |
limit |
Integer or 'NULL'. Number of results to request. |
config |
API credentials as a list with |
tz |
Timezone string. |
A data.frame with asset bill rows.
Retrieve historical funding account bills.
get_asset_bills_history( ccy = NULL, type = NULL, client_id = NULL, after = NULL, before = NULL, limit = NULL, paging_type = NULL, config, tz = .okx_default_tz )get_asset_bills_history( ccy = NULL, type = NULL, client_id = NULL, after = NULL, before = NULL, limit = NULL, paging_type = NULL, config, tz = .okx_default_tz )
ccy |
Character or 'NULL'. Currency filter. |
type |
Character or 'NULL'. Bill type filter. |
client_id |
Character or 'NULL'. Client-supplied transfer or withdrawal ID. |
after |
Character or 'NULL'. Pagination cursor for earlier records. |
before |
Character or 'NULL'. Pagination cursor for newer records. |
limit |
Integer or 'NULL'. Number of results to request. |
paging_type |
Character or 'NULL'. Paging type selector. |
config |
API credentials as a list with |
tz |
Timezone string. |
A data.frame with historical asset bill rows.
Retrieve currencies supported by the asset convert API.
get_asset_convert_currencies(config, tz = .okx_default_tz)get_asset_convert_currencies(config, tz = .okx_default_tz)
config |
API credentials as a list with |
tz |
Timezone string. |
A data.frame with supported convert currencies.
Retrieve convert metadata for a currency pair.
get_asset_convert_currency_pair( from_ccy, to_ccy, convert_mode = NULL, config, tz = .okx_default_tz )get_asset_convert_currency_pair( from_ccy, to_ccy, convert_mode = NULL, config, tz = .okx_default_tz )
from_ccy |
Character. Currency to convert from. |
to_ccy |
Character. Currency to convert to. |
convert_mode |
Character or 'NULL'. Convert mode selector. |
config |
API credentials as a list with |
tz |
Timezone string. |
A data.frame with currency-pair convert metadata.
Retrieve historical asset convert trades.
get_asset_convert_history( cl_t_req_id = NULL, after = NULL, before = NULL, limit = NULL, tag = NULL, config, tz = .okx_default_tz )get_asset_convert_history( cl_t_req_id = NULL, after = NULL, before = NULL, limit = NULL, tag = NULL, config, tz = .okx_default_tz )
cl_t_req_id |
Character or 'NULL'. Client trade request ID. |
after |
Character or 'NULL'. Pagination cursor for earlier records. |
before |
Character or 'NULL'. Pagination cursor for newer records. |
limit |
Integer or 'NULL'. Number of results to request. |
tag |
Character or 'NULL'. Broker tag filter. |
config |
API credentials as a list with |
tz |
Timezone string. |
A data.frame with convert history rows.
Retrieve currencies available to the current account.
get_asset_currencies(ccy = NULL, config, tz = .okx_default_tz)get_asset_currencies(ccy = NULL, config, tz = .okx_default_tz)
ccy |
Character or 'NULL'. Single currency or comma-separated currencies. |
config |
API credentials as a list with |
tz |
Timezone string (default: |
A data.frame with currency and chain metadata.
Retrieve deposit addresses for a currency.
get_asset_deposit_address(ccy, config, tz = .okx_default_tz)get_asset_deposit_address(ccy, config, tz = .okx_default_tz)
ccy |
Character. Currency, e.g. |
config |
API credentials as a list with |
tz |
Timezone string (default: |
A data.frame with deposit address rows.
Retrieves a record of all asset deposits made to your account.
get_asset_deposit_history( ccy = NULL, dep_id = NULL, from_wd_id = NULL, tx_id = NULL, type = NULL, state = NULL, after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )get_asset_deposit_history( ccy = NULL, dep_id = NULL, from_wd_id = NULL, tx_id = NULL, type = NULL, state = NULL, after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )
ccy |
Character or 'NULL'. Currency filter. |
dep_id |
Character or 'NULL'. Deposit ID filter. |
from_wd_id |
Character or 'NULL'. Source withdrawal ID filter. |
tx_id |
Character or 'NULL'. Transaction hash filter. |
type |
Character or 'NULL'. Deposit type filter. |
state |
Character or 'NULL'. Deposit state filter. |
after |
Character or 'NULL'. Pagination cursor for earlier records. |
before |
Character or 'NULL'. Pagination cursor for newer records. |
limit |
Integer or 'NULL'. Number of rows to request. |
config |
API credentials as a list with |
tz |
Timezone string (default: |
A data.frame with deposit history rows and detailed transfer metadata.
Retrieve detailed status for a deposit or withdrawal.
get_asset_deposit_withdraw_status( wd_id = NULL, tx_id = NULL, ccy = NULL, to = NULL, chain = NULL, config, tz = .okx_default_tz )get_asset_deposit_withdraw_status( wd_id = NULL, tx_id = NULL, ccy = NULL, to = NULL, chain = NULL, config, tz = .okx_default_tz )
wd_id |
Character or 'NULL'. Withdrawal ID. |
tx_id |
Character or 'NULL'. Deposit transaction hash. |
ccy |
Character or 'NULL'. Currency filter used with |
to |
Character or 'NULL'. Destination address used with |
chain |
Character or 'NULL'. Chain identifier used with |
config |
API credentials as a list with |
tz |
Timezone string. |
A data.frame with detailed deposit/withdraw status rows.
Retrieve the public exchange list used by asset withdrawal metadata.
get_asset_exchange_list(tz = .okx_default_tz)get_asset_exchange_list(tz = .okx_default_tz)
tz |
Timezone string. |
A data.frame with exchange identifiers and names.
Retrieve balances and withdrawal metadata for non-tradable assets.
get_asset_non_tradable_assets( ccy = NULL, config, tz = .okx_default_tz )get_asset_non_tradable_assets( ccy = NULL, config, tz = .okx_default_tz )
ccy |
Character or 'NULL'. Currency filter. |
config |
API credentials as a list with |
tz |
Timezone string. |
A data.frame with non-tradable asset rows.
Retrieve the state of a funding transfer.
get_asset_transfer_state( trans_id = NULL, client_id = NULL, type = NULL, config, tz = .okx_default_tz )get_asset_transfer_state( trans_id = NULL, client_id = NULL, type = NULL, config, tz = .okx_default_tz )
trans_id |
Character or 'NULL'. Transfer ID. |
client_id |
Character or 'NULL'. Client-supplied transfer ID. |
type |
Character or 'NULL'. Transfer type. |
config |
API credentials as a list with |
tz |
Timezone string. |
A data.frame with transfer state rows.
Retrieves a record of all asset withdrawals from your account.
get_asset_withdrawal_history( ccy = NULL, wd_id = NULL, client_id = NULL, tx_id = NULL, type = NULL, state = NULL, after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )get_asset_withdrawal_history( ccy = NULL, wd_id = NULL, client_id = NULL, tx_id = NULL, type = NULL, state = NULL, after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )
ccy |
Character or 'NULL'. Currency filter. |
wd_id |
Character or 'NULL'. Withdrawal ID filter. |
client_id |
Character or 'NULL'. Client withdrawal ID filter. |
tx_id |
Character or 'NULL'. Transaction hash filter. |
type |
Character or 'NULL'. Withdrawal type filter. |
state |
Character or 'NULL'. Withdrawal state filter. |
after |
Character or 'NULL'. Pagination cursor for earlier records. |
before |
Character or 'NULL'. Pagination cursor for newer records. |
limit |
Integer or 'NULL'. Number of rows to request. |
config |
API credentials as a list with |
tz |
Timezone string (default: |
A data.frame with withdrawal history rows and detailed transfer metadata.
Retrieve your account-level copy trading configuration.
get_copy_trade_config(config, tz = .okx_default_tz)get_copy_trade_config(config, tz = .okx_default_tz)
config |
List. API credentials/config, typically containing 'api_key', 'secret_key', and 'passphrase'. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with top-level copy trading configuration fields. Nested 'details' are returned as a JSON string column.
Retrieve your currently active subpositions under copy trading.
get_copy_trade_current_subpos( inst_type = NULL, inst_id = NULL, after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )get_copy_trade_current_subpos( inst_type = NULL, inst_id = NULL, after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )
inst_type |
Character or 'NULL'. Instrument type filter. |
inst_id |
Character or 'NULL'. Instrument ID filter. |
after |
Character or 'NULL'. Pagination cursor for earlier records. |
before |
Character or 'NULL'. Pagination cursor for newer records. |
limit |
Integer or 'NULL'. Number of rows to request. |
config |
List. API credentials/config, typically containing 'api_key', 'secret_key', and 'passphrase'. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
Wraps '/api/v5/copytrading/current-subpositions'. Returns one row per subposition, associated with the relevant lead trader.
A 'data.frame' with fields like 'instId' and 'uniqueCode'.
Since okxr 0.1.2
[get_copy_trade_historical_subpos()]
## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") get_copy_trade_current_subpos(config = cfg) ## End(Not run)## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") get_copy_trade_current_subpos(config = cfg) ## End(Not run)
Retrieve your historical copy trading subpositions.
get_copy_trade_historical_subpos( inst_type = NULL, inst_id = NULL, after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )get_copy_trade_historical_subpos( inst_type = NULL, inst_id = NULL, after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )
inst_type |
Character or 'NULL'. Instrument type filter. |
inst_id |
Character or 'NULL'. Instrument ID filter. |
after |
Character or 'NULL'. Pagination cursor for earlier records. |
before |
Character or 'NULL'. Pagination cursor for newer records. |
limit |
Integer or 'NULL'. Number of rows to request. |
config |
List. API credentials/config, typically containing 'api_key', 'secret_key', and 'passphrase'. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
Wraps '/api/v5/copytrading/subpositions-history'. Returns one row per closed or historical subposition.
A 'data.frame' with fields like 'instId' and 'uniqueCode'.
Since okxr 0.1.2
[get_copy_trade_current_subpos()]
## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") hist <- get_copy_trade_historical_subpos(config = cfg) head(hist) ## End(Not run)## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") hist <- get_copy_trade_historical_subpos(config = cfg) head(hist) ## End(Not run)
Retrieve instruments currently available for copy trading.
get_copy_trade_instruments( inst_type = NULL, config, tz = .okx_default_tz )get_copy_trade_instruments( inst_type = NULL, config, tz = .okx_default_tz )
inst_type |
Character or 'NULL'. Instrument type filter. |
config |
List. API credentials/config, typically containing 'api_key', 'secret_key', and 'passphrase'. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with one row per instrument and an 'enabled' flag.
Retrieve the list of lead traders you are currently copying.
get_copy_trade_my_leaders( inst_type = NULL, config, tz = .okx_default_tz, instType = inst_type )get_copy_trade_my_leaders( inst_type = NULL, config, tz = .okx_default_tz, instType = inst_type )
inst_type |
Character or 'NULL'. Filter by instrument type (e.g., '"SWAP"', '"MARGIN"', '"SPOT"'). If 'NULL', returns all. |
config |
List. API credentials/config, typically containing 'api_key', 'secret_key', and 'passphrase'. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
instType |
Deprecated alias for 'inst_type'. |
Wraps '/api/v5/copytrading/current-lead-traders'. Returns one row per lead trader followed by your account.
A 'data.frame' with fields such as 'nickName' and 'uniqueCode'.
Since okxr 0.1.2
[get_copy_trade_settings()], [get_copy_trade_current_subpos()]
## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") get_copy_trade_my_leaders(inst_type = "SWAP", config = cfg) ## End(Not run)## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") get_copy_trade_my_leaders(inst_type = "SWAP", config = cfg) ## End(Not run)
Retrieve realized profit sharing detail rows.
get_copy_trade_profit_sharing_details( inst_type = NULL, after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )get_copy_trade_profit_sharing_details( inst_type = NULL, after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )
inst_type |
Character or 'NULL'. Instrument type filter. |
after |
Character or 'NULL'. Pagination cursor for earlier records. |
before |
Character or 'NULL'. Pagination cursor for newer records. |
limit |
Integer or 'NULL'. Number of rows to request. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with realized profit sharing rows.
Retrieve public copy trading limits and ratio bounds.
get_copy_trade_public_config( inst_type = NULL, tz = .okx_default_tz )get_copy_trade_public_config( inst_type = NULL, tz = .okx_default_tz )
inst_type |
Character or 'NULL'. Instrument type filter. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with public copy trading configuration fields.
Retrieve public copy trader summary metrics for a lead trader.
get_copy_trade_public_copy_traders( unique_code, inst_type = NULL, limit = NULL, tz = .okx_default_tz )get_copy_trade_public_copy_traders( unique_code, inst_type = NULL, limit = NULL, tz = .okx_default_tz )
unique_code |
Character. Lead trader unique code. |
inst_type |
Character or 'NULL'. Instrument type filter. |
limit |
Integer or 'NULL'. Number of rows to request. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with summary metrics and a JSON-string 'copyTraders' column for nested trader details.
Retrieve public current subpositions for a lead trader.
get_copy_trade_public_current_subpositions( unique_code, inst_type = NULL, after = NULL, before = NULL, limit = NULL, tz = .okx_default_tz )get_copy_trade_public_current_subpositions( unique_code, inst_type = NULL, after = NULL, before = NULL, limit = NULL, tz = .okx_default_tz )
unique_code |
Character. Lead trader unique code. |
inst_type |
Character or 'NULL'. Instrument type filter. |
after |
Character or 'NULL'. Pagination cursor for earlier records. |
before |
Character or 'NULL'. Pagination cursor for newer records. |
limit |
Integer or 'NULL'. Number of rows to request. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with one row per current public subposition.
Retrieve ranked public lead trader summaries.
get_copy_trade_public_lead_traders( inst_type = NULL, sort_type = NULL, state = NULL, min_lead_days = NULL, min_assets = NULL, max_assets = NULL, min_aum = NULL, max_aum = NULL, data_ver = NULL, page = NULL, limit = NULL, tz = .okx_default_tz )get_copy_trade_public_lead_traders( inst_type = NULL, sort_type = NULL, state = NULL, min_lead_days = NULL, min_assets = NULL, max_assets = NULL, min_aum = NULL, max_aum = NULL, data_ver = NULL, page = NULL, limit = NULL, tz = .okx_default_tz )
inst_type |
Character or 'NULL'. Instrument type filter. |
sort_type |
Character or 'NULL'. Rank sort selector. |
state |
Character or 'NULL'. Lead trader state filter. |
min_lead_days |
Character or 'NULL'. Minimum lead-days selector. |
min_assets |
Character or 'NULL'. Minimum assets filter. |
max_assets |
Character or 'NULL'. Maximum assets filter. |
min_aum |
Character or 'NULL'. Minimum assets-under-management filter. |
max_aum |
Character or 'NULL'. Maximum assets-under-management filter. |
data_ver |
Character or 'NULL'. Data version selector used for pagination. |
page |
Character or 'NULL'. Page number. |
limit |
Integer or 'NULL'. Number of rows to request. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with top-level ranking metadata and a JSON-string 'ranks' column for nested leader rows.
Retrieve public pnl time windows for a lead trader.
get_copy_trade_public_pnl( unique_code, last_days, inst_type = NULL, tz = .okx_default_tz )get_copy_trade_public_pnl( unique_code, last_days, inst_type = NULL, tz = .okx_default_tz )
unique_code |
Character. Lead trader unique code. |
last_days |
Character or numeric. OKX lookback selector. |
inst_type |
Character or 'NULL'. Instrument type filter. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with pnl windows and ratios.
Retrieve the most frequently traded currencies for a lead trader.
get_copy_trade_public_preference_currency( unique_code, inst_type = NULL, tz = .okx_default_tz )get_copy_trade_public_preference_currency( unique_code, inst_type = NULL, tz = .okx_default_tz )
unique_code |
Character. Lead trader unique code. |
inst_type |
Character or 'NULL'. Instrument type filter. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with preferred currencies and their ratios.
Retrieve public copy trading performance stats for a lead trader.
get_copy_trade_public_stats( unique_code, last_days, inst_type = NULL, tz = .okx_default_tz )get_copy_trade_public_stats( unique_code, last_days, inst_type = NULL, tz = .okx_default_tz )
unique_code |
Character. Lead trader unique code. |
last_days |
Character or numeric. OKX lookback selector. |
inst_type |
Character or 'NULL'. Instrument type filter. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with copy trading summary statistics.
Retrieve public historical subpositions for a lead trader.
get_copy_trade_public_subpositions_history( unique_code, inst_type = NULL, after = NULL, before = NULL, limit = NULL, tz = .okx_default_tz )get_copy_trade_public_subpositions_history( unique_code, inst_type = NULL, after = NULL, before = NULL, limit = NULL, tz = .okx_default_tz )
unique_code |
Character. Lead trader unique code. |
inst_type |
Character or 'NULL'. Instrument type filter. |
after |
Character or 'NULL'. Pagination cursor for earlier records. |
before |
Character or 'NULL'. Pagination cursor for newer records. |
limit |
Integer or 'NULL'. Number of rows to request. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with one row per historical public subposition.
Retrieve public weekly pnl series for a lead trader.
get_copy_trade_public_weekly_pnl( unique_code, inst_type = NULL, tz = .okx_default_tz )get_copy_trade_public_weekly_pnl( unique_code, inst_type = NULL, tz = .okx_default_tz )
unique_code |
Character. Lead trader unique code. |
inst_type |
Character or 'NULL'. Instrument type filter. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with weekly pnl windows and ratios.
Retrieve your account's copy trading configuration.
get_copy_trade_settings( unique_code, inst_type = NULL, config, tz = .okx_default_tz, uniqueCode = unique_code, instType = inst_type )get_copy_trade_settings( unique_code, inst_type = NULL, config, tz = .okx_default_tz, uniqueCode = unique_code, instType = inst_type )
unique_code |
Character. Lead trader unique code. |
inst_type |
Character or 'NULL'. Instrument type filter. |
config |
List. API credentials/config, typically containing 'api_key', 'secret_key', and 'passphrase'. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
uniqueCode |
Deprecated alias for 'unique_code'. |
instType |
Deprecated alias for 'inst_type'. |
Wraps '/api/v5/copytrading/copy-settings'. Returns one row with the current copy mode and copy state for the given 'unique_code'.
A 'data.frame' with fields like 'copyMode' and 'copyState'.
Since okxr 0.1.2
[get_copy_trade_my_leaders()], [get_copy_trade_current_subpos()]
## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") get_copy_trade_settings(unique_code = "1129E65755274C36", config = cfg) ## End(Not run)## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") get_copy_trade_settings(unique_code = "1129E65755274C36", config = cfg) ## End(Not run)
Retrieve total realized profit sharing by instrument type.
get_copy_trade_total_profit_sharing( inst_type = NULL, config, tz = .okx_default_tz )get_copy_trade_total_profit_sharing( inst_type = NULL, config, tz = .okx_default_tz )
inst_type |
Character or 'NULL'. Instrument type filter. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with total realized profit sharing rows.
Retrieve total unrealized profit sharing by instrument type.
get_copy_trade_total_unrealized_profit_sharing( inst_type = NULL, config, tz = .okx_default_tz )get_copy_trade_total_unrealized_profit_sharing( inst_type = NULL, config, tz = .okx_default_tz )
inst_type |
Character or 'NULL'. Instrument type filter. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with total unrealized profit sharing rows.
Retrieve unrealized profit sharing detail rows.
get_copy_trade_unrealized_profit_sharing_details( inst_type = NULL, config, tz = .okx_default_tz )get_copy_trade_unrealized_profit_sharing_details( inst_type = NULL, config, tz = .okx_default_tz )
inst_type |
Character or 'NULL'. Instrument type filter. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with unrealized profit sharing rows.
Retrieve the latest 24-hour block-trading volume for a single instrument.
get_market_block_ticker( inst_id, config = NULL, tz = .okx_default_tz )get_market_block_ticker( inst_id, config = NULL, tz = .okx_default_tz )
inst_id |
Character. Instrument ID. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A one-row 'data.frame' with block trading volume fields.
Retrieve the latest 24-hour block-trading volume for instruments under an instrument type.
get_market_block_tickers( inst_type, inst_family = NULL, config = NULL, tz = .okx_default_tz )get_market_block_tickers( inst_type, inst_family = NULL, config = NULL, tz = .okx_default_tz )
inst_type |
Character. Instrument type. |
inst_family |
Character or 'NULL'. Instrument family filter. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with one row per block ticker.
Retrieve the current order book for an instrument.
get_market_books( inst_id, sz = NULL, config = NULL, tz = .okx_default_tz )get_market_books( inst_id, sz = NULL, config = NULL, tz = .okx_default_tz )
inst_id |
Character. Instrument ID, e.g. '"BTC-USDT"'. |
sz |
Integer or 'NULL'. Order book depth. If 'NULL', OKX uses its endpoint default. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with JSON-encoded 'asks' and 'bids' columns plus 'ts'.
Retrieve the latest candlestick data for a given instrument and bar size.
get_market_candles( inst_id, bar, limit = 100L, config = NULL, tz = .okx_default_tz, standardize_names = TRUE )get_market_candles( inst_id, bar, limit = 100L, config = NULL, tz = .okx_default_tz, standardize_names = TRUE )
inst_id |
Character. Instrument ID, e.g. '"BTC-USDT"', '"ETH-USDT-SWAP"'. |
bar |
Character. Candlestick granularity, e.g. '"1m"', '"5m"', '"1H"', '"1D"'. |
limit |
Integer. Number of bars to retrieve. Default '100L'. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
standardize_names |
Logical. If 'TRUE' (default), renames columns to 'timestamp', 'open', 'high', 'low', 'close', 'volume', 'volQuote'. |
Wraps '/api/v5/market/candles'. Returns up to 'limit' bars, sorted by timestamp. Candlestick fields can be standardized to common OHLCV names via 'standardize_names = TRUE'.
A 'data.frame' with columns including 'timestamp', 'open', 'high', 'low', 'close', 'volume', and 'volQuote'. Timestamps are 'POSIXct' in 'tz'.
Since okxr 0.1.1
[get_market_history_candles()], [get_public_mark_price()]
## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") get_market_candles("BTC-USDT", bar = "5m", limit = 50, config = cfg) ## End(Not run)## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") get_market_candles("BTC-USDT", bar = "5m", limit = 50, config = cfg) ## End(Not run)
Retrieve the two-week average exchange rate series summary.
get_market_exchange_rate(config = NULL, tz = .okx_default_tz)get_market_exchange_rate(config = NULL, tz = .okx_default_tz)
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A one-row 'data.frame' with 'usdCny'.
Retrieve candlestick data before a specific datetime.
get_market_history_candles( inst_id, bar, before = NULL, limit = 100L, config = NULL, tz = .okx_default_tz, standardize_names = TRUE )get_market_history_candles( inst_id, bar, before = NULL, limit = 100L, config = NULL, tz = .okx_default_tz, standardize_names = TRUE )
inst_id |
Character. Instrument ID, e.g. '"BTC-USDT"'. |
bar |
Character. Candlestick granularity, e.g. '"1m"', '"5m"', '"1H"'. |
before |
Character or 'NULL'. Timestamp string like '"%Y-%m-%d %H:%M:%S"'. If 'NULL', fetch recent history. |
limit |
Integer. Number of bars to retrieve. Default '100L'. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
standardize_names |
Logical. If 'TRUE' (default), renames columns to 'timestamp', 'open', 'high', 'low', 'close', 'volume', 'volQuote'. |
Wraps '/api/v5/market/history-candles'. If 'before' is supplied, it is converted to milliseconds since epoch (in 'tz') and sent as 'after=...' (per OKX semantics: *return data before this time*).
A 'data.frame' of candlestick bars. If 'standardize_names = TRUE', column names are normalized. Timestamps are 'POSIXct' in 'tz'.
Since okxr 0.1.1
[get_market_candles()]
## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") get_market_history_candles( "ETH-USDT-SWAP", bar = "1H", before = "2025-08-20 00:00:00", config = cfg ) ## End(Not run)## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") get_market_history_candles( "ETH-USDT-SWAP", bar = "1H", before = "2025-08-20 00:00:00", config = cfg ) ## End(Not run)
Retrieve historical candlestick data for an index.
get_market_history_index_candles( inst_id, bar = NULL, after = NULL, before = NULL, limit = 100L, config = NULL, tz = .okx_default_tz, standardize_names = TRUE )get_market_history_index_candles( inst_id, bar = NULL, after = NULL, before = NULL, limit = 100L, config = NULL, tz = .okx_default_tz, standardize_names = TRUE )
inst_id |
Character. Index ID. |
bar |
Character or 'NULL'. Bar size. |
after |
Character or 'NULL'. Pagination cursor for older rows. |
before |
Character or 'NULL'. Pagination cursor for newer rows. |
limit |
Integer. Number of rows to request. Default '100L'. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
standardize_names |
Logical. If 'TRUE' (default), renames OHLC columns to 'timestamp', 'open', 'high', 'low', and 'close'. |
A 'data.frame' of historical index candlesticks.
Retrieve historical candlestick data for mark price.
get_market_history_mark_price_candles( inst_id, bar = NULL, after = NULL, before = NULL, limit = 100L, config = NULL, tz = .okx_default_tz, standardize_names = TRUE )get_market_history_mark_price_candles( inst_id, bar = NULL, after = NULL, before = NULL, limit = 100L, config = NULL, tz = .okx_default_tz, standardize_names = TRUE )
inst_id |
Character. Instrument ID. |
bar |
Character or 'NULL'. Bar size. |
after |
Character or 'NULL'. Pagination cursor for older rows. |
before |
Character or 'NULL'. Pagination cursor for newer rows. |
limit |
Integer. Number of rows to request. Default '100L'. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
standardize_names |
Logical. If 'TRUE' (default), renames OHLC columns to 'timestamp', 'open', 'high', 'low', and 'close'. |
A 'data.frame' of historical mark-price candlesticks.
Retrieve public trade history for an instrument.
get_market_history_trades( inst_id, type = NULL, after = NULL, before = NULL, limit = NULL, config = NULL, tz = .okx_default_tz )get_market_history_trades( inst_id, type = NULL, after = NULL, before = NULL, limit = NULL, config = NULL, tz = .okx_default_tz )
inst_id |
Character. Instrument ID, e.g. '"BTC-USDT"'. |
type |
Character or 'NULL'. Pagination type, using OKX values. |
after |
Character or 'NULL'. Pagination cursor for earlier records. |
before |
Character or 'NULL'. Pagination cursor for newer records. |
limit |
Integer or 'NULL'. Number of rows to request. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with historical public trades.
Retrieve the latest candlestick data for an index.
get_market_index_candles( inst_id, bar = NULL, after = NULL, before = NULL, limit = 100L, config = NULL, tz = .okx_default_tz, standardize_names = TRUE )get_market_index_candles( inst_id, bar = NULL, after = NULL, before = NULL, limit = 100L, config = NULL, tz = .okx_default_tz, standardize_names = TRUE )
inst_id |
Character. Index ID. |
bar |
Character or 'NULL'. Bar size. |
after |
Character or 'NULL'. Pagination cursor for older rows. |
before |
Character or 'NULL'. Pagination cursor for newer rows. |
limit |
Integer. Number of rows to request. Default '100L'. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
standardize_names |
Logical. If 'TRUE' (default), renames OHLC columns to 'timestamp', 'open', 'high', 'low', and 'close'. |
A 'data.frame' of index candlesticks.
Retrieve component-exchange information for an index.
get_market_index_components( index, config = NULL, tz = .okx_default_tz )get_market_index_components( index, config = NULL, tz = .okx_default_tz )
index |
Character. Index identifier, e.g. '"BTC-USD"'. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A one-row 'data.frame' with 'index', 'last', 'ts', and JSON-encoded 'components'.
Retrieve the latest public index-price snapshots.
get_market_index_tickers( quote_ccy = NULL, inst_id = NULL, config = NULL, tz = .okx_default_tz )get_market_index_tickers( quote_ccy = NULL, inst_id = NULL, config = NULL, tz = .okx_default_tz )
quote_ccy |
Character or 'NULL'. Quote currency filter. |
inst_id |
Character or 'NULL'. Specific index ID filter. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with one row per index ticker.
Retrieve recent candlestick data for the mark price of an instrument.
get_market_mark_price_candles( inst_id, bar = NULL, after = NULL, before = NULL, limit = 100L, config = NULL, tz = .okx_default_tz, standardize_names = TRUE )get_market_mark_price_candles( inst_id, bar = NULL, after = NULL, before = NULL, limit = 100L, config = NULL, tz = .okx_default_tz, standardize_names = TRUE )
inst_id |
Character. Instrument ID. |
bar |
Character or 'NULL'. Bar size. |
after |
Character or 'NULL'. Pagination cursor for older rows. |
before |
Character or 'NULL'. Pagination cursor for newer rows. |
limit |
Integer. Number of rows to request. Default '100L'. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
standardize_names |
Logical. If 'TRUE' (default), renames OHLC columns to 'timestamp', 'open', 'high', 'low', and 'close'. |
A 'data.frame' of mark-price candlesticks.
Retrieve recent option trades for all instruments under the same instrument family.
get_market_option_instrument_family_trades( inst_family, config = NULL, tz = .okx_default_tz )get_market_option_instrument_family_trades( inst_family, config = NULL, tz = .okx_default_tz )
inst_family |
Character. Instrument family, e.g. '"BTC-USD"'. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with recent option trades under the requested instrument family, including 'instId', 'tradeId', 'px', 'sz', 'side', and 'ts'.
Retrieve total platform order-book trading volume over the last 24 hours.
get_market_platform_24_volume( config = NULL, tz = .okx_default_tz )get_market_platform_24_volume( config = NULL, tz = .okx_default_tz )
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A one-row 'data.frame' with 'volUsd', 'volCny', and 'ts'.
Retrieve the latest ticker snapshot for a specific instrument.
get_market_ticker(inst_id, config = NULL, tz = .okx_default_tz)get_market_ticker(inst_id, config = NULL, tz = .okx_default_tz)
inst_id |
Character. Instrument ID, e.g. '"BTC-USDT"' or '"ETH-USDT-SWAP"'. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with the latest ticker fields returned by OKX.
Retrieve ticker snapshots for all instruments under an instrument type.
get_market_tickers( inst_type, uly = NULL, inst_family = NULL, config = NULL, tz = .okx_default_tz )get_market_tickers( inst_type, uly = NULL, inst_family = NULL, config = NULL, tz = .okx_default_tz )
inst_type |
Character. Instrument type, e.g. '"SPOT"', '"SWAP"', '"FUTURES"', or '"OPTION"'. |
uly |
Character or 'NULL'. Underlying. Optional filter for derivatives. |
inst_family |
Character or 'NULL'. Instrument family. Optional filter for derivatives and options. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with one row per ticker.
Retrieve recent public trades for an instrument.
get_market_trades( inst_id, limit = NULL, config = NULL, tz = .okx_default_tz )get_market_trades( inst_id, limit = NULL, config = NULL, tz = .okx_default_tz )
inst_id |
Character. Instrument ID, e.g. '"BTC-USDT"'. |
limit |
Integer or 'NULL'. Number of rows to request. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with recent public trades.
Retrieve recent single-leg public block trades for an instrument.
get_public_block_trades( inst_id, config = NULL, tz = .okx_default_tz )get_public_block_trades( inst_id, config = NULL, tz = .okx_default_tz )
inst_id |
Character. Instrument ID. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with block trade fields such as price, size, trade side, volatility, and timestamps.
Convert the crypto value to the number of contracts, or vice versa.
get_public_convert_contract_coin( inst_id, sz, type = NULL, px = NULL, unit = NULL, op_type = NULL, config = NULL, tz = .okx_default_tz )get_public_convert_contract_coin( inst_id, sz, type = NULL, px = NULL, unit = NULL, op_type = NULL, config = NULL, tz = .okx_default_tz )
inst_id |
Character. Instrument ID. |
sz |
Character or numeric. Quantity to convert. |
type |
Character or 'NULL'. Convert type: '"1"' for currency to contract, '"2"' for contract to currency. |
px |
Character, numeric, or 'NULL'. Optional order price. |
unit |
Character or 'NULL'. Currency unit, '"coin"' or '"usds"'. |
op_type |
Character or 'NULL'. Order type for futures or swaps, such as '"open"' or '"close"'. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with conversion result fields 'type', 'instId', 'px', 'sz', and 'unit'.
Retrieve futures delivery records or option exercise records.
get_public_delivery_exercise_history( inst_type, inst_family, after = NULL, before = NULL, limit = NULL, config = NULL, tz = .okx_default_tz )get_public_delivery_exercise_history( inst_type, inst_family, after = NULL, before = NULL, limit = NULL, config = NULL, tz = .okx_default_tz )
inst_type |
Character. '"FUTURES"' or '"OPTION"'. |
inst_family |
Character. Instrument family. |
after |
Character or 'NULL'. Pagination cursor for older rows. |
before |
Character or 'NULL'. Pagination cursor for newer rows. |
limit |
Integer or 'NULL'. Number of rows to request. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with 'ts' and JSON-encoded 'details'.
Retrieve public collateral discount-rate tiers and interest-free quota information for supported currencies.
get_public_discount_rate_interest_free_quota( ccy = NULL, discount_lv = NULL, config = NULL, tz = .okx_default_tz )get_public_discount_rate_interest_free_quota( ccy = NULL, discount_lv = NULL, config = NULL, tz = .okx_default_tz )
ccy |
Character or 'NULL'. Currency filter, e.g. '"BTC"'. |
discount_lv |
Character or 'NULL'. Discount level filter. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with top-level discount and interest-free quota fields; nested tier details are JSON-encoded in 'details'.
Retrieve macro-economic calendar records. OKX requires authentication for this endpoint.
get_public_economic_calendar( region = NULL, importance = NULL, before = NULL, after = NULL, limit = NULL, config, tz = .okx_default_tz )get_public_economic_calendar( region = NULL, importance = NULL, before = NULL, after = NULL, limit = NULL, config, tz = .okx_default_tz )
region |
Character or 'NULL'. Region filter. |
importance |
Character or 'NULL'. Importance level filter. |
before |
Character or 'NULL'. Pagination cursor for newer rows. |
after |
Character or 'NULL'. Pagination cursor for older rows. |
limit |
Integer or 'NULL'. Number of rows to request. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with calendar event fields and timestamps.
Retrieve the estimated delivery, exercise, or settlement price for derivatives and events instruments.
get_public_estimated_price( inst_type, inst_family = NULL, inst_id = NULL, config = NULL, tz = .okx_default_tz )get_public_estimated_price( inst_type, inst_family = NULL, inst_id = NULL, config = NULL, tz = .okx_default_tz )
inst_type |
Character. Instrument type, such as '"FUTURES"', '"OPTION"', '"SWAP"', or '"EVENTS"'. |
inst_family |
Character or 'NULL'. Instrument family filter. |
inst_id |
Character or 'NULL'. Specific instrument ID filter. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with 'instType', 'instId', 'settlePx', and 'ts'.
Retrieve the estimated settlement price for a futures instrument close to settlement.
get_public_estimated_settlement_info( inst_id, config = NULL, tz = .okx_default_tz )get_public_estimated_settlement_info( inst_id, config = NULL, tz = .okx_default_tz )
inst_id |
Character. Instrument ID. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with 'instId', 'nextSettleTime', 'estSettlePx', and 'ts'.
Retrieve the current funding rate for a perpetual swap instrument.
get_public_funding_rate( inst_id, config = NULL, tz = .okx_default_tz )get_public_funding_rate( inst_id, config = NULL, tz = .okx_default_tz )
inst_id |
Character. Instrument ID, e.g. '"BTC-USDT-SWAP"'. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' containing the current funding rate fields returned by OKX.
Retrieve historical funding rate entries for a perpetual swap instrument.
get_public_funding_rate_history( inst_id, before = NULL, after = NULL, limit = 400, config = NULL, tz = .okx_default_tz )get_public_funding_rate_history( inst_id, before = NULL, after = NULL, limit = 400, config = NULL, tz = .okx_default_tz )
inst_id |
Character. Instrument ID, e.g. '"BTC-USDT-SWAP"'. |
before |
Optional cursor for records earlier than the supplied value. |
after |
Optional cursor for records later than the supplied value. |
limit |
Integer. Number of records to request. Default '400'. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' containing funding rate history rows returned by OKX.
Retrieve option tick-band information for one or more option instrument families.
get_public_instrument_tick_bands( inst_type = "OPTION", inst_family = NULL, config = NULL, tz = .okx_default_tz )get_public_instrument_tick_bands( inst_type = "OPTION", inst_family = NULL, config = NULL, tz = .okx_default_tz )
inst_type |
Character. Instrument type. Currently '"OPTION"'. |
inst_family |
Character or 'NULL'. Instrument family filter. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with 'instType', 'instFamily', and JSON-encoded 'tickBand' details.
Retrieve metadata for instruments of a given type.
get_public_instruments( inst_id = NULL, inst_type = "SWAP", config = NULL, tz = .okx_default_tz )get_public_instruments( inst_id = NULL, inst_type = "SWAP", config = NULL, tz = .okx_default_tz )
inst_id |
Character or 'NULL'. Specific instrument ID to query. Use 'NULL' to fetch all instruments of 'inst_type'. |
inst_type |
Character. Instrument type. One of '"SPOT"', '"MARGIN"', '"SWAP"' (default), '"FUTURES"', '"OPTION"'. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
Wraps '/api/v5/public/instruments'. Returns one row per instrument, including contract specifications, tick size, lot size, expiry, and state.
A 'data.frame' with instrument metadata (e.g., 'instType', 'instId', 'uly', 'baseCcy', 'quoteCcy', 'settleCcy', 'ctVal', 'ctMult', 'tickSz', 'lotSz', 'minSz', 'expTime', 'lever', 'state', ...).
Since okxr 0.1.2
[get_public_mark_price()]
## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") # Get metadata for all SWAP instruments df <- get_public_instruments(inst_type = "SWAP", config = cfg) # Get metadata for one instrument get_public_instruments("ETH-USDT-SWAP", inst_type = "SWAP", config = cfg) ## End(Not run)## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") # Get metadata for all SWAP instruments df <- get_public_instruments(inst_type = "SWAP", config = cfg) # Get metadata for one instrument get_public_instruments("ETH-USDT-SWAP", inst_type = "SWAP", config = cfg) ## End(Not run)
Retrieve public insurance-fund or security-fund balance information.
get_public_insurance_fund( inst_type, type = NULL, inst_family = NULL, ccy = NULL, before = NULL, after = NULL, limit = NULL, config = NULL, tz = .okx_default_tz )get_public_insurance_fund( inst_type, type = NULL, inst_family = NULL, ccy = NULL, before = NULL, after = NULL, limit = NULL, config = NULL, tz = .okx_default_tz )
inst_type |
Character. Instrument type, such as '"MARGIN"', '"SWAP"', '"FUTURES"', or '"OPTION"'. |
type |
Character or 'NULL'. Fund update type filter. |
inst_family |
Character or 'NULL'. Instrument family filter for derivatives. |
ccy |
Character or 'NULL'. Currency filter for margin data. |
before |
Character or 'NULL'. Pagination cursor for newer rows. |
after |
Character or 'NULL'. Pagination cursor for older rows. |
limit |
Integer or 'NULL'. Number of rows to request. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with top-level fund totals; nested per-currency detail rows are JSON-encoded in 'details'.
Retrieve public borrowing-rate and loan-quota tables.
get_public_interest_rate_loan_quota( ccy = NULL, vip_level = NULL, config = NULL, tz = .okx_default_tz )get_public_interest_rate_loan_quota( ccy = NULL, vip_level = NULL, config = NULL, tz = .okx_default_tz )
ccy |
Character or 'NULL'. Currency filter. |
vip_level |
Character or 'NULL'. VIP level filter when supported by OKX. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' where nested basic, VIP, regular, and custom quota tables are JSON-encoded string columns.
Retrieve the current mark price for a given instrument.
get_public_mark_price( inst_id, inst_type = "SWAP", config = NULL, tz = .okx_default_tz )get_public_mark_price( inst_id, inst_type = "SWAP", config = NULL, tz = .okx_default_tz )
inst_id |
Character. Instrument ID, e.g. '"BTC-USDT"', '"ETH-USDT-SWAP"'. |
inst_type |
Character. Instrument type. One of '"SPOT"', '"MARGIN"', '"SWAP"' (default), '"FUTURES"', '"OPTION"'. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
Wraps '/api/v5/public/mark-price'. Useful for margin calculations and PnL estimation. Returns a single row with the latest mark price and timestamp.
A 'data.frame' with columns 'timestamp', 'instId', 'markPx'.
Since okxr 0.1.1
[get_public_instruments()]
## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") get_public_mark_price("BTC-USDT", inst_type = "SWAP", config = cfg) ## End(Not run)## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") get_public_mark_price("BTC-USDT", inst_type = "SWAP", config = cfg) ## End(Not run)
Retrieve current open interest for an instrument.
get_public_open_interest( inst_id, inst_type, config = NULL, tz = .okx_default_tz )get_public_open_interest( inst_id, inst_type, config = NULL, tz = .okx_default_tz )
inst_id |
Character. Instrument ID, e.g. '"BTC-USDT-SWAP"'. |
inst_type |
Character. Instrument type such as '"SWAP"' or '"FUTURES"'. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' containing open interest fields returned by OKX.
Retrieve option market summary data for an instrument family.
get_public_opt_summary( inst_family, exp_time = NULL, config = NULL, tz = .okx_default_tz )get_public_opt_summary( inst_family, exp_time = NULL, config = NULL, tz = .okx_default_tz )
inst_family |
Character. Option instrument family. |
exp_time |
Character or 'NULL'. Expiry date in 'YYMMDD'. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with option greeks, volatility, forward price, and timestamp fields.
Retrieve recent public option trades filtered by instrument ID or instrument family.
get_public_option_trades( inst_id = NULL, inst_family = NULL, opt_type = NULL, config = NULL, tz = .okx_default_tz )get_public_option_trades( inst_id = NULL, inst_family = NULL, opt_type = NULL, config = NULL, tz = .okx_default_tz )
inst_id |
Character or 'NULL'. Specific option instrument ID. |
inst_family |
Character or 'NULL'. Option instrument family, e.g. '"BTC-USD"'. Either 'inst_id' or 'inst_family' should be supplied. |
opt_type |
Character or 'NULL'. Option type filter: '"C"' for call or '"P"' for put. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with recent option trade rows, including option instrument identifiers, trade price and size, option side/type, forward, index and mark prices, implied volatility, and trade time.
Retrieve public tier, margin, and maximum leverage information.
get_public_position_tiers( inst_type, td_mode, inst_family = NULL, inst_id = NULL, ccy = NULL, tier = NULL, config = NULL, tz = .okx_default_tz )get_public_position_tiers( inst_type, td_mode, inst_family = NULL, inst_id = NULL, ccy = NULL, tier = NULL, config = NULL, tz = .okx_default_tz )
inst_type |
Character. Instrument type. |
td_mode |
Character. Trade mode. |
inst_family |
Character or 'NULL'. Instrument family. |
inst_id |
Character or 'NULL'. Instrument ID(s). |
ccy |
Character or 'NULL'. Margin currency. |
tier |
Character or 'NULL'. Tier filter. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with public position tier information.
Retrieve buy and sell price limits for an instrument.
get_public_price_limit( inst_id, config = NULL, tz = .okx_default_tz )get_public_price_limit( inst_id, config = NULL, tz = .okx_default_tz )
inst_id |
Character. Instrument ID, e.g. '"BTC-USDT-SWAP"'. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with price limit fields.
Retrieve futures settlement history for an instrument family.
get_public_settlement_history( inst_family, after = NULL, before = NULL, limit = NULL, config = NULL, tz = .okx_default_tz )get_public_settlement_history( inst_family, after = NULL, before = NULL, limit = NULL, config = NULL, tz = .okx_default_tz )
inst_family |
Character. Instrument family. |
after |
Character or 'NULL'. Pagination cursor for older rows. |
before |
Character or 'NULL'. Pagination cursor for newer rows. |
limit |
Integer or 'NULL'. Number of rows to request. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with 'ts' and JSON-encoded 'details'.
Retrieve OKX system time.
get_public_time(config = NULL, tz = .okx_default_tz)get_public_time(config = NULL, tz = .okx_default_tz)
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A one-row 'data.frame' with system time.
Retrieve available underlyings for derivatives instruments.
get_public_underlying( inst_type, config = NULL, tz = .okx_default_tz )get_public_underlying( inst_type, config = NULL, tz = .okx_default_tz )
inst_type |
Character. Instrument type: '"SWAP"', '"FUTURES"', or '"OPTION"'. |
config |
Optional list. Public endpoint request options, such as 'timeout'; credentials are not required. |
tz |
Character. Unused except for interface consistency. |
A one-column 'data.frame' with 'uly'.
Retrieve account rate limit information related to new and amended order requests.
get_trade_account_rate_limit(config, tz = .okx_default_tz)get_trade_account_rate_limit(config, tz = .okx_default_tz)
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
Wraps '/api/v5/trade/account-rate-limit'. Returns one row containing the current account rate limit and fill-ratio metrics used by OKX.
A one-row 'data.frame' with rate-limit metrics such as 'accRateLimit', 'fillRatio', 'mainFillRatio', 'nextAccRateLimit', and 'ts'.
Retrieve currencies available for easy convert.
get_trade_easy_convert_currency_list( source = NULL, config, tz = .okx_default_tz )get_trade_easy_convert_currency_list( source = NULL, config, tz = .okx_default_tz )
source |
Character or 'NULL'. Source account type filter. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. |
A 'data.frame' with source and target currency metadata.
Retrieve easy convert history.
get_trade_easy_convert_history( after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )get_trade_easy_convert_history( after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )
after |
Character or 'NULL'. Pagination cursor for earlier records. |
before |
Character or 'NULL'. Pagination cursor for newer records. |
limit |
Integer or 'NULL'. Number of results to request. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. |
A 'data.frame' with easy convert history rows.
Retrieve recently filled transaction details from the last 3 days.
get_trade_fills( inst_type = NULL, inst_family = NULL, inst_id = NULL, ord_id = NULL, sub_type = NULL, after = NULL, before = NULL, limit = NULL, begin = NULL, end = NULL, config, tz = .okx_default_tz )get_trade_fills( inst_type = NULL, inst_family = NULL, inst_id = NULL, ord_id = NULL, sub_type = NULL, after = NULL, before = NULL, limit = NULL, begin = NULL, end = NULL, config, tz = .okx_default_tz )
inst_type |
Character or 'NULL'. Instrument type filter. |
inst_family |
Character or 'NULL'. Instrument family filter. |
inst_id |
Character or 'NULL'. Instrument ID filter. |
ord_id |
Character or 'NULL'. Order ID filter. |
sub_type |
Character or 'NULL'. Transaction subtype filter. |
after |
Character or 'NULL'. Pagination cursor for earlier records. |
before |
Character or 'NULL'. Pagination cursor for newer records. |
limit |
Integer or 'NULL'. Number of rows to request. |
begin |
Character or 'NULL'. Begin timestamp in milliseconds. |
end |
Character or 'NULL'. End timestamp in milliseconds. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with fill rows.
Retrieve historical filled transaction details from the last 3 months.
get_trade_fills_history( inst_type, inst_family = NULL, inst_id = NULL, ord_id = NULL, sub_type = NULL, after = NULL, before = NULL, limit = NULL, begin = NULL, end = NULL, config, tz = .okx_default_tz )get_trade_fills_history( inst_type, inst_family = NULL, inst_id = NULL, ord_id = NULL, sub_type = NULL, after = NULL, before = NULL, limit = NULL, begin = NULL, end = NULL, config, tz = .okx_default_tz )
inst_type |
Character. Instrument type, e.g. '"SPOT"' or '"SWAP"'. |
inst_family |
Character or 'NULL'. Instrument family filter. |
inst_id |
Character or 'NULL'. Instrument ID filter. |
ord_id |
Character or 'NULL'. Order ID filter. |
sub_type |
Character or 'NULL'. Transaction subtype filter. |
after |
Character or 'NULL'. Pagination cursor for earlier records. |
before |
Character or 'NULL'. Pagination cursor for newer records. |
limit |
Integer or 'NULL'. Number of rows to request. |
begin |
Character or 'NULL'. Begin timestamp in milliseconds. |
end |
Character or 'NULL'. End timestamp in milliseconds. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
A 'data.frame' with historical fill rows.
Retrieve repayable currencies for the legacy one-click repay endpoint.
get_trade_one_click_repay_currency_list( debt_type = NULL, config, tz = .okx_default_tz )get_trade_one_click_repay_currency_list( debt_type = NULL, config, tz = .okx_default_tz )
debt_type |
Character or 'NULL'. Debt type filter. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. |
A 'data.frame' with debt and repay currency metadata.
Retrieve repayable currencies for the new one-click repay endpoint.
get_trade_one_click_repay_currency_list_v2( config, tz = .okx_default_tz )get_trade_one_click_repay_currency_list_v2( config, tz = .okx_default_tz )
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. |
A 'data.frame' with debt and repay currency metadata.
Retrieve legacy one-click repay history.
get_trade_one_click_repay_history( after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )get_trade_one_click_repay_history( after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )
after |
Character or 'NULL'. Pagination cursor for earlier records. |
before |
Character or 'NULL'. Pagination cursor for newer records. |
limit |
Integer or 'NULL'. Number of results to request. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. |
A 'data.frame' with one-click repay history rows.
Retrieve new one-click repay history.
get_trade_one_click_repay_history_v2( after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )get_trade_one_click_repay_history_v2( after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )
after |
Character or 'NULL'. Pagination cursor for earlier records. |
before |
Character or 'NULL'. Pagination cursor for newer records. |
limit |
Integer or 'NULL'. Number of results to request. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. |
A 'data.frame' with one-click repay history rows.
Retrieve detailed information about a specific OKX order by either the exchange-assigned 'ord_id' or your client-assigned 'cl_ord_id'.
get_trade_order( inst_id, ord_id = NULL, cl_ord_id = NULL, config, tz = .okx_default_tz )get_trade_order( inst_id, ord_id = NULL, cl_ord_id = NULL, config, tz = .okx_default_tz )
inst_id |
Character. Instrument ID, e.g. '"ETH-USDT-SWAP"' (perps), '"BTC-USDT"' (spot), or '"BTC-USD-240927"' (dated futures). |
ord_id |
Character, optional. The OKX order ID. Provide this **or** 'cl_ord_id'. |
cl_ord_id |
Character, optional. Your client order ID. Provide this **or** 'ord_id'. |
config |
List. API credentials/config, typically containing 'api_key', 'secret_key', and 'passphrase'. May also include 'base_url'. |
tz |
Character. Time zone for parsing timestamps. Default '"Asia/Hong_Kong"'. |
You must provide exactly one identifier: 'ord_id' **or** 'cl_ord_id'. Timestamps in the response are converted to 'POSIXct' in the supplied 'tz'.
A 'data.frame' (one row) with order details following OKX schema (e.g., 'ordId', 'clOrdId', 'instId', 'ordType', 'px', 'sz', 'side', 'posSide', 'tdMode', 'accFillSz', 'fillPx', 'fillSz', 'fillTime', 'avgPx', 'state', 'lever', etc.). Timestamp columns are 'POSIXct' in 'tz'.
- ‘Either ’ord_id' or 'cl_ord_id' must be provided.' (client-side) - HTTP 401 Unauthorized (missing/invalid credentials) - OKX 'code' like '51000' invalid sign or '51603' order not found
Since okxr 0.1.1
[get_trade_orders_pending()], [get_trade_orders_history_7d()]
## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") get_trade_order( inst_id = "ETH-USDT-SWAP", ord_id = "1234567890", config = cfg ) ## End(Not run)## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") get_trade_order( inst_id = "ETH-USDT-SWAP", ord_id = "1234567890", config = cfg ) ## End(Not run)
Retrieve a specific algo order by algo ID or client algo order ID.
get_trade_order_algo( algo_id = NULL, algo_cl_ord_id = NULL, config, tz = .okx_default_tz )get_trade_order_algo( algo_id = NULL, algo_cl_ord_id = NULL, config, tz = .okx_default_tz )
algo_id |
Character or 'NULL'. Algo order ID. |
algo_cl_ord_id |
Character or 'NULL'. Client algo order ID. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. |
A 'data.frame' with algo order details.
Retrieve historical algo orders.
get_trade_orders_algo_history( ord_type, state = NULL, algo_id = NULL, inst_type = NULL, inst_id = NULL, after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )get_trade_orders_algo_history( ord_type, state = NULL, algo_id = NULL, inst_type = NULL, inst_id = NULL, after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )
ord_type |
Character. Algo order type filter. |
state |
Character or 'NULL'. Algo order state filter. |
algo_id |
Character or 'NULL'. Algo order ID. |
inst_type |
Character or 'NULL'. Instrument type filter. |
inst_id |
Character or 'NULL'. Instrument ID filter. |
after |
Character or 'NULL'. Pagination cursor for earlier records. |
before |
Character or 'NULL'. Pagination cursor for newer records. |
limit |
Integer or 'NULL'. Number of results to request. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. |
A 'data.frame' with algo order history rows.
Retrieve untriggered algo orders.
get_trade_orders_algo_pending( ord_type, algo_id = NULL, inst_type = NULL, inst_id = NULL, after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )get_trade_orders_algo_pending( ord_type, algo_id = NULL, inst_type = NULL, inst_id = NULL, after = NULL, before = NULL, limit = NULL, config, tz = .okx_default_tz )
ord_type |
Character. Algo order type filter. |
algo_id |
Character or 'NULL'. Algo order ID. |
inst_type |
Character or 'NULL'. Instrument type filter. |
inst_id |
Character or 'NULL'. Instrument ID filter. |
after |
Character or 'NULL'. Pagination cursor for earlier records. |
before |
Character or 'NULL'. Pagination cursor for newer records. |
limit |
Integer or 'NULL'. Number of results to request. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. |
A 'data.frame' with pending algo orders.
Retrieve completed orders from the last 7 days.
get_trade_orders_history( inst_type, inst_family = NULL, inst_id = NULL, ord_type = NULL, state = NULL, category = NULL, after = NULL, before = NULL, begin = NULL, end = NULL, limit = NULL, config, tz = .okx_default_tz )get_trade_orders_history( inst_type, inst_family = NULL, inst_id = NULL, ord_type = NULL, state = NULL, category = NULL, after = NULL, before = NULL, begin = NULL, end = NULL, limit = NULL, config, tz = .okx_default_tz )
inst_type |
Character. Instrument type. |
inst_family |
Character or 'NULL'. Instrument family filter. |
inst_id |
Character or 'NULL'. Instrument ID filter. |
ord_type |
Character or 'NULL'. Order type filter. |
state |
Character or 'NULL'. Order state filter. |
category |
Character or 'NULL'. Order category filter. |
after |
Character or 'NULL'. Pagination cursor for earlier records. |
before |
Character or 'NULL'. Pagination cursor for newer records. |
begin |
Character or 'NULL'. Begin timestamp in milliseconds. |
end |
Character or 'NULL'. End timestamp in milliseconds. |
limit |
Integer or 'NULL'. Number of results to request. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. |
A 'data.frame' with historical order rows.
Retrieve recent order history for an instrument type.
get_trade_orders_history_7d( inst_type = "SWAP", config, tz = .okx_default_tz )get_trade_orders_history_7d( inst_type = "SWAP", config, tz = .okx_default_tz )
inst_type |
Character. Instrument type. One of '"SPOT"', '"MARGIN"', '"SWAP"', '"FUTURES"', '"OPTION"'. Default '"SWAP"'. |
config |
List. API credentials/config, typically containing 'api_key', 'secret_key', and 'passphrase'. May also include 'base_url'. |
tz |
Character. Time zone for parsing timestamps (e.g. '"Asia/Hong_Kong"'). |
This wraps '/api/v5/trade/orders-history' and covers about 7 days of data. Older data is available from OKX's archive endpoint.
A 'data.frame' with one row per historical order and columns following the OKX schema (same layout as pending orders, plus final states). Timestamp columns are 'POSIXct' in 'tz'.
- HTTP 401 Unauthorized - HTTP 400 Bad Request for invalid 'inst_type'
Since okxr 0.1.2
[get_trade_order()], [get_trade_orders_pending()]
## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") hist <- get_trade_orders_history_7d( inst_type = "SWAP", config = cfg, tz = "Asia/Hong_Kong" ) tail(hist) ## End(Not run)## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") hist <- get_trade_orders_history_7d( inst_type = "SWAP", config = cfg, tz = "Asia/Hong_Kong" ) tail(hist) ## End(Not run)
Retrieve completed orders from the last 3 months.
get_trade_orders_history_archive( inst_type, inst_family = NULL, inst_id = NULL, ord_type = NULL, state = NULL, category = NULL, after = NULL, before = NULL, begin = NULL, end = NULL, limit = NULL, config, tz = .okx_default_tz )get_trade_orders_history_archive( inst_type, inst_family = NULL, inst_id = NULL, ord_type = NULL, state = NULL, category = NULL, after = NULL, before = NULL, begin = NULL, end = NULL, limit = NULL, config, tz = .okx_default_tz )
inst_type |
Character. Instrument type. |
inst_family |
Character or 'NULL'. Instrument family filter. |
inst_id |
Character or 'NULL'. Instrument ID filter. |
ord_type |
Character or 'NULL'. Order type filter. |
state |
Character or 'NULL'. Order state filter. |
category |
Character or 'NULL'. Order category filter. |
after |
Character or 'NULL'. Pagination cursor for earlier records. |
before |
Character or 'NULL'. Pagination cursor for newer records. |
begin |
Character or 'NULL'. Begin timestamp in milliseconds. |
end |
Character or 'NULL'. End timestamp in milliseconds. |
limit |
Integer or 'NULL'. Number of results to request. |
config |
List. API credentials/config. |
tz |
Character. Time zone for parsing timestamps. |
A 'data.frame' with archived order rows.
Retrieve all currently open (unfilled) orders for your OKX account.
get_trade_orders_pending(config, tz = .okx_default_tz)get_trade_orders_pending(config, tz = .okx_default_tz)
config |
List. API credentials/config, typically containing 'api_key', 'secret_key', and 'passphrase'. May also include 'base_url'. |
tz |
Character. Time zone for parsing timestamps (e.g. '"Asia/Hong_Kong"'). |
Returns one row per open order. Timestamps are parsed to 'POSIXct' using 'tz'.
A 'data.frame' with one row per pending order and columns following the OKX schema (e.g., 'cTime', 'ordId', 'clOrdId', 'tag', 'instId', 'ordType', 'px', 'sz', 'side', 'posSide', 'tdMode', 'accFillSz', 'fillPx', 'fillSz', 'fillTime', 'avgPx', 'state', 'lever', ...). Timestamp columns are 'POSIXct'.
- HTTP 401 Unauthorized (missing/invalid credentials) - Rate limiting: HTTP 429 / OKX throttle codes
Since okxr 0.1.1
[get_trade_order()], [get_trade_orders_history_7d()]
## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") df <- get_trade_orders_pending(config = cfg, tz = "Asia/Hong_Kong") head(df) ## End(Not run)## Not run: cfg <- list(api_key = "xxx", secret_key = "xxx", passphrase = "xxx") df <- get_trade_orders_pending(config = cfg, tz = "Asia/Hong_Kong") head(df) ## End(Not run)
Returns human-readable labels attached to a data frame produced by OKX API parsers. You can retrieve all labels or a label for a specific variable by name or index.
get_var_label(df, var = NULL, default = NA_character_)get_var_label(df, var = NULL, default = NA_character_)
df |
A |
var |
Optional variable name (character) or index (numeric). If |
default |
Value to return if the variable has no label (default: |
A character label if var is provided, or a named character vector of all labels if var = NULL.
df <- data.frame(ordId = "123", px = 10) attr(df, "var_labels") <- c(ordId = "Order ID", px = "Price") get_var_label(df, "ordId") get_var_label(df, 2) get_var_label(df)df <- data.frame(ordId = "123", px = 10) attr(df, "var_labels") <- c(ordId = "Order ID", px = "Price") get_var_label(df, "ordId") get_var_label(df, 2) get_var_label(df)
Preset required values before switching account mode.
post_account_account_level_switch_preset( acct_lv, lever = NULL, risk_offset_type = NULL, tz = .okx_default_tz, config )post_account_account_level_switch_preset( acct_lv, lever = NULL, risk_offset_type = NULL, tz = .okx_default_tz, config )
acct_lv |
Target account level. |
lever |
Optional leverage preset. |
risk_offset_type |
Optional deprecated risk offset type field. |
tz |
Timezone used for any timestamp parsing. |
config |
A list containing API credentials. |
A 'data.frame' describing the stored preset values.
Set market maker protection thresholds for an options instrument family.
post_account_mmp_config( inst_family, time_interval, frozen_interval, qty_limit, tz = .okx_default_tz, config )post_account_mmp_config( inst_family, time_interval, frozen_interval, qty_limit, tz = .okx_default_tz, config )
inst_family |
Instrument family. |
time_interval |
Time window in milliseconds. |
frozen_interval |
Frozen interval in milliseconds. |
qty_limit |
Quantity limit in number of contracts. |
tz |
Timezone used for any timestamp parsing. |
config |
A list containing API credentials. |
A 'data.frame' describing the applied MMP configuration.
Reset market maker protection status for an instrument family.
post_account_mmp_reset( inst_family, inst_type = NULL, tz = .okx_default_tz, config )post_account_mmp_reset( inst_family, inst_type = NULL, tz = .okx_default_tz, config )
inst_family |
Instrument family. |
inst_type |
Optional instrument type. Defaults to '"OPTION"' on OKX. |
tz |
Timezone used for any timestamp parsing. |
config |
A list containing API credentials. |
A 'data.frame' with the request result.
Move positions between accounts under the same master account.
post_account_move_positions( from_acct, to_acct, legs, client_id, tz = .okx_default_tz, config )post_account_move_positions( from_acct, to_acct, legs, client_id, tz = .okx_default_tz, config )
from_acct |
Source account name. |
to_acct |
Destination account name. |
legs |
List of move-position leg objects in the documented OKX shape. |
client_id |
Client-supplied request ID. |
tz |
Timezone used for any timestamp parsing. |
config |
A list containing API credentials. |
A 'data.frame' describing the move-position request result.
Increase or reduce margin for an existing position.
post_account_position_margin_balance( inst_id, pos_side, type, amt, ccy = NULL, tz = .okx_default_tz, config )post_account_position_margin_balance( inst_id, pos_side, type, amt, ccy = NULL, tz = .okx_default_tz, config )
inst_id |
Instrument ID. |
pos_side |
Position side. |
type |
Margin adjustment type, typically '"add"' or '"reduce"'. |
amt |
Amount to add or reduce. |
ccy |
Optional currency for isolated margin orders. |
tz |
Timezone used for any timestamp parsing. |
config |
A list containing API credentials. |
A 'data.frame' describing the applied margin adjustment.
Switch the account mode.
post_account_set_account_level( acct_lv, tz = .okx_default_tz, config )post_account_set_account_level( acct_lv, tz = .okx_default_tz, config )
acct_lv |
Account level string, such as '"1"', '"2"', '"3"', or '"4"'. |
tz |
Timezone used for any timestamp parsing. |
config |
A list containing API credentials. |
A 'data.frame' confirming the applied account level.
Enable or disable automatic borrowing.
post_account_set_auto_loan( auto_loan = TRUE, tz = .okx_default_tz, config )post_account_set_auto_loan( auto_loan = TRUE, tz = .okx_default_tz, config )
auto_loan |
Logical. Whether auto loan should be enabled. |
tz |
Timezone used for any timestamp parsing. |
config |
A list containing API credentials. |
A 'data.frame' confirming the applied auto-loan setting.
Enable or disable spot-mode auto repay.
post_account_set_auto_repay( auto_repay, tz = .okx_default_tz, config )post_account_set_auto_repay( auto_repay, tz = .okx_default_tz, config )
auto_repay |
Logical. Whether auto repay should be enabled. |
tz |
Timezone used for any timestamp parsing. |
config |
A list containing API credentials. |
A 'data.frame' confirming the applied auto-repay setting.
Configure whether all or selected assets are treated as collateral.
post_account_set_collateral_assets( type, collateral_enabled, ccy_list = NULL, tz = .okx_default_tz, config )post_account_set_collateral_assets( type, collateral_enabled, ccy_list = NULL, tz = .okx_default_tz, config )
type |
Type of update, typically '"all"' or '"custom"'. |
collateral_enabled |
Logical. Whether the selected assets should be collateral-enabled. |
ccy_list |
Optional character vector of currencies. Required when 'type = "custom"'. |
tz |
Timezone used for any timestamp parsing. |
config |
A list containing API credentials. |
A 'data.frame' confirming the applied collateral asset setting.
Configure the fee charging mode for spot trading.
post_account_set_fee_type(fee_type, tz = .okx_default_tz, config)post_account_set_fee_type(fee_type, tz = .okx_default_tz, config)
fee_type |
Fee type string, typically '"0"' or '"1"'. |
tz |
Timezone used for any timestamp parsing. |
config |
A list containing API credentials. |
A 'data.frame' confirming the applied fee type.
Configure whether Greeks are displayed in PA or BS mode.
post_account_set_greeks( greeks_type, tz = .okx_default_tz, config )post_account_set_greeks( greeks_type, tz = .okx_default_tz, config )
greeks_type |
Greeks display type, typically '"PA"' or '"BS"'. |
tz |
Timezone used for any timestamp parsing. |
config |
A list containing API credentials. |
A 'data.frame' confirming the applied Greeks display type.
Sets the leverage level for a specific trading instrument and margin mode.
post_account_set_leverage( inst_id, lever, mgn_mode, pos_side = NULL, tz = .okx_default_tz, config )post_account_set_leverage( inst_id, lever, mgn_mode, pos_side = NULL, tz = .okx_default_tz, config )
inst_id |
Instrument ID (e.g., |
lever |
Leverage level to apply (as a string or numeric, e.g., |
mgn_mode |
Margin mode: |
pos_side |
Optional. Position side: |
tz |
Timezone used for any timestamp parsing (default: |
config |
API credential list with keys 'api_key', 'secret_key', and 'passphrase'. |
A data.frame with leverage update confirmation (including instrument ID and leverage settings).
Set the account position mode.
post_account_set_position_mode( pos_mode, tz = .okx_default_tz, config )post_account_set_position_mode( pos_mode, tz = .okx_default_tz, config )
pos_mode |
Position mode. Use 'long_short_mode' or 'net_mode'. |
tz |
Timezone used for any timestamp parsing. |
config |
A list containing API credentials. |
A 'data.frame' confirming the applied position mode.
Manually borrow or repay under spot mode.
post_account_spot_manual_borrow_repay( ccy, side, amt, tz = .okx_default_tz, config )post_account_spot_manual_borrow_repay( ccy, side, amt, tz = .okx_default_tz, config )
ccy |
Currency. |
side |
Action side, typically '"borrow"' or '"repay"'. |
amt |
Amount. |
tz |
Timezone used for any timestamp parsing. |
config |
A list containing API credentials. |
A 'data.frame' describing the executed borrow/repay request.
Cancel a pending withdrawal request.
post_asset_cancel_withdrawal(wd_id, tz = .okx_default_tz, config)post_asset_cancel_withdrawal(wd_id, tz = .okx_default_tz, config)
wd_id |
Withdrawal request ID. |
tz |
Timezone used for any timestamp parsing. |
config |
API credential list. |
A 'data.frame' confirming the cancelled withdrawal ID.
Request a quote for an asset conversion without executing the trade.
post_asset_convert_estimate_quote( base_ccy, quote_ccy, side, rfq_sz, rfq_sz_ccy, cl_q_req_id = NULL, tag = NULL, convert_mode = NULL, tz = .okx_default_tz, config )post_asset_convert_estimate_quote( base_ccy, quote_ccy, side, rfq_sz, rfq_sz_ccy, cl_q_req_id = NULL, tag = NULL, convert_mode = NULL, tz = .okx_default_tz, config )
base_ccy |
Base currency. |
quote_ccy |
Quote currency. |
side |
Quote side, such as '"buy"' or '"sell"'. |
rfq_sz |
RFQ size. |
rfq_sz_ccy |
Currency in which 'rfq_sz' is specified. |
cl_q_req_id |
Optional client quote request ID. |
tag |
Optional request tag. |
convert_mode |
Optional OKX convert mode. |
tz |
Timezone used for any timestamp parsing. |
config |
API credential list. |
A 'data.frame' describing the estimated conversion quote.
Execute a confirmed asset conversion against a previously quoted price.
post_asset_convert_trade( quote_id, base_ccy, quote_ccy, side, sz, sz_ccy, cl_t_req_id = NULL, tag = NULL, convert_mode = NULL, tz = .okx_default_tz, config )post_asset_convert_trade( quote_id, base_ccy, quote_ccy, side, sz, sz_ccy, cl_t_req_id = NULL, tag = NULL, convert_mode = NULL, tz = .okx_default_tz, config )
quote_id |
Quote ID returned by [post_asset_convert_estimate_quote()]. |
base_ccy |
Base currency. |
quote_ccy |
Quote currency. |
side |
Trade side, such as '"buy"' or '"sell"'. |
sz |
Trade size. |
sz_ccy |
Currency in which 'sz' is specified. |
cl_t_req_id |
Optional client trade request ID. |
tag |
Optional request tag. |
convert_mode |
Optional OKX convert mode. |
tz |
Timezone used for any timestamp parsing. |
config |
API credential list. |
A 'data.frame' describing the executed conversion trade.
Transfer assets between funding, trading, and related accounts.
post_asset_transfer( ccy, amt, from, to, type = "0", sub_acct = NULL, loan_trans = NULL, omit_pos_risk = NULL, client_id = NULL, tz = .okx_default_tz, config )post_asset_transfer( ccy, amt, from, to, type = "0", sub_acct = NULL, loan_trans = NULL, omit_pos_risk = NULL, client_id = NULL, tz = .okx_default_tz, config )
ccy |
Currency to transfer. |
amt |
Transfer amount. |
from |
Source account code, such as '"6"' for funding or '"18"' for trading. |
to |
Destination account code. |
type |
Optional transfer type code. Defaults to '"0"' for an internal transfer within the same account. |
sub_acct |
Optional sub-account name when the transfer type requires it. |
loan_trans |
Optional logical. Whether the transfer should be treated as a loan transfer. |
omit_pos_risk |
Optional logical. Whether to omit position risk checks where supported by OKX. |
client_id |
Optional client-supplied transfer request ID. |
tz |
Timezone used for any timestamp parsing. |
config |
API credential list. |
A 'data.frame' describing the submitted transfer request.
Submit a withdrawal request from the OKX funding account.
post_asset_withdrawal( ccy, amt, dest, to_addr, chain = NULL, to_addr_type = NULL, area_code = NULL, rcvr_info = NULL, client_id = NULL, tz = .okx_default_tz, config )post_asset_withdrawal( ccy, amt, dest, to_addr, chain = NULL, to_addr_type = NULL, area_code = NULL, rcvr_info = NULL, client_id = NULL, tz = .okx_default_tz, config )
ccy |
Currency to withdraw. |
amt |
Withdrawal amount. |
dest |
Destination type code from the OKX API. |
to_addr |
Destination wallet address. |
chain |
Optional chain identifier, such as '"USDT-ERC20"'. |
to_addr_type |
Optional destination address type code. |
area_code |
Optional phone area code when required by OKX. |
rcvr_info |
Optional named list in the documented 'rcvrInfo' shape. |
client_id |
Optional client-supplied withdrawal request ID. |
tz |
Timezone used for any timestamp parsing. |
config |
API credential list. |
A 'data.frame' describing the submitted withdrawal request.
Amend a supported unfilled algo order.
post_trade_amend_algos( inst_id, algo_id = NULL, algo_cl_ord_id = NULL, cxl_on_fail = NULL, req_id = NULL, new_sz = NULL, new_tp_trigger_px = NULL, new_tp_ord_px = NULL, new_sl_trigger_px = NULL, new_sl_ord_px = NULL, new_tp_trigger_px_type = NULL, new_sl_trigger_px_type = NULL, new_trigger_px = NULL, new_ord_px = NULL, new_trigger_px_type = NULL, attach_algo_ords = NULL, config, tz = .okx_default_tz )post_trade_amend_algos( inst_id, algo_id = NULL, algo_cl_ord_id = NULL, cxl_on_fail = NULL, req_id = NULL, new_sz = NULL, new_tp_trigger_px = NULL, new_tp_ord_px = NULL, new_sl_trigger_px = NULL, new_sl_ord_px = NULL, new_tp_trigger_px_type = NULL, new_sl_trigger_px_type = NULL, new_trigger_px = NULL, new_ord_px = NULL, new_trigger_px_type = NULL, attach_algo_ords = NULL, config, tz = .okx_default_tz )
inst_id |
Instrument ID. |
algo_id |
Algo order ID. Optional if 'algo_cl_ord_id' is supplied. |
algo_cl_ord_id |
Client-supplied algo ID. Optional if 'algo_id' is supplied. |
cxl_on_fail |
Optional logical. Whether to cancel the order if the amendment fails. |
req_id |
Optional client amendment request ID. |
new_sz |
Optional new quantity after amendment. |
new_tp_trigger_px |
Optional new take-profit trigger price. |
new_tp_ord_px |
Optional new take-profit order price. |
new_sl_trigger_px |
Optional new stop-loss trigger price. |
new_sl_ord_px |
Optional new stop-loss order price. |
new_tp_trigger_px_type |
Optional new take-profit trigger price type. |
new_sl_trigger_px_type |
Optional new stop-loss trigger price type. |
new_trigger_px |
Optional new trigger price for trigger orders. |
new_ord_px |
Optional new order price for trigger orders. |
new_trigger_px_type |
Optional new trigger price type for trigger orders. |
attach_algo_ords |
Optional attached TP/SL amendment list. |
config |
A list with API credentials. |
tz |
Timezone for parsing response timestamps. |
A 'data.frame' describing the algo amendment result.
Submit multiple amendment requests in one request.
post_trade_amend_batch_orders( orders, config, tz = .okx_default_tz )post_trade_amend_batch_orders( orders, config, tz = .okx_default_tz )
orders |
List of amendment specs.
See |
config |
A list with API credentials. |
tz |
Timezone for parsing response timestamps. |
A 'data.frame' with one row per amendment result.
Submit an amendment request for an incomplete order.
post_trade_amend_order( inst_id, ord_id = NULL, cl_ord_id = NULL, req_id = NULL, new_sz = NULL, new_px = NULL, cxl_on_fail = NULL, new_px_usd = NULL, new_px_vol = NULL, px_amend_type = NULL, attach_algo_ords = NULL, speed_bump = NULL, config, tz = .okx_default_tz )post_trade_amend_order( inst_id, ord_id = NULL, cl_ord_id = NULL, req_id = NULL, new_sz = NULL, new_px = NULL, cxl_on_fail = NULL, new_px_usd = NULL, new_px_vol = NULL, px_amend_type = NULL, attach_algo_ords = NULL, speed_bump = NULL, config, tz = .okx_default_tz )
inst_id |
Instrument ID. |
ord_id |
Order ID. Optional if 'cl_ord_id' is supplied. |
cl_ord_id |
Client order ID. Optional if 'ord_id' is supplied. |
req_id |
Optional client amendment request ID. |
new_sz |
Optional new total order size. |
new_px |
Optional new price. |
cxl_on_fail |
Optional logical. Whether to cancel the order if the amendment fails. |
new_px_usd |
Optional new option order USD price. |
new_px_vol |
Optional new option order implied volatility price. |
px_amend_type |
Optional price amendment mode. |
attach_algo_ords |
Optional attached TP/SL amendment list. |
speed_bump |
Optional event-contract speed bump. |
config |
A list with API credentials. |
tz |
Timezone for parsing response timestamps. |
A 'data.frame' describing the amendment request result.
Submit multiple trade orders in one request.
post_trade_batch_orders(orders, config, tz = .okx_default_tz)post_trade_batch_orders(orders, config, tz = .okx_default_tz)
orders |
List of order specs.
See |
config |
A list with API credentials. |
tz |
Timezone for parsing response timestamps. |
A 'data.frame' with one row per submitted order result.
Cancel up to 10 unfilled algo orders in one request.
post_trade_cancel_algos(orders, config, tz = .okx_default_tz)post_trade_cancel_algos(orders, config, tz = .okx_default_tz)
orders |
List of cancellation specification lists containing 'inst_id' plus either 'algo_id' or 'algo_cl_ord_id'. |
config |
A list with API credentials. |
tz |
Timezone for parsing response timestamps. |
A 'data.frame' with one row per algo cancellation result.
Set or disable the cancel-all-after countdown.
post_trade_cancel_all_after( time_out, tag = NULL, config, tz = .okx_default_tz )post_trade_cancel_all_after( time_out, tag = NULL, config, tz = .okx_default_tz )
time_out |
Character or numeric. Countdown in seconds. '0' disables it. |
tag |
Optional cancel-all-after tag scope. |
config |
A list with API credentials. |
tz |
Timezone for parsing response timestamps. |
A 'data.frame' with the configured trigger time and tag.
Submit a batch cancellation request for incomplete orders.
post_trade_cancel_batch_orders( orders, config, tz = .okx_default_tz )post_trade_cancel_batch_orders( orders, config, tz = .okx_default_tz )
orders |
List of cancellation specification lists containing 'inst_id' plus either 'ord_id' or 'cl_ord_id'. |
config |
A list with API credentials. |
tz |
Timezone for parsing response timestamps. |
A 'data.frame' with one row per cancellation result.
Submits a cancellation request for a previously placed trade order.
post_trade_cancel_order( inst_id, ord_id = NULL, cl_ord_id = NULL, config, tz = .okx_default_tz )post_trade_cancel_order( inst_id, ord_id = NULL, cl_ord_id = NULL, config, tz = .okx_default_tz )
inst_id |
Instrument ID (e.g., |
ord_id |
Optional OKX order ID to cancel. |
cl_ord_id |
Optional client order ID to cancel. Provide this or 'ord_id'. |
config |
A list with API credentials: |
tz |
Timezone for parsing any timestamps (default: |
A data.frame containing cancellation result and timestamp.
Submits a request to close a position for a given instrument and position side.
post_trade_close_position( inst_id, mgn_mode, pos_side, tz = .okx_default_tz, config )post_trade_close_position( inst_id, mgn_mode, pos_side, tz = .okx_default_tz, config )
inst_id |
Instrument ID (e.g., |
mgn_mode |
Margin mode: |
pos_side |
Position side to close: |
tz |
Timezone for parsing any timestamps (default: |
config |
A list with API credentials: |
A data.frame with close position confirmation details.
Cancel all MMP pending orders for an options instrument family.
post_trade_mass_cancel( inst_type, inst_family, lock_interval = NULL, config, tz = .okx_default_tz )post_trade_mass_cancel( inst_type, inst_family, lock_interval = NULL, config, tz = .okx_default_tz )
inst_type |
Instrument type. Currently 'OPTION'. |
inst_family |
Instrument family. |
lock_interval |
Optional lock interval in milliseconds. |
config |
A list with API credentials. |
tz |
Timezone for parsing response timestamps. |
A 'data.frame' with the request result.
Submits a trade order to the OKX exchange.
post_trade_order( inst_id, td_mode, side, ord_type, sz, pos_side = NULL, px = NULL, reduce_only = NULL, tgt_ccy = NULL, cl_ord_id = NULL, tag = NULL, config, tz = .okx_default_tz )post_trade_order( inst_id, td_mode, side, ord_type, sz, pos_side = NULL, px = NULL, reduce_only = NULL, tgt_ccy = NULL, cl_ord_id = NULL, tag = NULL, config, tz = .okx_default_tz )
inst_id |
Instrument ID (e.g., |
td_mode |
Trade mode: |
side |
Order side: |
ord_type |
Order type: |
sz |
Size of the order (quantity to buy/sell). |
pos_side |
Optional. Position side: |
px |
Optional. Price (required for limit orders). |
reduce_only |
Optional. Logical flag to indicate a reduce-only order. |
tgt_ccy |
Optional. Quote currency (e.g., |
cl_ord_id |
Optional. Custom client order ID (auto-generated if NULL). |
tag |
Optional. Tag used for identifying the strategy or bot. |
config |
A list with API credentials: |
tz |
Timezone for parsing any timestamps (default: |
A data.frame containing fields like order ID, client order ID, and timestamp.
Submit an order precheck request without placing the order.
post_trade_order_precheck( inst_id, td_mode, side, ord_type, sz, ccy = NULL, cl_ord_id = NULL, tag = NULL, pos_side = NULL, px = NULL, reduce_only = NULL, tgt_ccy = NULL, attach_algo_ords = NULL, speed_bump = NULL, outcome = NULL, config, tz = .okx_default_tz )post_trade_order_precheck( inst_id, td_mode, side, ord_type, sz, ccy = NULL, cl_ord_id = NULL, tag = NULL, pos_side = NULL, px = NULL, reduce_only = NULL, tgt_ccy = NULL, attach_algo_ords = NULL, speed_bump = NULL, outcome = NULL, config, tz = .okx_default_tz )
inst_id |
Instrument ID. |
td_mode |
Trade mode. |
side |
Order side. |
ord_type |
Order type. |
sz |
Order size. |
ccy |
Optional margin currency. |
cl_ord_id |
Optional client order ID. |
tag |
Optional order tag. |
pos_side |
Optional position side. |
px |
Optional order price. |
reduce_only |
Optional logical reduce-only flag. |
tgt_ccy |
Optional target currency mode. |
attach_algo_ords |
Optional attached TP/SL list. |
speed_bump |
Optional event-contract speed bump. |
outcome |
Optional event-contract outcome. |
config |
A list with API credentials. |
tz |
Timezone for parsing response timestamps. |
A 'data.frame' with projected account metrics after the precheck.
Convenience wrapper to set global options for okxr, such as whether to return raw data instead of parsed data.
set_okxr_options(raw_data = NULL, timeout = NULL)set_okxr_options(raw_data = NULL, timeout = NULL)
raw_data |
Logical. If 'TRUE', return raw API 'data'. If 'NULL', the current value is left unchanged. |
timeout |
Numeric. HTTP request timeout in seconds. If 'NULL', the current value is left unchanged. |
An invisible named list with the current package options: 'raw_data' (logical) and 'timeout' (numeric seconds). This return value can be used to inspect the effective option state.
old <- getOption("okxr.raw_data") old_timeout <- getOption("okxr.timeout") set_okxr_options(raw_data = TRUE) set_okxr_options(timeout = 5) options(okxr.raw_data = old, okxr.timeout = old_timeout) set_okxr_options() # check current valuesold <- getOption("okxr.raw_data") old_timeout <- getOption("okxr.timeout") set_okxr_options(raw_data = TRUE) set_okxr_options(timeout = 5) options(okxr.raw_data = old, okxr.timeout = old_timeout) set_okxr_options() # check current values