Skip to main content

px_core/models/
event.rs

1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3
4/// A grouping of related markets — one Kalshi event_ticker or one Polymarket event slug.
5#[derive(Debug, Clone, Serialize, Deserialize)]
6#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
7pub struct Event {
8    /// Native event identifier — Kalshi event ticker or Polymarket event slug (e.g. `"KXPRES-2028"`).
9    pub ticker: String,
10    /// Polymarket numeric event id (e.g. `"12585"`); `null` on Kalshi.
11    #[serde(default, skip_serializing_if = "Option::is_none")]
12    pub numeric_id: Option<String>,
13    /// Human-readable event title (e.g. `"2028 US Presidential Election"`).
14    pub title: String,
15    /// Long-form event description; `null` when upstream omits it.
16    #[serde(default, skip_serializing_if = "Option::is_none")]
17    pub description: Option<String>,
18    /// Topical category (e.g. `"Politics"`); `null` when upstream omits it.
19    #[serde(default, skip_serializing_if = "Option::is_none")]
20    pub category: Option<String>,
21    /// Parent series ticker (e.g. `"KXPRES"`); `null` when the event has no parent series.
22    #[serde(default, skip_serializing_if = "Option::is_none")]
23    pub series_ticker: Option<String>,
24    /// Upstream lifecycle string (e.g. `"open"`); `null` when upstream omits it.
25    #[serde(default, skip_serializing_if = "Option::is_none")]
26    pub status: Option<String>,
27    /// Tickers of markets under this event (e.g. `["KXBTCD-25APR1517"]`).
28    #[serde(default)]
29    pub market_tickers: Vec<String>,
30    /// Event start time in UTC.
31    #[serde(default, skip_serializing_if = "Option::is_none")]
32    pub start_ts: Option<DateTime<Utc>>,
33    /// Event end time in UTC.
34    #[serde(default, skip_serializing_if = "Option::is_none")]
35    pub end_ts: Option<DateTime<Utc>>,
36    /// Lifetime trading volume in USD (e.g. `12345.67`).
37    #[serde(default, skip_serializing_if = "Option::is_none")]
38    pub volume: Option<f64>,
39    /// Open interest in USD (e.g. `5000.0`).
40    #[serde(default, skip_serializing_if = "Option::is_none")]
41    pub open_interest: Option<f64>,
42    /// `true` if exactly one child market resolves YES.
43    #[serde(default, skip_serializing_if = "Option::is_none")]
44    pub mutually_exclusive: Option<bool>,
45    /// Last upstream update time in UTC.
46    #[serde(default, skip_serializing_if = "Option::is_none")]
47    pub last_updated_ts: Option<DateTime<Utc>>,
48}