Skip to main content

Market

Struct Market 

Source
pub struct Market {
Show 54 fields pub openpx_id: String, pub exchange: String, pub id: String, pub group_id: Option<String>, pub event_id: Option<String>, pub title: String, pub question: Option<String>, pub description: String, pub slug: Option<String>, pub rules: Option<String>, pub status: MarketStatus, pub market_type: MarketType, pub accepting_orders: bool, pub outcomes: Vec<String>, pub outcome_tokens: Vec<OutcomeToken>, pub outcome_prices: HashMap<String, f64>, pub token_id_yes: Option<String>, pub token_id_no: Option<String>, pub condition_id: Option<String>, pub question_id: Option<String>, pub volume: f64, pub volume_24h: Option<f64>, pub volume_1wk: Option<f64>, pub volume_1mo: Option<f64>, pub liquidity: Option<f64>, pub open_interest: Option<f64>, pub last_trade_price: Option<f64>, pub best_bid: Option<f64>, pub best_ask: Option<f64>, pub spread: Option<f64>, pub price_change_1d: Option<f64>, pub price_change_1h: Option<f64>, pub price_change_1wk: Option<f64>, pub price_change_1mo: Option<f64>, pub tick_size: Option<f64>, pub min_order_size: Option<f64>, pub close_time: Option<DateTime<Utc>>, pub open_time: Option<DateTime<Utc>>, pub created_at: Option<DateTime<Utc>>, pub settlement_time: Option<DateTime<Utc>>, pub image_url: Option<String>, pub icon_url: Option<String>, pub neg_risk: Option<bool>, pub neg_risk_market_id: Option<String>, pub maker_fee_bps: Option<f64>, pub taker_fee_bps: Option<f64>, pub denomination_token: Option<String>, pub chain_id: Option<String>, pub notional_value: Option<f64>, pub price_level_structure: Option<String>, pub settlement_value: Option<f64>, pub previous_price: Option<f64>, pub can_close_early: Option<bool>, pub result: Option<String>,
}
Expand description

Unified prediction market model.

All exchanges produce this single type directly — no intermediate conversion.

§Price Format

All prices are normalized to decimal format (0.0 to 1.0). Exchange-specific conversions are handled during parsing:

  • Kalshi: Fixed-point dollar strings parsed directly (post March 2026 migration).
  • Polymarket, Opinion: Native prices already in decimal (0.0-1.0).

Fields§

§openpx_id: String

Primary key: {exchange}:{native_id}

§exchange: String

Exchange identifier (kalshi, polymarket, opinion)

§id: String

Native exchange market ID

§group_id: Option<String>

Source-native event/group ID from the exchange.

§event_id: Option<String>

Canonical OpenPX event ID for cross-exchange event grouping.

§title: String

Market title

§question: Option<String>

Market question (may differ from title)

§description: String

Full description

§slug: Option<String>

URL-friendly identifier

§rules: Option<String>

Resolution rules

§status: MarketStatus

Normalized status: Active, Closed, Resolved

§market_type: MarketType

Market type classification

§accepting_orders: bool

Whether the market is currently accepting orders

§outcomes: Vec<String>

Outcome labels (e.g., [“Yes”, “No”] for binary markets)

§outcome_tokens: Vec<OutcomeToken>

Outcome-to-token mapping for orderbook subscriptions

§outcome_prices: HashMap<String, f64>

Outcome prices from the REST API (e.g., {“Yes”: 0.65, “No”: 0.35})

§token_id_yes: Option<String>

Yes outcome token ID

§token_id_no: Option<String>

No outcome token ID

§condition_id: Option<String>

Condition ID for CTF

§question_id: Option<String>

Question ID (Opinion, Polymarket)

§volume: f64

Total volume (USD)

§volume_24h: Option<f64>

24-hour trading volume (USD)

§volume_1wk: Option<f64>

7-day rolling trading volume (USD)

§volume_1mo: Option<f64>

30-day rolling trading volume (USD)

§liquidity: Option<f64>

Current liquidity

§open_interest: Option<f64>

Current open interest

§last_trade_price: Option<f64>

Last trade price (normalized 0-1)

§best_bid: Option<f64>

Best bid price (normalized 0-1)

§best_ask: Option<f64>

Best ask price (normalized 0-1)

§spread: Option<f64>

Bid-ask spread (decimal)

§price_change_1d: Option<f64>

24-hour YES price change (decimal, e.g. 0.05 = +5%)

§price_change_1h: Option<f64>

1-hour YES price change

§price_change_1wk: Option<f64>

7-day YES price change

§price_change_1mo: Option<f64>

30-day YES price change

§tick_size: Option<f64>

Tick size (minimum price increment, normalized decimal e.g. 0.01)

§min_order_size: Option<f64>

Minimum order size (contracts)

§close_time: Option<DateTime<Utc>>

Market close time

§open_time: Option<DateTime<Utc>>

Market open time

§created_at: Option<DateTime<Utc>>

Market creation time

§settlement_time: Option<DateTime<Utc>>

Settlement / resolution time

§image_url: Option<String>

Market image URL

§icon_url: Option<String>

Market icon URL

§neg_risk: Option<bool>

Polymarket: neg-risk flag

§neg_risk_market_id: Option<String>

Polymarket: neg-risk market ID

§maker_fee_bps: Option<f64>

Maker fee rate (basis points)

§taker_fee_bps: Option<f64>

Taker fee rate (basis points)

§denomination_token: Option<String>

Denomination token (e.g. USDC address)

§chain_id: Option<String>

Chain ID for on-chain markets

§notional_value: Option<f64>

Notional value per contract (Kalshi)

§price_level_structure: Option<String>

Kalshi sub-penny pricing structure

§settlement_value: Option<f64>

Kalshi: settlement value

§previous_price: Option<f64>

Kalshi: previous price

§can_close_early: Option<bool>

Kalshi: can close early

§result: Option<String>

Resolution result

Implementations§

Source§

impl Market

Source

pub fn make_openpx_id(exchange: &str, id: &str) -> String

Create openpx_id from exchange and native id

Source

pub fn parse_openpx_id(openpx_id: &str) -> Option<(&str, &str)>

Parse openpx_id into (exchange, native_id)

Check if market matches search query (case-insensitive)

Source

pub fn is_binary(&self) -> bool

Source

pub fn is_open(&self) -> bool

Source

pub fn computed_spread(&self) -> Option<f64>

Compute bid-ask spread from outcome prices for binary markets.

Source

pub fn get_token_ids(&self) -> Vec<String>

Source

pub fn get_outcome_tokens(&self) -> Vec<OutcomeToken>

Trait Implementations§

Source§

impl Clone for Market

Source§

fn clone(&self) -> Market

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 Market

Source§

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

Formats the value using the given formatter. Read more
Source§

impl Default for Market

Source§

fn default() -> Self

Returns the “default value” for a type. Read more
Source§

impl<'de> Deserialize<'de> for Market

Source§

fn deserialize<__D>(__deserializer: __D) -> Result<Self, __D::Error>
where __D: Deserializer<'de>,

Deserialize this value from the given Serde deserializer. Read more
Source§

impl Serialize for Market

Source§

fn serialize<__S>(&self, __serializer: __S) -> Result<__S::Ok, __S::Error>
where __S: Serializer,

Serialize this value into the given Serde serializer. 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.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

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> 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.
Source§

impl<T> WithSubscriber for T

Source§

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
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

impl<T> DeserializeOwned for T
where T: for<'de> Deserialize<'de>,