rusty_feeder/exchange/coinbase/
types.rs

1use crate::provider::prelude::*;
2
3/// Coinbase API rate limits
4pub const COINBASE_RATE_LIMITS: &[RateLimit] = &[
5    RateLimit {
6        limit_type: "RAW_REQUESTS",
7        interval: "MINUTE",
8        interval_num: 1,
9        limit: 100,
10    },
11    RateLimit {
12        limit_type: "ORDERS",
13        interval: "MINUTE",
14        interval_num: 1,
15        limit: 30,
16    },
17];
18
19/// Coinbase WebSocket URLs
20/// Traditional market data feed (public)
21pub const COINBASE_WS_FEED_URL: &str = "wss://ws-feed.exchange.coinbase.com";
22/// Direct market data feed with lower latency (may require authentication)
23pub const COINBASE_WS_DIRECT_URL: &str = "wss://ws-direct.exchange.coinbase.com";
24/// Advanced Trade WebSocket URL
25pub const COINBASE_WS_ADVANCED_URL: &str = "wss://advanced-trade-ws.coinbase.com";
26/// Sandbox public market data feed for testing
27pub const COINBASE_WS_SANDBOX_FEED_URL: &str = "wss://ws-feed-public.sandbox.exchange.coinbase.com";
28/// Sandbox direct market data feed for testing
29pub const COINBASE_WS_SANDBOX_DIRECT_URL: &str = "wss://ws-direct.sandbox.exchange.coinbase.com";
30
31/// Coinbase REST API base URL
32pub const COINBASE_API_URL: &str = "https://api.exchange.coinbase.com";
33
34/// Coinbase WebSocket message types
35#[derive(Debug, PartialEq, Eq)]
36pub enum CoinbaseMessageType {
37    /// Subscription confirmation message
38    Subscription,
39    /// Ticker update message
40    Ticker,
41    /// Level2 order book snapshot
42    Level2Snapshot,
43    /// Level2 order book update
44    Level2Update,
45    /// Trade match message
46    TradeMatch,
47    /// Heartbeat keepalive message
48    Heartbeat,
49    /// Error message
50    Error,
51    /// Unknown message type
52    Unknown,
53}
54
55impl From<&str> for CoinbaseMessageType {
56    fn from(s: &str) -> Self {
57        match s {
58            "subscriptions" => Self::Subscription,
59            "ticker" => Self::Ticker,
60            "snapshot" => Self::Level2Snapshot,
61            "l2update" => Self::Level2Update,
62            "match" | "last_match" => Self::TradeMatch,
63            "heartbeat" => Self::Heartbeat,
64            "error" => Self::Error,
65            _ => Self::Unknown,
66        }
67    }
68}