pub struct OkxBuilder { /* private fields */ }Expand description
Builder for creating OKX exchange instances.
Provides a fluent API for configuring all aspects of the OKX exchange, including authentication, connection settings, and OKX-specific options.
§Example
use ccxt_exchanges::okx::OkxBuilder;
let okx = OkxBuilder::new()
.api_key("your-api-key")
.secret("your-secret")
.passphrase("your-passphrase")
.sandbox(true)
.timeout(30)
.build()
.unwrap();Implementations§
Source§impl OkxBuilder
impl OkxBuilder
Sourcepub fn new() -> OkxBuilder
pub fn new() -> OkxBuilder
Creates a new builder with default configuration.
§Example
use ccxt_exchanges::okx::OkxBuilder;
let builder = OkxBuilder::new();Sourcepub fn api_key(self, key: impl Into<String>) -> OkxBuilder
pub fn api_key(self, key: impl Into<String>) -> OkxBuilder
Sourcepub fn secret(self, secret: impl Into<String>) -> OkxBuilder
pub fn secret(self, secret: impl Into<String>) -> OkxBuilder
Sourcepub fn passphrase(self, passphrase: impl Into<String>) -> OkxBuilder
pub fn passphrase(self, passphrase: impl Into<String>) -> OkxBuilder
Sets the passphrase for authentication.
OKX requires a passphrase in addition to API key and secret.
§Arguments
passphrase- The passphrase string.
Sourcepub fn sandbox(self, enabled: bool) -> OkxBuilder
pub fn sandbox(self, enabled: bool) -> OkxBuilder
Enables or disables sandbox/demo mode.
When enabled, the exchange will connect to OKX’s demo environment instead of the production environment.
§Arguments
enabled- Whether to enable sandbox mode.
Sourcepub fn account_mode(self, mode: impl Into<String>) -> OkxBuilder
pub fn account_mode(self, mode: impl Into<String>) -> OkxBuilder
Sets the account mode for trading.
Valid values: “cash” (spot), “cross” (cross margin), “isolated” (isolated margin).
§Arguments
mode- The account mode string.
Sourcepub fn default_type(self, default_type: impl Into<DefaultType>) -> OkxBuilder
pub fn default_type(self, default_type: impl Into<DefaultType>) -> OkxBuilder
Sets the default market type for trading.
This determines which instrument type (instType) to use for API calls. OKX uses a unified V5 API, so this primarily affects market filtering.
§Arguments
default_type- The default market type (spot, swap, futures, margin, option).
§Example
use ccxt_exchanges::okx::OkxBuilder;
use ccxt_core::types::default_type::DefaultType;
let okx = OkxBuilder::new()
.default_type(DefaultType::Swap)
.build()
.unwrap();Sourcepub fn default_sub_type(self, sub_type: DefaultSubType) -> OkxBuilder
pub fn default_sub_type(self, sub_type: DefaultSubType) -> OkxBuilder
Sets the default sub-type for contract settlement.
Linear: USDT-margined contractsInverse: Coin-margined contracts
Only applicable when default_type is Swap, Futures, or Option.
Ignored for Spot and Margin types.
§Arguments
sub_type- The contract settlement type (linear or inverse).
§Example
use ccxt_exchanges::okx::OkxBuilder;
use ccxt_core::types::default_type::{DefaultType, DefaultSubType};
let okx = OkxBuilder::new()
.default_type(DefaultType::Swap)
.default_sub_type(DefaultSubType::Linear)
.build()
.unwrap();Sourcepub fn timeout(self, timeout: Duration) -> OkxBuilder
pub fn timeout(self, timeout: Duration) -> OkxBuilder
Sets the request timeout.
Sourcepub fn timeout_secs(self, seconds: u64) -> OkxBuilder
pub fn timeout_secs(self, seconds: u64) -> OkxBuilder
Sets the request timeout in seconds (convenience method).
Sourcepub fn connect_timeout(self, timeout: Duration) -> OkxBuilder
pub fn connect_timeout(self, timeout: Duration) -> OkxBuilder
Sourcepub fn connect_timeout_secs(self, seconds: u64) -> OkxBuilder
pub fn connect_timeout_secs(self, seconds: u64) -> OkxBuilder
Sets the TCP connection timeout in seconds (convenience method).
§Arguments
seconds- Connection timeout duration in seconds.
Sourcepub fn retry_policy(self, policy: RetryPolicy) -> OkxBuilder
pub fn retry_policy(self, policy: RetryPolicy) -> OkxBuilder
Sets the retry policy.
Sourcepub fn enable_rate_limit(self, enabled: bool) -> OkxBuilder
pub fn enable_rate_limit(self, enabled: bool) -> OkxBuilder
Sourcepub fn proxy(self, proxy: ProxyConfig) -> OkxBuilder
pub fn proxy(self, proxy: ProxyConfig) -> OkxBuilder
Sets the HTTP proxy configuration.
Sourcepub fn proxy_url(self, url: impl Into<String>) -> OkxBuilder
pub fn proxy_url(self, url: impl Into<String>) -> OkxBuilder
Sets the HTTP proxy URL (convenience method).
Sourcepub fn verbose(self, enabled: bool) -> OkxBuilder
pub fn verbose(self, enabled: bool) -> OkxBuilder
Trait Implementations§
Source§impl Clone for OkxBuilder
impl Clone for OkxBuilder
Source§fn clone(&self) -> OkxBuilder
fn clone(&self) -> OkxBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more