Skip to main content

BybitClient

Struct BybitClient 

Source
pub struct BybitClient { /* private fields */ }
Expand description

A thin wrapper over the Bybit v5 REST API.

Implementations§

Source§

impl BybitClient

Source

pub fn new( config: BybitConfig, credentials: Option<BybitCredentials>, exchange: ExchangeId, ) -> Self

Build a new client optionally configured with credentials.

Source

pub fn testnet(credentials: Option<BybitCredentials>) -> Self

Convenience helper for the Bybit testnet.

Source

pub fn get_credentials(&self) -> Option<BybitCredentials>

Source

pub fn exchange(&self) -> ExchangeId

Source

pub fn get_ws_url(&self) -> String

Source

pub async fn server_time(&self) -> BrokerResult<u128>

Fetch Bybit server time (docs/v5/market/time.mdx).

Source

pub async fn list_executions_since( &self, since: DateTime<Utc>, ) -> BrokerResult<Vec<BybitExecution>>

Fetch executions (fills) since the provided timestamp (inclusive), paginated. Maps the response into framework-native Fill records.

Trait Implementations§

Source§

impl ExecutionClient for BybitClient

Source§

fn info(&self) -> BrokerInfo

Return metadata about the connector for telemetry.
Source§

fn place_order<'life0, 'async_trait>( &'life0 self, request: OrderRequest, ) -> Pin<Box<dyn Future<Output = BrokerResult<Order>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Place a new order on the exchange.
Source§

fn cancel_order<'life0, 'async_trait>( &'life0 self, order_id: OrderId, symbol: Symbol, ) -> Pin<Box<dyn Future<Output = BrokerResult<()>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Cancel an existing order by identifier.
Source§

fn amend_order<'life0, 'async_trait>( &'life0 self, request: OrderUpdateRequest, ) -> Pin<Box<dyn Future<Output = BrokerResult<Order>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Amend an existing order in-place when the exchange supports it.
Source§

fn list_open_orders<'life0, 'async_trait>( &'life0 self, symbol: Symbol, ) -> Pin<Box<dyn Future<Output = BrokerResult<Vec<Order>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Get all open orders for a symbol.
Source§

fn account_balances<'life0, 'async_trait>( &'life0 self, ) -> Pin<Box<dyn Future<Output = BrokerResult<Vec<AccountBalance>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait,

Retrieve the latest known account balances.
Source§

fn positions<'life0, 'life1, 'async_trait>( &'life0 self, symbols: Option<&'life1 Vec<Symbol>>, ) -> Pin<Box<dyn Future<Output = BrokerResult<Vec<Position>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieve the current open positions.
Source§

fn list_instruments<'life0, 'life1, 'async_trait>( &'life0 self, category: &'life1 str, ) -> Pin<Box<dyn Future<Output = BrokerResult<Vec<Instrument>>> + Send + 'async_trait>>
where Self: 'async_trait, 'life0: 'async_trait, 'life1: 'async_trait,

Retrieve instrument metadata for the provided market category.
Source§

fn as_any(&self) -> &dyn Any

Helper for downcasting to a concrete type.
Source§

fn list_order_fills<'life0, 'life1, 'async_trait>( &'life0 self, order_id: &'life1 str, symbol: Symbol, ) -> Pin<Box<dyn Future<Output = Result<Vec<Fill>, BrokerError>> + Send + 'async_trait>>
where 'life0: 'async_trait, 'life1: 'async_trait, Self: 'async_trait,

Retrieve historical fills for an order when the exchange exposes this API.

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> PolicyExt for T
where T: ?Sized,

Source§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow only if self and other return Action::Follow. Read more
Source§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: Sized + Policy<B, E>, P: Policy<B, E>,

Create a new Policy that returns Action::Follow if either self or other returns Action::Follow. Read more
Source§

impl<T> Same for T

Source§

type Output = T

Should always be Self
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V

Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more