pub struct AxHttpClient { /* private fields */ }Expand description
High-level HTTP client for the Ax REST API.
This client wraps the underlying AxRawHttpClient to provide a convenient
interface for Python bindings and instrument caching.
Implementations§
Source§impl AxHttpClient
impl AxHttpClient
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 AxHttpClient 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 AxHttpClient configured with credentials.
§Errors
Returns an error if the HTTP client cannot be created.
Sourcepub fn cancel_all_requests(&self)
pub fn cancel_all_requests(&self)
Cancel all pending HTTP requests.
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.
Sourcepub fn is_initialized(&self) -> bool
pub fn is_initialized(&self) -> bool
Checks if the client is initialized.
The client is considered initialized if any instruments have been cached from the venue.
Sourcepub fn get_cached_symbols(&self) -> Vec<String>
pub fn get_cached_symbols(&self) -> Vec<String>
Returns a snapshot of all instrument symbols currently held in the internal cache.
Sourcepub fn cache_instruments(&self, instruments: Vec<InstrumentAny>)
pub fn cache_instruments(&self, instruments: Vec<InstrumentAny>)
Caches multiple instruments.
Any existing instruments with the same symbols will be replaced.
Sourcepub fn cache_instrument(&self, instrument: InstrumentAny)
pub fn cache_instrument(&self, instrument: InstrumentAny)
Caches a single instrument.
Any existing instrument with the same symbol will be replaced.
Sourcepub async fn authenticate(
&self,
api_key: &str,
api_secret: &str,
expiration_seconds: i32,
) -> Result<String, AxHttpError>
pub async fn authenticate( &self, api_key: &str, api_secret: &str, expiration_seconds: i32, ) -> Result<String, AxHttpError>
Authenticates with Ax using API credentials.
On success, the session token is automatically stored for subsequent authenticated requests.
§Errors
Returns an error if the HTTP request fails or credentials are invalid.
Sourcepub async fn authenticate_with_totp(
&self,
api_key: &str,
api_secret: &str,
expiration_seconds: i32,
totp_code: Option<&str>,
) -> Result<String, AxHttpError>
pub async fn authenticate_with_totp( &self, api_key: &str, api_secret: &str, expiration_seconds: i32, totp_code: Option<&str>, ) -> Result<String, AxHttpError>
Authenticates with Ax using API credentials and TOTP.
On success, the session token is automatically stored for subsequent authenticated requests.
§Errors
Returns an error if the HTTP request fails or credentials are invalid.
Sourcepub fn get_instrument(&self, symbol: &Ustr) -> Option<InstrumentAny>
pub fn get_instrument(&self, symbol: &Ustr) -> Option<InstrumentAny>
Gets an instrument from the cache by symbol.
Sourcepub async fn request_instruments(
&self,
maker_fee: Option<Decimal>,
taker_fee: Option<Decimal>,
) -> Result<Vec<InstrumentAny>>
pub async fn request_instruments( &self, maker_fee: Option<Decimal>, taker_fee: Option<Decimal>, ) -> Result<Vec<InstrumentAny>>
Requests all instruments from Ax.
§Errors
Returns an error if the HTTP request fails or instrument parsing fails.
Sourcepub async fn request_instrument(
&self,
symbol: &str,
maker_fee: Option<Decimal>,
taker_fee: Option<Decimal>,
) -> Result<InstrumentAny>
pub async fn request_instrument( &self, symbol: &str, maker_fee: Option<Decimal>, taker_fee: Option<Decimal>, ) -> Result<InstrumentAny>
Requests a single instrument from Ax by symbol.
§Errors
Returns an error if the HTTP request fails or instrument parsing fails.
Sourcepub async fn request_account_state(
&self,
account_id: AccountId,
) -> Result<AccountState>
pub async fn request_account_state( &self, account_id: AccountId, ) -> Result<AccountState>
Requests account state from Ax and parses to a Nautilus [AccountState].
§Errors
Returns an error if the HTTP request fails or parsing fails.
Sourcepub async fn request_funding_rates(
&self,
symbol: &str,
start_timestamp_ns: i64,
end_timestamp_ns: i64,
) -> Result<AxFundingRatesResponse, AxHttpError>
pub async fn request_funding_rates( &self, symbol: &str, start_timestamp_ns: i64, end_timestamp_ns: i64, ) -> Result<AxFundingRatesResponse, AxHttpError>
Sourcepub async fn request_bars(
&self,
symbol: &str,
start_timestamp_ns: i64,
end_timestamp_ns: i64,
width: AxCandleWidth,
) -> Result<Vec<Bar>>
pub async fn request_bars( &self, symbol: &str, start_timestamp_ns: i64, end_timestamp_ns: i64, width: AxCandleWidth, ) -> Result<Vec<Bar>>
Requests historical bars from Ax and parses them to Nautilus Bar types.
Requires the instrument to be cached (call request_instruments first).
§Errors
Returns an error if:
- The instrument is not found in the cache.
- The HTTP request fails.
- Bar parsing fails.
Sourcepub async fn request_order_status_reports(
&self,
account_id: AccountId,
) -> Result<Vec<OrderStatusReport>>
pub async fn request_order_status_reports( &self, account_id: AccountId, ) -> Result<Vec<OrderStatusReport>>
Requests open orders from Ax and parses them to Nautilus [OrderStatusReport].
Requires instruments to be cached for parsing order details.
§Errors
Returns an error if:
- The HTTP request fails.
- An order’s instrument is not found in the cache.
- Order parsing fails.
Sourcepub async fn request_fill_reports(
&self,
account_id: AccountId,
) -> Result<Vec<FillReport>>
pub async fn request_fill_reports( &self, account_id: AccountId, ) -> Result<Vec<FillReport>>
Requests fills from Ax and parses them to Nautilus [FillReport].
Requires instruments to be cached for parsing fill details.
§Errors
Returns an error if:
- The HTTP request fails.
- A fill’s instrument is not found in the cache.
- Fill parsing fails.
Sourcepub async fn request_position_reports(
&self,
account_id: AccountId,
) -> Result<Vec<PositionStatusReport>>
pub async fn request_position_reports( &self, account_id: AccountId, ) -> Result<Vec<PositionStatusReport>>
Requests positions from Ax and parses them to Nautilus [PositionStatusReport].
Requires instruments to be cached for parsing position details.
§Errors
Returns an error if:
- The HTTP request fails.
- A position’s instrument is not found in the cache.
- Position parsing fails.
Source§impl AxHttpClient
impl AxHttpClient
pub fn py_base_url(&self) -> &str
pub fn py_cancel_all_requests(&self)
Trait Implementations§
Source§impl Clone for AxHttpClient
impl Clone for AxHttpClient
Source§impl Debug for AxHttpClient
impl Debug for AxHttpClient
Source§impl Default for AxHttpClient
impl Default for AxHttpClient
Source§impl<'py> IntoPyObject<'py> for AxHttpClient
impl<'py> IntoPyObject<'py> for AxHttpClient
Source§type Target = AxHttpClient
type Target = AxHttpClient
Source§type Output = Bound<'py, <AxHttpClient as IntoPyObject<'py>>::Target>
type Output = Bound<'py, <AxHttpClient as IntoPyObject<'py>>::Target>
Source§fn into_pyobject(
self,
py: Python<'py>,
) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
fn into_pyobject( self, py: Python<'py>, ) -> Result<<Self as IntoPyObject<'_>>::Output, <Self as IntoPyObject<'_>>::Error>
Source§impl PyClass for AxHttpClient
impl PyClass for AxHttpClient
Source§impl PyClassImpl for AxHttpClient
impl PyClassImpl for AxHttpClient
Source§const IS_BASETYPE: bool = false
const IS_BASETYPE: bool = false
Source§const IS_SUBCLASS: bool = false
const IS_SUBCLASS: bool = false
Source§const IS_MAPPING: bool = false
const IS_MAPPING: bool = false
Source§const IS_SEQUENCE: bool = false
const IS_SEQUENCE: bool = false
Source§const IS_IMMUTABLE_TYPE: bool = false
const IS_IMMUTABLE_TYPE: bool = false
Source§const RAW_DOC: &'static CStr = /// High-level HTTP client for the Ax REST API.
///
/// This client wraps the underlying [`AxRawHttpClient`] to provide a convenient
/// interface for Python bindings and instrument caching.
const RAW_DOC: &'static CStr = /// High-level HTTP client for the Ax REST API. /// /// This client wraps the underlying [`AxRawHttpClient`] to provide a convenient /// interface for Python bindings and instrument caching.
Source§const DOC: &'static CStr
const DOC: &'static CStr
text_signature if a constructor is defined. Read moreSource§type ThreadChecker = SendablePyClass<AxHttpClient>
type ThreadChecker = SendablePyClass<AxHttpClient>
Source§type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
type PyClassMutability = <<PyAny as PyClassBaseType>::PyClassMutability as PyClassMutability>::MutableChild
Source§type BaseNativeType = PyAny
type BaseNativeType = PyAny
PyAny by default, and when you declare
#[pyclass(extends=PyDict)], it’s PyDict.fn items_iter() -> PyClassItemsIter
fn lazy_type_object() -> &'static LazyTypeObject<Self>
fn dict_offset() -> Option<isize>
fn weaklist_offset() -> Option<isize>
Source§impl PyClassNewTextSignature for AxHttpClient
impl PyClassNewTextSignature for AxHttpClient
const TEXT_SIGNATURE: &'static str = "(base_url=None, orders_base_url=None, timeout_secs=None, max_retries=None, retry_delay_ms=None, retry_delay_max_ms=None, proxy_url=None)"
Source§impl PyMethods<AxHttpClient> for PyClassImplCollector<AxHttpClient>
impl PyMethods<AxHttpClient> for PyClassImplCollector<AxHttpClient>
fn py_methods(self) -> &'static PyClassItems
Source§impl PyTypeInfo for AxHttpClient
impl PyTypeInfo for AxHttpClient
Source§fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
fn type_object_raw(py: Python<'_>) -> *mut PyTypeObject
§fn type_object(py: Python<'_>) -> Bound<'_, PyType>
fn type_object(py: Python<'_>) -> Bound<'_, PyType>
§fn is_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type or a subclass of this type.§fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
fn is_exact_type_of(object: &Bound<'_, PyAny>) -> bool
object is an instance of this type.impl DerefToPyAny for AxHttpClient
impl ExtractPyClassWithClone for AxHttpClient
Auto Trait Implementations§
impl !Freeze for AxHttpClient
impl !RefUnwindSafe for AxHttpClient
impl Send for AxHttpClient
impl Sync for AxHttpClient
impl Unpin for AxHttpClient
impl !UnwindSafe for AxHttpClient
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
§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§impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
impl<'py, T> IntoPyObjectExt<'py> for Twhere
T: IntoPyObject<'py>,
§fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
fn into_bound_py_any(self, py: Python<'py>) -> Result<Bound<'py, PyAny>, PyErr>
self into an owned Python object, dropping type information.§fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
fn into_py_any(self, py: Python<'py>) -> Result<Py<PyAny>, PyErr>
self into an owned Python object, dropping type information and unbinding it
from the 'py lifetime.§fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
fn into_pyobject_or_pyerr(self, py: Python<'py>) -> Result<Self::Output, PyErr>
self into a Python object. Read more§impl<'py, T> IntoPyObjectNautilusExt<'py> for Twhere
T: IntoPyObjectExt<'py>,
impl<'py, T> IntoPyObjectNautilusExt<'py> for Twhere
T: IntoPyObjectExt<'py>,
§fn into_py_any_unwrap(self, py: Python<'py>) -> Py<PyAny>
fn into_py_any_unwrap(self, py: Python<'py>) -> Py<PyAny>
§impl<T> PolicyExt for Twhere
T: ?Sized,
impl<T> PolicyExt for Twhere
T: ?Sized,
§impl<T> PyErrArguments for T
impl<T> PyErrArguments for T
§impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
impl<T> PyTypeCheck for Twhere
T: PyTypeInfo,
§const NAME: &'static str = T::NAME
const NAME: &'static str = T::NAME
§fn type_check(object: &Bound<'_, PyAny>) -> bool
fn type_check(object: &Bound<'_, PyAny>) -> bool
§fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
fn classinfo_object(py: Python<'_>) -> Bound<'_, PyAny>
isinstance and issubclass function. Read more