pub struct PolymarketGammaHttpClient { /* private fields */ }Expand description
Provides a domain HTTP client for Polymarket instrument fetching.
Wraps PolymarketGammaRawHttpClient with instrument parsing: fetch from
the Gamma API and parse into Nautilus types. Stateless with respect to
instrument storage; caching is handled by the instrument provider.
Implementations§
Source§impl PolymarketGammaHttpClient
impl PolymarketGammaHttpClient
Sourcepub fn new(
gamma_base_url: Option<String>,
timeout_secs: u64,
retry_config: RetryConfig,
) -> StdResult<Self, HttpClientError>
pub fn new( gamma_base_url: Option<String>, timeout_secs: u64, retry_config: RetryConfig, ) -> StdResult<Self, HttpClientError>
Creates a new PolymarketGammaHttpClient.
§Errors
Returns an error if the underlying HTTP client cannot be created.
Sourcepub async fn request_instruments(&self) -> Result<Vec<InstrumentAny>>
pub async fn request_instruments(&self) -> Result<Vec<InstrumentAny>>
Fetches instruments from the Gamma API and returns Nautilus domain types.
§Errors
Returns an error if the HTTP request or parsing fails.
Sourcepub async fn request_instruments_by_slugs(
&self,
slugs: Vec<String>,
) -> Result<Vec<InstrumentAny>>
pub async fn request_instruments_by_slugs( &self, slugs: Vec<String>, ) -> Result<Vec<InstrumentAny>>
Fetches instruments for the given slugs concurrently.
Each slug is queried individually via the Gamma API. Missing or unparsable slugs are logged and skipped.
§Errors
Returns an error if all slug requests fail. Individual slug failures are warned and skipped when at least one slug succeeds.
Sourcepub async fn request_instruments_by_slugs_with_retry(
&self,
slugs: Vec<String>,
) -> Result<Vec<InstrumentAny>>
pub async fn request_instruments_by_slugs_with_retry( &self, slugs: Vec<String>, ) -> Result<Vec<InstrumentAny>>
Fetches instruments for the given slugs with retry on empty results.
Uses the client’s [RetryManager] with exponential backoff. Gamma API
may not have indexed a newly created market yet, so empty results are
treated as retryable (indexing lag). HTTP errors are also retried per
the standard is_retryable() classification.
Sourcepub async fn request_instruments_by_event_slugs(
&self,
event_slugs: Vec<String>,
) -> Result<Vec<InstrumentAny>>
pub async fn request_instruments_by_event_slugs( &self, event_slugs: Vec<String>, ) -> Result<Vec<InstrumentAny>>
Fetches instruments from event slugs concurrently.
Each slug queries GET /events?slug=, extracts the markets array from
the first matching event, and parses each market into instruments.
Sourcepub async fn request_instruments_by_params(
&self,
base_params: GetGammaMarketsParams,
) -> Result<Vec<InstrumentAny>>
pub async fn request_instruments_by_params( &self, base_params: GetGammaMarketsParams, ) -> Result<Vec<InstrumentAny>>
Fetches instruments using arbitrary Gamma API query params with auto-pagination.
Sourcepub async fn request_instruments_by_event_query(
&self,
event_slug: &str,
params: GetGammaMarketsParams,
) -> Result<Vec<InstrumentAny>>
pub async fn request_instruments_by_event_query( &self, event_slug: &str, params: GetGammaMarketsParams, ) -> Result<Vec<InstrumentAny>>
Fetches instruments from an event slug with client-side sorting and limiting.
The /events?slug= response already includes the full markets array,
so no second API call is needed. Sorting and truncation are applied
client-side using fields from GetGammaMarketsParams:
order: sort field ("liquidity","volume","volume24hr")ascending: sort direction (default: descending)max_markets: truncate after sorting
Sourcepub async fn request_instruments_by_event_params(
&self,
params: GetGammaEventsParams,
) -> Result<Vec<InstrumentAny>>
pub async fn request_instruments_by_event_params( &self, params: GetGammaEventsParams, ) -> Result<Vec<InstrumentAny>>
Fetches instruments from events matching full query params (paginated).
Sourcepub async fn request_instruments_by_search(
&self,
params: GetSearchParams,
) -> Result<Vec<InstrumentAny>>
pub async fn request_instruments_by_search( &self, params: GetSearchParams, ) -> Result<Vec<InstrumentAny>>
Searches for instruments via the Gamma public search endpoint.
Fetches available tags from the Gamma API.
Sourcepub fn inner(&self) -> &Arc<PolymarketGammaRawHttpClient> ⓘ
pub fn inner(&self) -> &Arc<PolymarketGammaRawHttpClient> ⓘ
Returns a reference to the underlying raw HTTP client.
Trait Implementations§
Source§impl Clone for PolymarketGammaHttpClient
impl Clone for PolymarketGammaHttpClient
Source§fn clone(&self) -> PolymarketGammaHttpClient
fn clone(&self) -> PolymarketGammaHttpClient
1.0.0 · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreAuto Trait Implementations§
impl Freeze for PolymarketGammaHttpClient
impl !RefUnwindSafe for PolymarketGammaHttpClient
impl Send for PolymarketGammaHttpClient
impl Sync for PolymarketGammaHttpClient
impl Unpin for PolymarketGammaHttpClient
impl UnsafeUnpin for PolymarketGammaHttpClient
impl !UnwindSafe for PolymarketGammaHttpClient
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