Skip to main content

ccxt_exchanges/binance/
constants.rs

1//! Binance API constants.
2//!
3//! This module contains constants for API endpoints, order statuses, and other
4//! fixed strings used throughout the Binance implementation.
5
6use std::collections::HashMap;
7
8/// API Endpoints
9pub mod endpoints {
10    /// Public API base URL
11    pub const PUBLIC: &str = "https://api.binance.com/api/v3";
12    /// SAPI (System API) base URL
13    pub const SAPI: &str = "https://api.binance.com/sapi/v1";
14    /// FAPI (Futures API) base URL
15    pub const FAPI: &str = "https://fapi.binance.com/fapi/v1";
16    /// DAPI (Delivery API) base URL
17    pub const DAPI: &str = "https://dapi.binance.com/dapi/v1";
18
19    /// Exchange Info endpoint
20    pub const EXCHANGE_INFO: &str = "/exchangeInfo";
21    /// 24hr Ticker endpoint
22    pub const TICKER_24HR: &str = "/ticker/24hr";
23    /// Price Ticker endpoint
24    pub const TICKER_PRICE: &str = "/ticker/price";
25    /// Order Book (Depth) endpoint
26    pub const DEPTH: &str = "/depth";
27    /// Recent Trades endpoint
28    pub const TRADES: &str = "/trades";
29    /// Aggregated Trades endpoint
30    pub const AGG_TRADES: &str = "/aggTrades";
31    /// Kline/Candlestick endpoint
32    pub const KLINES: &str = "/klines";
33    /// Rolling window ticker endpoint
34    pub const TICKER_ROLLING: &str = "/ticker";
35    /// Historical Trades endpoint
36    pub const HISTORICAL_TRADES: &str = "/historicalTrades";
37    /// System Status endpoint
38    pub const SYSTEM_STATUS: &str = "/system/status";
39    /// Server Time endpoint
40    pub const TIME: &str = "/time";
41
42    /// Order endpoint (create, cancel, fetch)
43    pub const ORDER: &str = "/order";
44    /// Open Orders endpoint
45    pub const OPEN_ORDERS: &str = "/openOrders";
46    /// All Orders endpoint
47    pub const ALL_ORDERS: &str = "/allOrders";
48}
49
50/// Order Statuses
51pub mod status {
52    /// The order has been accepted by the engine.
53    pub const NEW: &str = "NEW";
54    /// A part of the order has been filled.
55    pub const PARTIALLY_FILLED: &str = "PARTIALLY_FILLED";
56    /// The order has been completed.
57    pub const FILLED: &str = "FILLED";
58    /// The order has been canceled by the user.
59    pub const CANCELED: &str = "CANCELED";
60    /// The order is currently pending cancelation.
61    pub const PENDING_CANCEL: &str = "PENDING_CANCEL";
62    /// The order was not accepted by the engine and not processed.
63    pub const REJECTED: &str = "REJECTED";
64    /// The order was canceled according to the order type's rules.
65    pub const EXPIRED: &str = "EXPIRED";
66}
67
68/// Returns the supported timeframes for Binance.
69pub fn timeframes() -> HashMap<String, String> {
70    let mut timeframes = HashMap::new();
71    timeframes.insert("1s".to_string(), "1s".to_string());
72    timeframes.insert("1m".to_string(), "1m".to_string());
73    timeframes.insert("3m".to_string(), "3m".to_string());
74    timeframes.insert("5m".to_string(), "5m".to_string());
75    timeframes.insert("15m".to_string(), "15m".to_string());
76    timeframes.insert("30m".to_string(), "30m".to_string());
77    timeframes.insert("1h".to_string(), "1h".to_string());
78    timeframes.insert("2h".to_string(), "2h".to_string());
79    timeframes.insert("4h".to_string(), "4h".to_string());
80    timeframes.insert("6h".to_string(), "6h".to_string());
81    timeframes.insert("8h".to_string(), "8h".to_string());
82    timeframes.insert("12h".to_string(), "12h".to_string());
83    timeframes.insert("1d".to_string(), "1d".to_string());
84    timeframes.insert("3d".to_string(), "3d".to_string());
85    timeframes.insert("1w".to_string(), "1w".to_string());
86    timeframes.insert("1M".to_string(), "1M".to_string());
87    timeframes
88}