AxRawHttpClient

Struct AxRawHttpClient 

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

Raw HTTP client for low-level AX Exchange API operations.

This client handles request/response operations with the AX Exchange API, returning venue-specific response types. It does not parse to Nautilus domain types.

Implementations§

Source§

impl AxRawHttpClient

Source

pub fn base_url(&self) -> &str

Returns the base URL for this client.

Source

pub fn cancel_all_requests(&self)

Cancel all pending HTTP requests.

Source

pub fn cancellation_token(&self) -> &CancellationToken

Get the cancellation token for this client.

Source

pub fn new( base_url: Option<String>, orders_base_url: Option<String>, timeout_secs: Option<u64>, max_retries: Option<u32>, retry_delay_ms: Option<u64>, retry_delay_max_ms: Option<u64>, proxy_url: Option<String>, ) -> Result<Self, AxHttpError>

Creates a new AxRawHttpClient using the default Ax HTTP URL.

§Errors

Returns an error if the retry manager cannot be created.

Source

pub fn with_credentials( api_key: String, api_secret: String, base_url: Option<String>, orders_base_url: Option<String>, timeout_secs: Option<u64>, max_retries: Option<u32>, retry_delay_ms: Option<u64>, retry_delay_max_ms: Option<u64>, proxy_url: Option<String>, ) -> Result<Self, AxHttpError>

Creates a new AxRawHttpClient configured with credentials.

§Errors

Returns an error if the HTTP client cannot be created.

Source

pub fn set_session_token(&self, token: String)

Sets the session token for authenticated requests.

The session token is obtained through the login flow and used for bearer token authentication.

§Panics

Panics if the internal lock is poisoned (indicates a panic in another thread).

Source

pub async fn get_whoami(&self) -> Result<AxWhoAmI, AxHttpError>

Fetches the current authenticated user information.

§Endpoint

GET /whoami

§Errors

Returns an error if the request fails or the response cannot be parsed.

Source

pub async fn get_instruments( &self, ) -> Result<AxInstrumentsResponse, AxHttpError>

Fetches all available instruments.

§Endpoint

GET /instruments

§Errors

Returns an error if the request fails or the response cannot be parsed.

Source

pub async fn get_balances(&self) -> Result<AxBalancesResponse, AxHttpError>

Fetches all account balances for the authenticated user.

§Endpoint

GET /balances

§Errors

Returns an error if the request fails or the response cannot be parsed.

Source

pub async fn get_positions(&self) -> Result<AxPositionsResponse, AxHttpError>

Fetches all open positions for the authenticated user.

§Endpoint

GET /positions

§Errors

Returns an error if the request fails or the response cannot be parsed.

Source

pub async fn get_tickers(&self) -> Result<AxTickersResponse, AxHttpError>

Fetches all tickers.

§Endpoint

GET /tickers

§Errors

Returns an error if the request fails or the response cannot be parsed.

Source

pub async fn get_ticker(&self, symbol: &str) -> Result<AxTicker, AxHttpError>

Fetches a single ticker by symbol.

§Endpoint

GET /ticker?symbol=<symbol>

§Errors

Returns an error if the request fails or the response cannot be parsed.

Source

pub async fn get_instrument( &self, symbol: &str, ) -> Result<AxInstrument, AxHttpError>

Fetches a single instrument by symbol.

§Endpoint

GET /instrument?symbol=<symbol>

§Errors

Returns an error if the request fails or the response cannot be parsed.

Source

pub async fn authenticate( &self, api_key: &str, api_secret: &str, expiration_seconds: i32, ) -> Result<AxAuthenticateResponse, AxHttpError>

Authenticates using API key and secret to obtain a session token.

§Endpoint

POST /authenticate

§Errors

Returns an error if the request fails or the response cannot be parsed.

Source

pub async fn authenticate_with_totp( &self, api_key: &str, api_secret: &str, expiration_seconds: i32, totp: Option<&str>, ) -> Result<AxAuthenticateResponse, AxHttpError>

Authenticates with the AX Exchange API using API key credentials and optional 2FA.

§Endpoint

POST /authenticate

§Errors

Returns an error if:

  • 400: 2FA is required but totp was not provided.
  • 401: Invalid credentials.
Source

pub async fn place_order( &self, request: &PlaceOrderRequest, ) -> Result<AxPlaceOrderResponse, AxHttpError>

Places a new order.

§Endpoint

POST /place_order (orders base URL)

§Errors

Returns an error if the request fails or the response cannot be parsed.

Source

pub async fn cancel_order( &self, order_id: &str, ) -> Result<AxCancelOrderResponse, AxHttpError>

Cancels an existing order.

§Endpoint

POST /cancel_order (orders base URL)

§Errors

Returns an error if the request fails or the response cannot be parsed.

Source

pub async fn get_open_orders(&self) -> Result<AxOpenOrdersResponse, AxHttpError>

Fetches all open orders.

§Endpoint

GET /open_orders (orders base URL)

§Errors

Returns an error if the request fails or the response cannot be parsed.

Source

pub async fn get_fills(&self) -> Result<AxFillsResponse, AxHttpError>

Fetches all fills/trades.

§Endpoint

GET /fills

§Errors

Returns an error if the request fails or the response cannot be parsed.

Source

pub async fn get_candles( &self, symbol: &str, start_timestamp_ns: i64, end_timestamp_ns: i64, candle_width: AxCandleWidth, ) -> Result<AxCandlesResponse, AxHttpError>

Fetches historical candles.

§Endpoint

GET /candles

§Errors

Returns an error if the request fails or the response cannot be parsed.

Source

pub async fn get_current_candle( &self, symbol: &str, candle_width: AxCandleWidth, ) -> Result<AxCandle, AxHttpError>

Fetches the current (incomplete) candle.

§Endpoint

GET /candles/current

§Errors

Returns an error if the request fails or the response cannot be parsed.

Source

pub async fn get_last_candle( &self, symbol: &str, candle_width: AxCandleWidth, ) -> Result<AxCandle, AxHttpError>

Fetches the last completed candle.

§Endpoint

GET /candles/last

§Errors

Returns an error if the request fails or the response cannot be parsed.

Source

pub async fn get_funding_rates( &self, symbol: &str, start_timestamp_ns: i64, end_timestamp_ns: i64, ) -> Result<AxFundingRatesResponse, AxHttpError>

Fetches funding rates for a symbol.

§Endpoint

GET /funding-rates

§Errors

Returns an error if the request fails or the response cannot be parsed.

Source

pub async fn get_risk_snapshot( &self, ) -> Result<AxRiskSnapshotResponse, AxHttpError>

Fetches the current risk snapshot.

§Endpoint

GET /risk-snapshot

§Errors

Returns an error if the request fails or the response cannot be parsed.

Source

pub async fn get_transactions( &self, transaction_types: Vec<String>, ) -> Result<AxTransactionsResponse, AxHttpError>

Fetches transactions filtered by type.

§Endpoint

GET /transactions

§Errors

Returns an error if the request fails or the response cannot be parsed.

Trait Implementations§

Source§

impl Debug for AxRawHttpClient

Source§

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

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

impl Default for AxRawHttpClient

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> 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> Ungil for T
where T: Send,