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
impl AxRawHttpClient
Sourcepub fn api_key_masked(&self) -> String
pub fn api_key_masked(&self) -> String
Returns a masked version of the API key for logging purposes.
Sourcepub fn cancel_all_requests(&self)
pub fn cancel_all_requests(&self)
Sourcepub fn reset_cancellation_token(&self)
pub fn reset_cancellation_token(&self)
Replaces the cancelled token so new requests can proceed after reconnect.
§Panics
Panics if the cancellation token lock is poisoned.
Sourcepub fn cancellation_token(&self) -> CancellationToken
pub fn cancellation_token(&self) -> CancellationToken
Get a clone of the current cancellation token.
§Panics
Panics if the cancellation token lock is poisoned.
Sourcepub 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>
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.
Sourcepub 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>
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.
Sourcepub fn set_session_token(&self, token: String)
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).
Sourcepub async fn get_whoami(&self) -> Result<AxWhoAmI, AxHttpError>
pub async fn get_whoami(&self) -> Result<AxWhoAmI, AxHttpError>
Sourcepub async fn get_instruments(
&self,
) -> Result<AxInstrumentsResponse, AxHttpError>
pub async fn get_instruments( &self, ) -> Result<AxInstrumentsResponse, AxHttpError>
Sourcepub async fn get_balances(&self) -> Result<AxBalancesResponse, AxHttpError>
pub async fn get_balances(&self) -> Result<AxBalancesResponse, AxHttpError>
Sourcepub async fn get_positions(&self) -> Result<AxPositionsResponse, AxHttpError>
pub async fn get_positions(&self) -> Result<AxPositionsResponse, AxHttpError>
Sourcepub async fn get_tickers(&self) -> Result<AxTickersResponse, AxHttpError>
pub async fn get_tickers(&self) -> Result<AxTickersResponse, AxHttpError>
Sourcepub async fn get_ticker(&self, symbol: Ustr) -> Result<AxTicker, AxHttpError>
pub async fn get_ticker(&self, symbol: Ustr) -> Result<AxTicker, AxHttpError>
Sourcepub async fn get_instrument(
&self,
symbol: Ustr,
) -> Result<AxInstrument, AxHttpError>
pub async fn get_instrument( &self, symbol: Ustr, ) -> Result<AxInstrument, AxHttpError>
Sourcepub async fn authenticate(
&self,
api_key: &str,
api_secret: &str,
expiration_seconds: i32,
) -> Result<AxAuthenticateResponse, AxHttpError>
pub async fn authenticate( &self, api_key: &str, api_secret: &str, expiration_seconds: i32, ) -> Result<AxAuthenticateResponse, AxHttpError>
Sourcepub async fn authenticate_auto(
&self,
expiration_seconds: i32,
) -> Result<AxAuthenticateResponse, AxHttpError>
pub async fn authenticate_auto( &self, expiration_seconds: i32, ) -> Result<AxAuthenticateResponse, AxHttpError>
Authenticates using stored credentials or environment variables.
§Credential Resolution
Credentials are resolved in the following order:
- Stored credentials (from
with_credentialsconstructor) - Environment variables (
AX_API_KEYandAX_API_SECRET)
§Errors
Returns an error if:
- No credentials are available from either source
- The HTTP request fails
- The credentials are invalid
Sourcepub async fn place_order(
&self,
request: &PlaceOrderRequest,
) -> Result<AxPlaceOrderResponse, AxHttpError>
pub async fn place_order( &self, request: &PlaceOrderRequest, ) -> Result<AxPlaceOrderResponse, AxHttpError>
Sourcepub async fn cancel_order(
&self,
order_id: &str,
) -> Result<AxCancelOrderResponse, AxHttpError>
pub async fn cancel_order( &self, order_id: &str, ) -> Result<AxCancelOrderResponse, AxHttpError>
Sourcepub async fn cancel_all_orders(
&self,
request: &CancelAllOrdersRequest,
) -> Result<AxCancelAllOrdersResponse, AxHttpError>
pub async fn cancel_all_orders( &self, request: &CancelAllOrdersRequest, ) -> Result<AxCancelAllOrdersResponse, AxHttpError>
Sourcepub async fn batch_cancel_orders(
&self,
request: &BatchCancelOrdersRequest,
) -> Result<AxBatchCancelOrdersResponse, AxHttpError>
pub async fn batch_cancel_orders( &self, request: &BatchCancelOrdersRequest, ) -> Result<AxBatchCancelOrdersResponse, AxHttpError>
Sourcepub async fn get_open_orders(&self) -> Result<AxOpenOrdersResponse, AxHttpError>
pub async fn get_open_orders(&self) -> Result<AxOpenOrdersResponse, AxHttpError>
Sourcepub async fn get_fills(&self) -> Result<AxFillsResponse, AxHttpError>
pub async fn get_fills(&self) -> Result<AxFillsResponse, AxHttpError>
Sourcepub async fn get_candles(
&self,
symbol: Ustr,
start_timestamp_ns: i64,
end_timestamp_ns: i64,
candle_width: AxCandleWidth,
) -> Result<AxCandlesResponse, AxHttpError>
pub async fn get_candles( &self, symbol: Ustr, start_timestamp_ns: i64, end_timestamp_ns: i64, candle_width: AxCandleWidth, ) -> Result<AxCandlesResponse, AxHttpError>
Sourcepub async fn get_current_candle(
&self,
symbol: Ustr,
candle_width: AxCandleWidth,
) -> Result<AxCandle, AxHttpError>
pub async fn get_current_candle( &self, symbol: Ustr, candle_width: AxCandleWidth, ) -> Result<AxCandle, AxHttpError>
Sourcepub async fn get_last_candle(
&self,
symbol: Ustr,
candle_width: AxCandleWidth,
) -> Result<AxCandle, AxHttpError>
pub async fn get_last_candle( &self, symbol: Ustr, candle_width: AxCandleWidth, ) -> Result<AxCandle, AxHttpError>
Sourcepub async fn get_funding_rates(
&self,
symbol: Ustr,
start_timestamp_ns: i64,
end_timestamp_ns: i64,
) -> Result<AxFundingRatesResponse, AxHttpError>
pub async fn get_funding_rates( &self, symbol: Ustr, start_timestamp_ns: i64, end_timestamp_ns: i64, ) -> Result<AxFundingRatesResponse, AxHttpError>
Sourcepub async fn get_risk_snapshot(
&self,
) -> Result<AxRiskSnapshotResponse, AxHttpError>
pub async fn get_risk_snapshot( &self, ) -> Result<AxRiskSnapshotResponse, AxHttpError>
Sourcepub async fn preview_aggressive_limit_order(
&self,
request: &PreviewAggressiveLimitOrderRequest,
) -> Result<AxPreviewAggressiveLimitOrderResponse, AxHttpError>
pub async fn preview_aggressive_limit_order( &self, request: &PreviewAggressiveLimitOrderRequest, ) -> Result<AxPreviewAggressiveLimitOrderResponse, AxHttpError>
Previews an aggressive limit order to get the “take through” price.
This endpoint calculates the price needed to sweep the order book for a given quantity, which is used to simulate market orders on AX (which only supports limit orders natively).
§Endpoint
POST /preview-aggressive-limit-order
§Errors
Returns an error if the request fails or the response cannot be parsed.
Sourcepub async fn get_transactions(
&self,
transaction_types: Vec<String>,
) -> Result<AxTransactionsResponse, AxHttpError>
pub async fn get_transactions( &self, transaction_types: Vec<String>, ) -> Result<AxTransactionsResponse, AxHttpError>
Sourcepub async fn get_trades(
&self,
symbol: Ustr,
limit: Option<i32>,
) -> Result<AxTradesResponse, AxHttpError>
pub async fn get_trades( &self, symbol: Ustr, limit: Option<i32>, ) -> Result<AxTradesResponse, AxHttpError>
Sourcepub async fn get_book(
&self,
symbol: Ustr,
level: Option<i32>,
) -> Result<AxBookResponse, AxHttpError>
pub async fn get_book( &self, symbol: Ustr, level: Option<i32>, ) -> Result<AxBookResponse, AxHttpError>
Sourcepub async fn get_order_status_by_id(
&self,
order_id: &str,
) -> Result<AxOrderStatusQueryResponse, AxHttpError>
pub async fn get_order_status_by_id( &self, order_id: &str, ) -> Result<AxOrderStatusQueryResponse, AxHttpError>
Sourcepub async fn get_order_status_by_cid(
&self,
client_order_id: u64,
) -> Result<AxOrderStatusQueryResponse, AxHttpError>
pub async fn get_order_status_by_cid( &self, client_order_id: u64, ) -> Result<AxOrderStatusQueryResponse, AxHttpError>
Sourcepub async fn get_orders(
&self,
params: &GetOrdersParams,
) -> Result<AxOrdersResponse, AxHttpError>
pub async fn get_orders( &self, params: &GetOrdersParams, ) -> Result<AxOrdersResponse, AxHttpError>
Sourcepub async fn check_initial_margin(
&self,
request: &PlaceOrderRequest,
) -> Result<AxInitialMarginRequirementResponse, AxHttpError>
pub async fn check_initial_margin( &self, request: &PlaceOrderRequest, ) -> Result<AxInitialMarginRequirementResponse, AxHttpError>
Trait Implementations§
Source§impl Debug for AxRawHttpClient
impl Debug for AxRawHttpClient
Auto Trait Implementations§
impl !Freeze for AxRawHttpClient
impl !RefUnwindSafe for AxRawHttpClient
impl Send for AxRawHttpClient
impl Sync for AxRawHttpClient
impl Unpin for AxRawHttpClient
impl UnsafeUnpin for AxRawHttpClient
impl !UnwindSafe for AxRawHttpClient
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
§impl<T> Instrument for T
impl<T> Instrument for T
§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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