diff --git a/README.md b/README.md index a765ad8..afbc7d0 100644 --- a/README.md +++ b/README.md @@ -362,16 +362,4 @@ The library enforces price tick alignment automatically. If someone sends you a *The tick alignment code includes detailed comments about why this matters for market integrity and how the integer math makes validation nearly free.* ### Memory Management -Order books can grow huge if you're not careful. The library automatically trims them to keep only the relevant price levels, and you can clean up stale books that haven't updated recently. - -## Contributing - -Found a bug? Have a performance improvement? PRs welcome! - -The codebase is designed to be educational as well as functional. Every optimization includes: -- Commented-out "before" code showing the slower approach -- Detailed explanations of why the optimization works -- Performance measurements and memory usage analysis -- References to trading concepts and market microstructure theory - -If you're curious about high-frequency trading or high performance Rust, start with `src/book.rs` - it's like a textbook on order book performance engineering. \ No newline at end of file +Order books can grow huge if you're not careful. The library automatically trims them to keep only the relevant price levels, and you can clean up stale books that haven't updated recently. \ No newline at end of file diff --git a/src/types.rs b/src/types.rs index a522c37..5afd89e 100644 --- a/src/types.rs +++ b/src/types.rs @@ -904,5 +904,128 @@ pub struct BatchPriceResponse { pub prices: Vec, } +// Additional types for API compatibility with reference implementation +#[derive(Debug, Deserialize)] +pub struct ApiKeysResponse { + #[serde(rename = "apiKeys")] + pub api_keys: Vec, +} + +#[derive(Debug, Deserialize)] +pub struct MidpointResponse { + #[serde(with = "rust_decimal::serde::str")] + pub mid: Decimal, +} + +#[derive(Debug, Deserialize)] +pub struct PriceResponse { + #[serde(with = "rust_decimal::serde::str")] + pub price: Decimal, +} + +#[derive(Debug, Deserialize)] +pub struct SpreadResponse { + #[serde(with = "rust_decimal::serde::str")] + pub spread: Decimal, +} + +#[derive(Debug, Deserialize)] +pub struct TickSizeResponse { + #[serde(with = "rust_decimal::serde::str")] + pub minimum_tick_size: Decimal, +} + +#[derive(Debug, Deserialize)] +pub struct NegRiskResponse { + pub neg_risk: bool, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct BookParams { + pub token_id: String, + pub side: Side, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct MarketsResponse { + #[serde(with = "rust_decimal::serde::str")] + pub limit: Decimal, + #[serde(with = "rust_decimal::serde::str")] + pub count: Decimal, + pub next_cursor: Option, + pub data: Vec, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct SimplifiedMarketsResponse { + #[serde(with = "rust_decimal::serde::str")] + pub limit: Decimal, + #[serde(with = "rust_decimal::serde::str")] + pub count: Decimal, + pub next_cursor: Option, + pub data: Vec, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Market { + pub condition_id: String, + pub tokens: [Token; 2], + pub rewards: Rewards, + pub min_incentive_size: Option, + pub max_incentive_spread: Option, + pub active: bool, + pub closed: bool, + pub question_id: String, + #[serde(with = "rust_decimal::serde::str")] + pub minimum_order_size: Decimal, + #[serde(with = "rust_decimal::serde::str")] + pub minimum_tick_size: Decimal, + pub description: String, + pub category: Option, + pub end_date_iso: Option, + pub game_start_time: Option, + pub question: String, + pub market_slug: String, + #[serde(with = "rust_decimal::serde::str")] + pub seconds_delay: Decimal, + pub icon: String, + pub fpmm: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct SimplifiedMarket { + pub condition_id: String, + pub tokens: [Token; 2], + pub rewards: Rewards, + pub min_incentive_size: Option, + pub max_incentive_spread: Option, + pub active: bool, + pub closed: bool, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Token { + pub token_id: String, + pub outcome: String, +} + +#[derive(Debug, Serialize, Deserialize)] +pub struct Rewards { + pub rates: Option, + #[serde(with = "rust_decimal::serde::str")] + pub min_size: Decimal, + #[serde(with = "rust_decimal::serde::str")] + pub max_spread: Decimal, + pub event_start_date: Option, + pub event_end_date: Option, + #[serde(with = "rust_decimal::serde::str", skip_serializing_if = "Option::is_none")] + pub in_game_multiplier: Option, + #[serde(with = "rust_decimal::serde::str", skip_serializing_if = "Option::is_none")] + pub reward_epoch: Option, +} + +// For compatibility with reference implementation +pub type ClientResult = anyhow::Result; + /// Result type used throughout the client pub type Result = std::result::Result; \ No newline at end of file