OKXHttpInnerClient

Struct OKXHttpInnerClient 

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

Provides a HTTP client for connecting to the OKX REST API.

This client wraps the underlying HttpClient to handle functionality specific to OKX, such as request signing (for authenticated endpoints), forming request URLs, and deserializing responses into specific data models.

Implementations§

Source§

impl OKXHttpInnerClient

Source

pub fn new(base_url: Option<String>, timeout_secs: Option<u64>) -> Self

Creates a new OKXHttpClient using the default OKX HTTP URL, optionally overridden with a custom base URL.

This version of the client has no credentials, so it can only call publicly accessible endpoints.

Source

pub fn with_credentials( api_key: String, api_secret: String, api_passphrase: String, base_url: String, timeout_secs: Option<u64>, ) -> Self

Creates a new OKXHttpClient configured with credentials for authenticated requests, optionally using a custom base URL.

Source

pub async fn http_set_position_mode( &self, params: SetPositionModeParams, ) -> Result<Vec<Value>, OKXHttpError>

Sets the position mode for an account.

§Errors

Returns an error if JSON serialization of params fails, if the HTTP request fails, or if the response body cannot be deserialized.

§References

https://www.okx.com/docs-v5/en/#trading-account-rest-api-set-position-mode

Source

pub async fn http_get_position_tiers( &self, params: GetPositionTiersParams, ) -> Result<Vec<OKXPositionTier>, OKXHttpError>

Requests position tiers information, maximum leverage depends on your borrowings and margin ratio.

§Errors

Returns an error if the HTTP request fails, authentication is rejected or the response cannot be deserialized.

§References

https://www.okx.com/docs-v5/en/#public-data-rest-api-get-position-tiers

Source

pub async fn http_get_instruments( &self, params: GetInstrumentsParams, ) -> Result<Vec<OKXInstrument>, OKXHttpError>

Requests a list of instruments with open contracts.

§Errors

Returns an error if JSON serialization of params fails, if the HTTP request fails, or if the response body cannot be deserialized.

§References

https://www.okx.com/docs-v5/en/#public-data-rest-api-get-instruments

Source

pub async fn http_get_mark_price( &self, params: GetMarkPriceParams, ) -> Result<Vec<OKXMarkPrice>, OKXHttpError>

Requests a mark price.

We set the mark price based on the SPOT index and at a reasonable basis to prevent individual users from manipulating the market and causing the contract price to fluctuate.

§Errors

Returns an error if the HTTP request fails or if the response body cannot be parsed into OKXMarkPrice.

§References

https://www.okx.com/docs-v5/en/#public-data-rest-api-get-mark-price

Source

pub async fn http_get_index_ticker( &self, params: GetIndexTickerParams, ) -> Result<Vec<OKXIndexTicker>, OKXHttpError>

Source

pub async fn http_get_trades( &self, params: GetTradesParams, ) -> Result<Vec<OKXTrade>, OKXHttpError>

Source

pub async fn http_get_candlesticks( &self, params: GetCandlesticksParams, ) -> Result<Vec<OKXCandlestick>, OKXHttpError>

Source

pub async fn http_get_candlesticks_history( &self, params: GetCandlesticksParams, ) -> Result<Vec<OKXCandlestick>, OKXHttpError>

Source

pub async fn http_get_pending_orders( &self, params: GetPendingOrdersParams, ) -> Result<Vec<OKXOrderHistory>, OKXHttpError>

Source

pub async fn http_get_order( &self, params: GetOrderParams, ) -> Result<Vec<OKXOrderHistory>, OKXHttpError>

Retrieves a single order’s details.

§References

https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order

Source

pub async fn http_get_balance(&self) -> Result<Vec<OKXAccount>, OKXHttpError>

Requests a list of assets (with non-zero balance), remaining balance, and available amount in the trading account.

§References

https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-balance

Source

pub async fn http_get_order_history( &self, params: GetOrderHistoryParams, ) -> Result<Vec<OKXOrderHistory>, OKXHttpError>

Source

pub async fn http_get_order_list( &self, params: GetOrderListParams, ) -> Result<Vec<OKXOrderHistory>, OKXHttpError>

Requests order list (pending orders).

§References

https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-order-list

Source

pub async fn http_get_positions( &self, params: GetPositionsParams, ) -> Result<Vec<OKXPosition>, OKXHttpError>

Requests information on your positions. When the account is in net mode, net positions will be displayed, and when the account is in long/short mode, long or short positions will be displayed. Returns in reverse chronological order using ctime.

§References

https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-positions

Source

pub async fn http_get_position_history( &self, params: GetPositionsHistoryParams, ) -> Result<Vec<OKXPositionHistory>, OKXHttpError>

Requests closed or historical position data.

§References

https://www.okx.com/docs-v5/en/#trading-account-rest-api-get-positions-history

Source

pub async fn http_get_transaction_details( &self, params: GetTransactionDetailsParams, ) -> Result<Vec<OKXTransactionDetail>, OKXHttpError>

Requests transaction details (fills) for the given parameters.

§References

https://www.okx.com/docs-v5/en/#order-book-trading-trade-get-transaction-details-last-3-days

Trait Implementations§

Source§

impl Debug for OKXHttpInnerClient

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for OKXHttpInnerClient

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

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.

§

impl<T> Instrument for T

§

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

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

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> IntoEither for T

Source§

fn into_either(self, into_left: bool) -> Either<Self, Self>

Converts self into a Left variant of Either<Self, Self> if into_left is true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

Converts self into a Left variant of Either<Self, Self> if into_left(&self) returns true. Converts self into a Right variant of Either<Self, Self> otherwise. Read more
§

impl<T> Pointable for T

§

const ALIGN: usize

The alignment of pointer.
§

type Init = T

The type for initializers.
§

unsafe fn init(init: <T as Pointable>::Init) -> usize

Initializes a with the given initializer. Read more
§

unsafe fn deref<'a>(ptr: usize) -> &'a T

Dereferences the given pointer. Read more
§

unsafe fn deref_mut<'a>(ptr: usize) -> &'a mut T

Mutably dereferences the given pointer. Read more
§

unsafe fn drop(ptr: usize)

Drops the object pointed to by the given pointer. Read more
§

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

§

fn and<P, B, E>(self, other: P) -> And<T, P>
where T: 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
§

fn or<P, B, E>(self, other: P) -> Or<T, P>
where T: 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.
§

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

§

fn vzip(self) -> V

§

impl<T> WithSubscriber for T

§

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
§

fn with_current_subscriber(self) -> WithDispatch<Self>

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

impl<T> ErasedDestructor for T
where T: 'static,

§

impl<T> Ungil for T
where T: Send,