pub struct Bybit { /* private fields */ }Expand description
Bybit exchange structure.
Implementations§
Source§impl Bybit
impl Bybit
Sourcepub fn check_required_credentials(&self) -> Result<()>
pub fn check_required_credentials(&self) -> Result<()>
Check that required credentials are configured.
Sourcepub async fn fetch_markets(&self) -> Result<Vec<Market>>
pub async fn fetch_markets(&self) -> Result<Vec<Market>>
Fetch all trading markets.
§Returns
Returns a vector of Market structures containing market information.
§Errors
Returns an error if the API request fails or response parsing fails.
§Example
let bybit = Bybit::builder().build()?;
let markets = bybit.fetch_markets().await?;
println!("Found {} markets", markets.len());Sourcepub async fn fetch_ticker(&self, symbol: &str) -> Result<Ticker>
pub async fn fetch_ticker(&self, symbol: &str) -> Result<Ticker>
Sourcepub async fn fetch_order_book(
&self,
symbol: &str,
limit: Option<u32>,
) -> Result<OrderBook>
pub async fn fetch_order_book( &self, symbol: &str, limit: Option<u32>, ) -> Result<OrderBook>
Sourcepub async fn fetch_ohlcv(
&self,
symbol: &str,
timeframe: &str,
since: Option<i64>,
limit: Option<u32>,
) -> Result<Vec<OHLCV>>
pub async fn fetch_ohlcv( &self, symbol: &str, timeframe: &str, since: Option<i64>, limit: Option<u32>, ) -> Result<Vec<OHLCV>>
Sourcepub async fn fetch_balance(&self) -> Result<Balance>
pub async fn fetch_balance(&self) -> Result<Balance>
Sourcepub async fn fetch_my_trades(
&self,
symbol: &str,
since: Option<i64>,
limit: Option<u32>,
) -> Result<Vec<Trade>>
pub async fn fetch_my_trades( &self, symbol: &str, since: Option<i64>, limit: Option<u32>, ) -> Result<Vec<Trade>>
Sourcepub async fn create_order(
&self,
symbol: &str,
order_type: OrderType,
side: OrderSide,
amount: f64,
price: Option<f64>,
) -> Result<Order>
pub async fn create_order( &self, symbol: &str, order_type: OrderType, side: OrderSide, amount: f64, price: Option<f64>, ) -> Result<Order>
Sourcepub async fn fetch_open_orders(
&self,
symbol: Option<&str>,
since: Option<i64>,
limit: Option<u32>,
) -> Result<Vec<Order>>
pub async fn fetch_open_orders( &self, symbol: Option<&str>, since: Option<i64>, limit: Option<u32>, ) -> Result<Vec<Order>>
Source§impl Bybit
impl Bybit
Sourcepub fn builder() -> BybitBuilder
pub fn builder() -> BybitBuilder
Creates a new Bybit instance using the builder pattern.
This is the recommended way to create a Bybit instance.
§Example
use ccxt_exchanges::bybit::Bybit;
let bybit = Bybit::builder()
.api_key("your-api-key")
.secret("your-secret")
.testnet(true)
.build()
.unwrap();Sourcepub fn new(config: ExchangeConfig) -> Result<Self>
pub fn new(config: ExchangeConfig) -> Result<Self>
Sourcepub fn new_with_options(
config: ExchangeConfig,
options: BybitOptions,
) -> Result<Self>
pub fn new_with_options( config: ExchangeConfig, options: BybitOptions, ) -> Result<Self>
Creates a new Bybit instance with custom options.
This is used internally by the builder pattern.
§Arguments
config- Exchange configuration.options- Bybit-specific options.
Sourcepub fn base(&self) -> &BaseExchange
pub fn base(&self) -> &BaseExchange
Returns a reference to the base exchange.
Sourcepub fn base_mut(&mut self) -> &mut BaseExchange
pub fn base_mut(&mut self) -> &mut BaseExchange
Returns a mutable reference to the base exchange.
Sourcepub fn options(&self) -> &BybitOptions
pub fn options(&self) -> &BybitOptions
Returns the Bybit options.
Sourcepub fn set_options(&mut self, options: BybitOptions)
pub fn set_options(&mut self, options: BybitOptions)
Sets the Bybit options.
Sourcepub fn rate_limit(&self) -> f64
pub fn rate_limit(&self) -> f64
Returns the rate limit in requests per second.
Sourcepub fn timeframes(&self) -> HashMap<String, String>
pub fn timeframes(&self) -> HashMap<String, String>
Returns the supported timeframes.
Trait Implementations§
Source§impl WsExchange for Bybit
impl WsExchange for Bybit
Source§fn ws_connect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn ws_connect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Connect to the WebSocket server Read more
Source§fn ws_disconnect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn ws_disconnect<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Disconnect from the WebSocket server Read more
Source§fn ws_is_connected(&self) -> bool
fn ws_is_connected(&self) -> bool
Check if WebSocket is connected Read more
Source§fn ws_state(&self) -> WsConnectionState
fn ws_state(&self) -> WsConnectionState
Get WebSocket connection state Read more
Source§fn watch_ticker<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<MessageStream<Ticker>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn watch_ticker<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<MessageStream<Ticker>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Watch ticker updates for a symbol Read more
Source§fn watch_tickers<'life0, 'life1, 'async_trait>(
&'life0 self,
_symbols: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<MessageStream<Vec<Ticker>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn watch_tickers<'life0, 'life1, 'async_trait>(
&'life0 self,
_symbols: &'life1 [String],
) -> Pin<Box<dyn Future<Output = Result<MessageStream<Vec<Ticker>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Watch tickers for multiple symbols Read more
Source§fn watch_order_book<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<MessageStream<OrderBook>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn watch_order_book<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
limit: Option<u32>,
) -> Pin<Box<dyn Future<Output = Result<MessageStream<OrderBook>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Watch order book updates Read more
Source§fn watch_trades<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<MessageStream<Vec<Trade>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn watch_trades<'life0, 'life1, 'async_trait>(
&'life0 self,
symbol: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<MessageStream<Vec<Trade>>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Watch public trades Read more
Source§fn watch_ohlcv<'life0, 'life1, 'async_trait>(
&'life0 self,
_symbol: &'life1 str,
_timeframe: Timeframe,
) -> Pin<Box<dyn Future<Output = Result<MessageStream<Ohlcv>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn watch_ohlcv<'life0, 'life1, 'async_trait>(
&'life0 self,
_symbol: &'life1 str,
_timeframe: Timeframe,
) -> Pin<Box<dyn Future<Output = Result<MessageStream<Ohlcv>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Watch OHLCV candlestick updates Read more
Source§fn watch_balance<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<MessageStream<Balance>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
fn watch_balance<'life0, 'async_trait>(
&'life0 self,
) -> Pin<Box<dyn Future<Output = Result<MessageStream<Balance>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
Watch account balance updates Read more
Source§fn watch_orders<'life0, 'life1, 'async_trait>(
&'life0 self,
_symbol: Option<&'life1 str>,
) -> Pin<Box<dyn Future<Output = Result<MessageStream<Order>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn watch_orders<'life0, 'life1, 'async_trait>(
&'life0 self,
_symbol: Option<&'life1 str>,
) -> Pin<Box<dyn Future<Output = Result<MessageStream<Order>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Watch order updates Read more
Source§fn watch_my_trades<'life0, 'life1, 'async_trait>(
&'life0 self,
_symbol: Option<&'life1 str>,
) -> Pin<Box<dyn Future<Output = Result<MessageStream<Trade>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
fn watch_my_trades<'life0, 'life1, 'async_trait>(
&'life0 self,
_symbol: Option<&'life1 str>,
) -> Pin<Box<dyn Future<Output = Result<MessageStream<Trade>>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
Watch user trade updates Read more
Source§fn subscribe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_channel: &'life1 str,
_symbol: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn subscribe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_channel: &'life1 str,
_symbol: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Subscribe to a channel Read more
Source§fn unsubscribe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_channel: &'life1 str,
_symbol: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
fn unsubscribe<'life0, 'life1, 'life2, 'async_trait>(
&'life0 self,
_channel: &'life1 str,
_symbol: Option<&'life2 str>,
) -> Pin<Box<dyn Future<Output = Result<()>> + Send + 'async_trait>>where
Self: 'async_trait,
'life0: 'async_trait,
'life1: 'async_trait,
'life2: 'async_trait,
Unsubscribe from a channel Read more
Auto Trait Implementations§
impl Freeze for Bybit
impl !RefUnwindSafe for Bybit
impl Send for Bybit
impl Sync for Bybit
impl Unpin for Bybit
impl !UnwindSafe for Bybit
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Mutably borrows from an owned value. Read more