pub struct Okx { /* private fields */ }Expand description
OKX exchange structure.
Implementations§
Source§impl Okx
impl Okx
Sourcepub fn check_required_credentials(&self) -> Result<(), Error>
pub fn check_required_credentials(&self) -> Result<(), Error>
Check that required credentials are configured.
Sourcepub async fn fetch_markets(&self) -> Result<Vec<Market>, Error>
pub async fn fetch_markets(&self) -> Result<Vec<Market>, Error>
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 okx = Okx::builder().build()?;
let markets = okx.fetch_markets().await?;
println!("Found {} markets", markets.len());Sourcepub async fn fetch_tickers(
&self,
symbols: Option<Vec<String>>,
) -> Result<Vec<Ticker>, Error>
pub async fn fetch_tickers( &self, symbols: Option<Vec<String>>, ) -> Result<Vec<Ticker>, Error>
Sourcepub async fn fetch_order_book(
&self,
symbol: &str,
limit: Option<u32>,
) -> Result<OrderBook, Error>
pub async fn fetch_order_book( &self, symbol: &str, limit: Option<u32>, ) -> Result<OrderBook, Error>
Sourcepub async fn fetch_trades(
&self,
symbol: &str,
limit: Option<u32>,
) -> Result<Vec<Trade>, Error>
pub async fn fetch_trades( &self, symbol: &str, limit: Option<u32>, ) -> Result<Vec<Trade>, Error>
Sourcepub async fn fetch_ohlcv(
&self,
symbol: &str,
timeframe: &str,
since: Option<i64>,
limit: Option<u32>,
) -> Result<Vec<OHLCV>, Error>
pub async fn fetch_ohlcv( &self, symbol: &str, timeframe: &str, since: Option<i64>, limit: Option<u32>, ) -> Result<Vec<OHLCV>, Error>
Sourcepub async fn fetch_balance(&self) -> Result<Balance, Error>
pub async fn fetch_balance(&self) -> Result<Balance, Error>
Sourcepub async fn fetch_my_trades(
&self,
symbol: &str,
since: Option<i64>,
limit: Option<u32>,
) -> Result<Vec<Trade>, Error>
pub async fn fetch_my_trades( &self, symbol: &str, since: Option<i64>, limit: Option<u32>, ) -> Result<Vec<Trade>, Error>
Sourcepub async fn create_order(
&self,
symbol: &str,
order_type: OrderType,
side: OrderSide,
amount: f64,
price: Option<f64>,
) -> Result<Order, Error>
pub async fn create_order( &self, symbol: &str, order_type: OrderType, side: OrderSide, amount: f64, price: Option<f64>, ) -> Result<Order, Error>
Sourcepub async fn fetch_open_orders(
&self,
symbol: Option<&str>,
since: Option<i64>,
limit: Option<u32>,
) -> Result<Vec<Order>, Error>
pub async fn fetch_open_orders( &self, symbol: Option<&str>, since: Option<i64>, limit: Option<u32>, ) -> Result<Vec<Order>, Error>
Source§impl Okx
impl Okx
Sourcepub fn builder() -> OkxBuilder
pub fn builder() -> OkxBuilder
Creates a new OKX instance using the builder pattern.
This is the recommended way to create an OKX instance.
§Example
use ccxt_exchanges::okx::Okx;
let okx = Okx::builder()
.api_key("your-api-key")
.secret("your-secret")
.passphrase("your-passphrase")
.sandbox(true)
.build()
.unwrap();Sourcepub fn new_with_options(
config: ExchangeConfig,
options: OkxOptions,
) -> Result<Okx, Error>
pub fn new_with_options( config: ExchangeConfig, options: OkxOptions, ) -> Result<Okx, Error>
Creates a new OKX instance with custom options.
This is used internally by the builder pattern.
§Arguments
config- Exchange configuration.options- OKX-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) -> &OkxOptions
pub fn options(&self) -> &OkxOptions
Returns the OKX options.
Sourcepub fn set_options(&mut self, options: OkxOptions)
pub fn set_options(&mut self, options: OkxOptions)
Sets the OKX 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.
Sourcepub fn create_ws(&self) -> OkxWs
pub fn create_ws(&self) -> OkxWs
Creates a new WebSocket client for OKX.
Returns an OkxWs instance configured with the appropriate WebSocket URL
based on the exchange configuration (production or demo).
§Example
use ccxt_exchanges::okx::Okx;
use ccxt_core::ExchangeConfig;
let okx = Okx::new(ExchangeConfig::default())?;
let ws = okx.create_ws();
ws.connect().await?;