pub struct Bitget { /* private fields */ }Expand description
Bitget exchange structure.
Implementations§
Source§impl Bitget
impl Bitget
Sourcepub async fn fetch_funding_rate_impl(&self, symbol: &str) -> Result<FundingRate>
pub async fn fetch_funding_rate_impl(&self, symbol: &str) -> Result<FundingRate>
Fetch current funding rate for a symbol.
Uses Bitget GET /api/v2/mix/market/current-fund-rate (public endpoint).
Sourcepub async fn fetch_funding_rates_impl(
&self,
symbols: &[&str],
) -> Result<Vec<FundingRate>>
pub async fn fetch_funding_rates_impl( &self, symbols: &[&str], ) -> Result<Vec<FundingRate>>
Fetch funding rates for multiple symbols.
Sourcepub async fn fetch_funding_rate_history_impl(
&self,
symbol: &str,
since: Option<i64>,
limit: Option<u32>,
) -> Result<Vec<FundingRateHistory>>
pub async fn fetch_funding_rate_history_impl( &self, symbol: &str, since: Option<i64>, limit: Option<u32>, ) -> Result<Vec<FundingRateHistory>>
Fetch funding rate history for a symbol.
Uses Bitget GET /api/v2/mix/market/history-fund-rate (public endpoint).
Source§impl Bitget
impl Bitget
Sourcepub async fn set_leverage_impl(
&self,
symbol: &str,
leverage: u32,
margin_mode: Option<&str>,
) -> Result<()>
pub async fn set_leverage_impl( &self, symbol: &str, leverage: u32, margin_mode: Option<&str>, ) -> Result<()>
Set leverage for a symbol.
Uses Bitget POST /api/v2/mix/account/set-leverage endpoint.
Sourcepub async fn get_leverage_impl(&self, symbol: &str) -> Result<u32>
pub async fn get_leverage_impl(&self, symbol: &str) -> Result<u32>
Get current leverage for a symbol.
Uses Bitget GET /api/v2/mix/account/account endpoint and extracts leverage.
Source§impl Bitget
impl Bitget
Sourcepub async fn fetch_position_impl(&self, symbol: &str) -> Result<Position>
pub async fn fetch_position_impl(&self, symbol: &str) -> Result<Position>
Fetch a single position for a symbol.
Uses Bitget GET /api/v2/mix/position/single-position endpoint.
Source§impl Bitget
impl Bitget
Sourcepub async fn fetch_markets(&self) -> Result<Arc<HashMap<String, Arc<Market>>>>
pub async fn fetch_markets(&self) -> Result<Arc<HashMap<String, Arc<Market>>>>
Fetch all trading markets.
Sourcepub async fn load_markets(
&self,
reload: bool,
) -> Result<Arc<HashMap<String, Arc<Market>>>>
pub async fn load_markets( &self, reload: bool, ) -> Result<Arc<HashMap<String, Arc<Market>>>>
Load and cache market data.
Sourcepub async fn fetch_ticker(&self, symbol: &str) -> Result<Ticker>
pub async fn fetch_ticker(&self, symbol: &str) -> Result<Ticker>
Fetch ticker for a single trading pair.
Sourcepub async fn fetch_tickers(
&self,
symbols: Option<Vec<String>>,
) -> Result<Vec<Ticker>>
pub async fn fetch_tickers( &self, symbols: Option<Vec<String>>, ) -> Result<Vec<Ticker>>
Fetch tickers for multiple trading pairs.
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>
Fetch order book for a trading pair.
Sourcepub async fn fetch_trades(
&self,
symbol: &str,
limit: Option<u32>,
) -> Result<Vec<Trade>>
pub async fn fetch_trades( &self, symbol: &str, limit: Option<u32>, ) -> Result<Vec<Trade>>
Fetch recent public trades.
Sourcepub async fn fetch_ohlcv_v2(&self, request: OhlcvRequest) -> Result<Vec<OHLCV>>
pub async fn fetch_ohlcv_v2(&self, request: OhlcvRequest) -> Result<Vec<OHLCV>>
Fetch OHLCV (candlestick) data.
Source§impl Bitget
impl Bitget
Sourcepub async fn create_order_v2(&self, request: OrderRequest) -> Result<Order>
pub async fn create_order_v2(&self, request: OrderRequest) -> Result<Order>
Create a new order.
Sourcepub async fn create_order(
&self,
symbol: &str,
order_type: OrderType,
side: OrderSide,
amount: Amount,
price: Option<Price>,
) -> Result<Order>
👎Deprecated since 0.2.0: Use create_order_v2 with OrderRequest::builder() instead
pub async fn create_order( &self, symbol: &str, order_type: OrderType, side: OrderSide, amount: Amount, price: Option<Price>, ) -> Result<Order>
Create a new order (deprecated).
Sourcepub async fn cancel_order(&self, id: &str, symbol: &str) -> Result<Order>
pub async fn cancel_order(&self, id: &str, symbol: &str) -> Result<Order>
Cancel an existing order.
Sourcepub async fn fetch_order(&self, id: &str, symbol: &str) -> Result<Order>
pub async fn fetch_order(&self, id: &str, symbol: &str) -> Result<Order>
Fetch a single order by ID.
Source§impl Bitget
impl Bitget
Sourcepub fn get_auth(&self) -> Result<BitgetAuth>
pub fn get_auth(&self) -> Result<BitgetAuth>
Get the authentication instance if credentials are configured.
Sourcepub fn check_required_credentials(&self) -> Result<()>
pub fn check_required_credentials(&self) -> Result<()>
Check that required credentials are configured.
Source§impl Bitget
impl Bitget
Sourcepub fn builder() -> BitgetBuilder
pub fn builder() -> BitgetBuilder
Creates a new Bitget instance using the builder pattern.
This is the recommended way to create a Bitget instance.
§Example
use ccxt_exchanges::bitget::Bitget;
let bitget = Bitget::builder()
.api_key("your-api-key")
.secret("your-secret")
.passphrase("your-passphrase")
.sandbox(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: BitgetOptions,
) -> Result<Self>
pub fn new_with_options( config: ExchangeConfig, options: BitgetOptions, ) -> Result<Self>
Creates a new Bitget instance with custom options.
This is used internally by the builder pattern.
§Arguments
config- Exchange configuration.options- Bitget-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) -> &BitgetOptions
pub fn options(&self) -> &BitgetOptions
Returns the Bitget options.
Sourcepub fn set_options(&mut self, options: BitgetOptions)
pub fn set_options(&mut self, options: BitgetOptions)
Sets the Bitget options.
Sourcepub fn rate_limit(&self) -> u32
pub fn rate_limit(&self) -> u32
Returns the rate limit in requests per second.
Sourcepub fn is_sandbox(&self) -> bool
pub fn is_sandbox(&self) -> bool
Returns true if sandbox/testnet mode is enabled.
Sandbox mode is enabled when either:
config.sandboxis set totrueoptions.testnetis set totrue
§Returns
true if sandbox mode is enabled, false otherwise.
§Example
use ccxt_exchanges::bitget::Bitget;
use ccxt_core::ExchangeConfig;
let config = ExchangeConfig {
sandbox: true,
..Default::default()
};
let bitget = Bitget::new(config).unwrap();
assert!(bitget.is_sandbox());Sourcepub fn timeframes(&self) -> HashMap<String, String>
pub fn timeframes(&self) -> HashMap<String, String>
Returns the supported timeframes.
Sourcepub fn urls(&self) -> BitgetUrls
pub fn urls(&self) -> BitgetUrls
Returns the API URLs.
Returns testnet URLs when sandbox mode is enabled (via config.sandbox or options.testnet),
otherwise returns production URLs.
§Returns
BitgetUrls::testnet()when sandbox mode is enabledBitgetUrls::production()when sandbox mode is disabled
Sourcepub fn create_private_ws(&self) -> BitgetWs
pub fn create_private_ws(&self) -> BitgetWs
Creates a new private WebSocket client for Bitget.
Returns a BitgetWs instance configured with the private WebSocket URL.
The caller must call login() on the returned client before subscribing
to private channels.
Sourcepub fn signed_request(
&self,
endpoint: impl Into<String>,
) -> BitgetSignedRequestBuilder<'_>
pub fn signed_request( &self, endpoint: impl Into<String>, ) -> BitgetSignedRequestBuilder<'_>
Creates a signed request builder for authenticated API requests.
§Arguments
endpoint- API endpoint path (e.g., “/api/v2/spot/account/assets”)
§Returns
Returns a BitgetSignedRequestBuilder for fluent API construction.
§Example
use ccxt_exchanges::bitget::Bitget;
use ccxt_exchanges::bitget::signed_request::HttpMethod;
use ccxt_core::ExchangeConfig;
let bitget = Bitget::new(ExchangeConfig::default())?;
let data = bitget.signed_request("/api/v2/spot/account/assets")
.execute()
.await?;