Skip to main content

PolymarketGammaHttpClient

Struct PolymarketGammaHttpClient 

Source
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

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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.

Source

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
Source

pub async fn request_instruments_by_event_params( &self, params: GetGammaEventsParams, ) -> Result<Vec<InstrumentAny>>

Fetches instruments from events matching full query params (paginated).

Searches for instruments via the Gamma public search endpoint.

Source

pub async fn request_tags(&self) -> Result<Vec<GammaTag>>

Fetches available tags from the Gamma API.

Source

pub fn inner(&self) -> &Arc<PolymarketGammaRawHttpClient>

Returns a reference to the underlying raw HTTP client.

Trait Implementations§

Source§

impl Clone for PolymarketGammaHttpClient

Source§

fn clone(&self) -> PolymarketGammaHttpClient

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PolymarketGammaHttpClient

Source§

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

Formats the value using the given formatter. 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> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. 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> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
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,