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() -> BybitBuilder
pub fn new() -> BybitBuilder
Creates a new builder with default configuration.
§Example
use ccxt_exchanges::bybit::BybitBuilder;
let builder = BybitBuilder::new();Sourcepub fn api_key(self, key: impl Into<String>) -> BybitBuilder
pub fn api_key(self, key: impl Into<String>) -> BybitBuilder
Sourcepub fn secret(self, secret: impl Into<String>) -> BybitBuilder
pub fn secret(self, secret: impl Into<String>) -> BybitBuilder
Sourcepub fn sandbox(self, enabled: bool) -> BybitBuilder
pub fn sandbox(self, enabled: bool) -> BybitBuilder
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) -> BybitBuilder
pub fn testnet(self, enabled: bool) -> BybitBuilder
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>) -> BybitBuilder
pub fn account_type(self, account_type: impl Into<String>) -> BybitBuilder
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>) -> BybitBuilder
pub fn default_type(self, default_type: impl Into<DefaultType>) -> BybitBuilder
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) -> BybitBuilder
pub fn default_sub_type(self, sub_type: DefaultSubType) -> BybitBuilder
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) -> BybitBuilder
pub fn recv_window(self, millis: u64) -> BybitBuilder
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(self, timeout: Duration) -> BybitBuilder
pub fn timeout(self, timeout: Duration) -> BybitBuilder
Sets the request timeout.
Sourcepub fn timeout_secs(self, seconds: u64) -> BybitBuilder
pub fn timeout_secs(self, seconds: u64) -> BybitBuilder
Sets the request timeout in seconds (convenience method).
Sourcepub fn connect_timeout(self, timeout: Duration) -> BybitBuilder
pub fn connect_timeout(self, timeout: Duration) -> BybitBuilder
Sourcepub fn connect_timeout_secs(self, seconds: u64) -> BybitBuilder
pub fn connect_timeout_secs(self, seconds: u64) -> BybitBuilder
Sets the TCP connection timeout in seconds (convenience method).
§Arguments
seconds- Connection timeout duration in seconds.
Sourcepub fn retry_policy(self, policy: RetryPolicy) -> BybitBuilder
pub fn retry_policy(self, policy: RetryPolicy) -> BybitBuilder
Sets the retry policy.
Sourcepub fn enable_rate_limit(self, enabled: bool) -> BybitBuilder
pub fn enable_rate_limit(self, enabled: bool) -> BybitBuilder
Sourcepub fn proxy(self, proxy: ProxyConfig) -> BybitBuilder
pub fn proxy(self, proxy: ProxyConfig) -> BybitBuilder
Sets the HTTP proxy configuration.
Sourcepub fn proxy_url(self, url: impl Into<String>) -> BybitBuilder
pub fn proxy_url(self, url: impl Into<String>) -> BybitBuilder
Sets the HTTP proxy URL (convenience method).
Sourcepub fn verbose(self, enabled: bool) -> BybitBuilder
pub fn verbose(self, enabled: bool) -> BybitBuilder
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