Skip to main content
async fn fetch_price_history(
    req: PriceHistoryRequest,
) -> Result<Vec<Candlestick>, OpenPxError>

Parameters

market_id
string
required
Native market ID.
outcome
string?
Outcome label. Kalshi infers Yes/No from the market.
token_id
string?
Polymarket CLOB token.
condition_id
string?
Polymarket condition ID for OI enrichment.
interval
PriceHistoryInterval
required
1m, 1h, 6h, 1d, 1w, or max.
start_ts
i64?
Unix seconds.
end_ts
i64?
Unix seconds.

Returns

Candlestick[].
timestamp
DateTime<Utc>
open
f64
high
f64
low
f64
close
f64
volume
f64
open_interest
f64?
Kalshi only.

Example

use openpx::{PriceHistoryRequest, PriceHistoryInterval};

let candles = ex.fetch_price_history(PriceHistoryRequest {
    market_id: "KXBTC-25MAR14-T20000".into(),
    interval: PriceHistoryInterval::Hour,
    ..Default::default()
}).await?;