diff --git a/polyte-clob/src/api/markets.rs b/polyte-clob/src/api/markets.rs index 9072d66..d0146ac 100644 --- a/polyte-clob/src/api/markets.rs +++ b/polyte-clob/src/api/markets.rs @@ -75,6 +75,18 @@ impl Markets { ) .query("token_id", token_id.into()) } + + /// Get historical prices for a token + pub fn prices_history(&self, token_id: impl Into) -> Request { + Request::get( + self.client.clone(), + self.base_url.clone(), + "/prices-history", + AuthMode::None, + self.chain_id, + ) + .query("market", token_id.into()) + } } /// Market information @@ -143,3 +155,20 @@ pub struct PriceResponse { pub struct MidpointResponse { pub mid: String, } + +/// A single point in the price history timeseries +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct PriceHistoryPoint { + /// Unix timestamp (seconds) + #[serde(rename = "t")] + pub timestamp: i64, + /// Price at this point in time + #[serde(rename = "p")] + pub price: f64, +} + +/// Response from the prices-history endpoint +#[derive(Debug, Clone, Serialize, Deserialize)] +pub struct PricesHistoryResponse { + pub history: Vec, +}