nautilus_kraken/
config.rs1use nautilus_model::identifiers::{AccountId, TraderId};
19
20use crate::common::{
21 enums::{KrakenEnvironment, KrakenProductType},
22 urls::{get_kraken_http_base_url, get_kraken_ws_private_url, get_kraken_ws_public_url},
23};
24
25#[derive(Debug, Clone)]
27pub struct KrakenDataClientConfig {
28 pub api_key: Option<String>,
29 pub api_secret: Option<String>,
30 pub product_type: KrakenProductType,
31 pub environment: KrakenEnvironment,
32 pub base_url: Option<String>,
33 pub ws_public_url: Option<String>,
34 pub ws_private_url: Option<String>,
35 pub http_proxy: Option<String>,
36 pub ws_proxy: Option<String>,
37 pub timeout_secs: Option<u64>,
38 pub heartbeat_interval_secs: Option<u64>,
39 pub max_requests_per_second: Option<u32>,
40}
41
42impl Default for KrakenDataClientConfig {
43 fn default() -> Self {
44 Self {
45 api_key: None,
46 api_secret: None,
47 product_type: KrakenProductType::Spot,
48 environment: KrakenEnvironment::Mainnet,
49 base_url: None,
50 ws_public_url: None,
51 ws_private_url: None,
52 http_proxy: None,
53 ws_proxy: None,
54 timeout_secs: Some(30),
55 heartbeat_interval_secs: Some(30),
56 max_requests_per_second: None,
57 }
58 }
59}
60
61impl KrakenDataClientConfig {
62 pub fn has_api_credentials(&self) -> bool {
64 self.api_key.is_some() && self.api_secret.is_some()
65 }
66
67 pub fn http_base_url(&self) -> String {
69 self.base_url.clone().unwrap_or_else(|| {
70 get_kraken_http_base_url(self.product_type, self.environment).to_string()
71 })
72 }
73
74 pub fn ws_public_url(&self) -> String {
76 self.ws_public_url.clone().unwrap_or_else(|| {
77 get_kraken_ws_public_url(self.product_type, self.environment).to_string()
78 })
79 }
80
81 pub fn ws_private_url(&self) -> String {
83 self.ws_private_url.clone().unwrap_or_else(|| {
84 get_kraken_ws_private_url(self.product_type, self.environment).to_string()
85 })
86 }
87}
88
89#[derive(Debug, Clone)]
91pub struct KrakenExecClientConfig {
92 pub trader_id: TraderId,
93 pub account_id: AccountId,
94 pub api_key: String,
95 pub api_secret: String,
96 pub product_type: KrakenProductType,
97 pub environment: KrakenEnvironment,
98 pub base_url: Option<String>,
99 pub ws_url: Option<String>,
100 pub http_proxy: Option<String>,
101 pub ws_proxy: Option<String>,
102 pub timeout_secs: Option<u64>,
103 pub heartbeat_interval_secs: Option<u64>,
104 pub max_requests_per_second: Option<u32>,
105}
106
107impl Default for KrakenExecClientConfig {
108 fn default() -> Self {
109 Self {
110 trader_id: TraderId::default(),
111 account_id: AccountId::from("KRAKEN-001"),
112 api_key: String::new(),
113 api_secret: String::new(),
114 product_type: KrakenProductType::Spot,
115 environment: KrakenEnvironment::Mainnet,
116 base_url: None,
117 ws_url: None,
118 http_proxy: None,
119 ws_proxy: None,
120 timeout_secs: Some(30),
121 heartbeat_interval_secs: Some(30),
122 max_requests_per_second: None,
123 }
124 }
125}
126
127impl KrakenExecClientConfig {
128 pub fn http_base_url(&self) -> String {
130 self.base_url.clone().unwrap_or_else(|| {
131 get_kraken_http_base_url(self.product_type, self.environment).to_string()
132 })
133 }
134
135 pub fn ws_url(&self) -> String {
137 self.ws_url.clone().unwrap_or_else(|| {
138 get_kraken_ws_private_url(self.product_type, self.environment).to_string()
139 })
140 }
141}