pub struct BybitBuilder { /* private fields */ }Expand description
Builder for creating Bybit exchange instances.
Provides a fluent API for configuring all aspects of the Bybit exchange, including authentication, connection settings, and Bybit-specific options.
§Example
use ccxt_exchanges::bybit::BybitBuilder;
let bybit = BybitBuilder::new()
.api_key("your-api-key")
.secret("your-secret")
.testnet(true)
.timeout(30)
.build()
.unwrap();Implementations§
Source§impl BybitBuilder
impl BybitBuilder
Sourcepub fn new() -> Self
pub fn new() -> Self
Creates a new builder with default configuration.
§Example
use ccxt_exchanges::bybit::BybitBuilder;
let builder = BybitBuilder::new();Sourcepub fn sandbox(self, enabled: bool) -> Self
pub fn sandbox(self, enabled: bool) -> Self
Enables or disables sandbox/testnet mode.
When enabled, the exchange will connect to Bybit’s testnet environment instead of the production environment.
This method is equivalent to testnet() and is provided for
consistency with other exchanges.
§Arguments
enabled- Whether to enable sandbox mode.
Sourcepub fn testnet(self, enabled: bool) -> Self
pub fn testnet(self, enabled: bool) -> Self
Enables or disables testnet mode.
When enabled, the exchange will connect to Bybit’s testnet environment instead of the production environment.
This method is equivalent to sandbox() and is provided for
backward compatibility.
§Arguments
enabled- Whether to enable testnet mode.
Sourcepub fn account_type(self, account_type: impl Into<String>) -> Self
pub fn account_type(self, account_type: impl Into<String>) -> Self
Sets the account type for trading.
Valid values: “UNIFIED”, “CONTRACT”, “SPOT”.
§Arguments
account_type- The account type string.
Sourcepub fn default_type(self, default_type: impl Into<DefaultType>) -> Self
pub fn default_type(self, default_type: impl Into<DefaultType>) -> Self
Sets the default market type for trading.
This determines which category to use for API calls. Bybit uses a unified V5 API with category-based filtering:
Spot-> category=spotSwap+ Linear -> category=linearSwap+ Inverse -> category=inverseOption-> category=option
§Arguments
default_type- The default market type (spot, swap, futures, option).
§Example
use ccxt_exchanges::bybit::BybitBuilder;
use ccxt_core::types::default_type::DefaultType;
let bybit = BybitBuilder::new()
.default_type(DefaultType::Swap)
.build()
.unwrap();Sourcepub fn default_sub_type(self, sub_type: DefaultSubType) -> Self
pub fn default_sub_type(self, sub_type: DefaultSubType) -> Self
Sets the default sub-type for contract settlement.
Linear: USDT-margined contracts (category=linear)Inverse: Coin-margined contracts (category=inverse)
Only applicable when default_type is Swap or Futures.
Ignored for Spot and Option types.
§Arguments
sub_type- The contract settlement type (linear or inverse).
§Example
use ccxt_exchanges::bybit::BybitBuilder;
use ccxt_core::types::default_type::{DefaultType, DefaultSubType};
let bybit = BybitBuilder::new()
.default_type(DefaultType::Swap)
.default_sub_type(DefaultSubType::Linear)
.build()
.unwrap();Sourcepub fn recv_window(self, millis: u64) -> Self
pub fn recv_window(self, millis: u64) -> Self
Sets the receive window for signed requests.
The receive window specifies how long a request is valid after the timestamp. Default is 5000 milliseconds.
§Arguments
millis- Receive window in milliseconds.
Sourcepub fn timeout_secs(self, seconds: u64) -> Self
pub fn timeout_secs(self, seconds: u64) -> Self
Sets the request timeout in seconds (convenience method).
Sourcepub fn connect_timeout(self, timeout: Duration) -> Self
pub fn connect_timeout(self, timeout: Duration) -> Self
Sourcepub fn connect_timeout_secs(self, seconds: u64) -> Self
pub fn connect_timeout_secs(self, seconds: u64) -> Self
Sets the TCP connection timeout in seconds (convenience method).
§Arguments
seconds- Connection timeout duration in seconds.
Sourcepub fn retry_policy(self, policy: RetryPolicy) -> Self
pub fn retry_policy(self, policy: RetryPolicy) -> Self
Sets the retry policy.
Sourcepub fn enable_rate_limit(self, enabled: bool) -> Self
pub fn enable_rate_limit(self, enabled: bool) -> Self
Sourcepub fn proxy(self, proxy: ProxyConfig) -> Self
pub fn proxy(self, proxy: ProxyConfig) -> Self
Sets the HTTP proxy configuration.
Sourcepub fn proxy_url(self, url: impl Into<String>) -> Self
pub fn proxy_url(self, url: impl Into<String>) -> Self
Sets the HTTP proxy URL (convenience method).
Trait Implementations§
Source§impl Clone for BybitBuilder
impl Clone for BybitBuilder
Source§fn clone(&self) -> BybitBuilder
fn clone(&self) -> BybitBuilder
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read more