Skip to main content

px_core/models/
series.rs

1use chrono::{DateTime, Utc};
2use serde::{Deserialize, Serialize};
3
4/// A recurring family of events (e.g. a weekly inflation reading or sports season).
5#[derive(Debug, Clone, Serialize, Deserialize)]
6#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
7pub struct Series {
8    /// Native series identifier — Kalshi series ticker or Polymarket series ticker/slug (e.g. `"KXPRES"`).
9    pub ticker: String,
10    /// Polymarket numeric series id (e.g. `"10345"`); `null` on Kalshi.
11    #[serde(default, skip_serializing_if = "Option::is_none")]
12    pub numeric_id: Option<String>,
13    /// Human-readable series title (e.g. `"US Presidential Election"`).
14    pub title: String,
15    /// Topical category (e.g. `"Politics"`); `null` when upstream omits it.
16    #[serde(default, skip_serializing_if = "Option::is_none")]
17    pub category: Option<String>,
18    /// Cadence string (e.g. `"weekly"`); `null` when upstream omits it.
19    #[serde(default, skip_serializing_if = "Option::is_none")]
20    pub frequency: Option<String>,
21    /// Free-form tags (e.g. `["macro", "fed"]`).
22    #[serde(default)]
23    pub tags: Vec<String>,
24    /// Resolution sources used by the exchange (e.g. `[{"name": "BLS", "url": "..."}]`).
25    #[serde(default)]
26    pub settlement_sources: Vec<SettlementSource>,
27    /// Fee schedule label (e.g. `"flat"`); `null` when upstream omits it.
28    #[serde(default, skip_serializing_if = "Option::is_none")]
29    pub fee_type: Option<String>,
30    /// Lifetime trading volume in USD across the series (e.g. `123456.78`).
31    #[serde(default, skip_serializing_if = "Option::is_none")]
32    pub volume: Option<f64>,
33    /// Last upstream update time in UTC.
34    #[serde(default, skip_serializing_if = "Option::is_none")]
35    pub last_updated_ts: Option<DateTime<Utc>>,
36}
37
38/// Reference used by the exchange to settle a series.
39#[derive(Debug, Clone, Serialize, Deserialize)]
40#[cfg_attr(feature = "schema", derive(schemars::JsonSchema))]
41pub struct SettlementSource {
42    /// Display name of the source (e.g. `"Bureau of Labor Statistics"`).
43    #[serde(default, skip_serializing_if = "Option::is_none")]
44    pub name: Option<String>,
45    /// Source URL (e.g. `"https://www.bls.gov/cpi/"`).
46    #[serde(default, skip_serializing_if = "Option::is_none")]
47    pub url: Option<String>,
48}