Skip to content

Commit 60a1218

Browse files
committed
refactor(rust): live feature configuration.
1 parent c48fe85 commit 60a1218

File tree

3 files changed

+11
-25
lines changed

3 files changed

+11
-25
lines changed

connector/src/binancefutures/mod.rs

+8-1
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,14 @@ impl From<BinanceFuturesError> for Value {
5959
match value {
6060
BinanceFuturesError::InstrumentNotFound => Value::String(value.to_string()),
6161
BinanceFuturesError::InvalidRequest => Value::String(value.to_string()),
62-
BinanceFuturesError::ReqError(error) => error.into(),
62+
BinanceFuturesError::ReqError(error) => {
63+
let mut map = HashMap::new();
64+
if let Some(code) = error.status() {
65+
map.insert("status_code".to_string(), Value::String(code.to_string()));
66+
}
67+
map.insert("msg".to_string(), Value::String(error.to_string()));
68+
Value::Map(map)
69+
}
6370
BinanceFuturesError::OrderError { code, msg } => Value::Map({
6471
let mut map = HashMap::new();
6572
map.insert("code".to_string(), Value::Int(code));

hftbacktest/Cargo.toml

+3-12
Original file line numberDiff line numberDiff line change
@@ -16,17 +16,14 @@ keywords = [
1616
"hft"
1717
]
1818
categories = ["finance", "mathematics", "science", "algorithms", "simulation"]
19-
rust-version = "1.81"
19+
rust-version = "1.82"
2020

2121
# See more keys and their definitions at https://doc.rust-lang.org/cargo/reference/manifest.html
2222

2323
[features]
24-
default = ["backtest", "live", "binancefutures", "bybit"]
24+
default = ["backtest", "live"]
2525
backtest = ["zip", "uuid", "nom", "hftbacktest-derive"]
26-
live = ["chrono", "tokio", "futures-util", "iceoryx2"]
27-
use_reqwest = ["reqwest"]
28-
binancefutures = ["serde", "serde_json", "tokio-tungstenite", "use_reqwest", "sha2", "hmac", "rand"]
29-
bybit = ["serde", "serde_json", "tokio-tungstenite", "use_reqwest", "sha2", "hmac", "rand"]
26+
live = ["chrono", "tokio", "futures-util", "iceoryx2", "rand"]
3027
unstable_fuse = []
3128

3229
[dependencies]
@@ -36,15 +33,9 @@ thiserror = "2.0.3"
3633
dyn-clone = "1.0.17"
3734
bincode = "2.0.0-rc.3"
3835
chrono = { version = "0.4.33", optional = true }
39-
serde = { version = "1.0.196", features = ["derive"], optional = true }
40-
serde_json = { version = "1.0.113", optional = true }
4136
tokio = { version = "1.35.1", features = ["full"], optional = true }
42-
tokio-tungstenite = { version = "0.24.0", features = ["rustls-tls-native-roots"], optional = true }
43-
reqwest = { version = "0.12.3", default-features = false, features = ["json", "rustls-tls-native-roots"], optional = true }
4437
zip = { version = "2.1.3", optional = true }
4538
futures-util = { version = "0.3.30", optional = true }
46-
sha2 = { version = "0.11.0-pre.3", optional = true }
47-
hmac = { version = "0.13.0-pre.3", optional = true }
4839
rand = { version = "0.8.5", optional = true }
4940
uuid = { version = "1.8.0", features = ["v4"], optional = true }
5041
nom = { version = "7.1.3", optional = true }

hftbacktest/src/types.rs

-12
Original file line numberDiff line numberDiff line change
@@ -87,18 +87,6 @@ impl From<anyhow::Error> for Value {
8787
}
8888
}
8989

90-
#[cfg(feature = "use_reqwest")]
91-
impl From<reqwest::Error> for Value {
92-
fn from(value: reqwest::Error) -> Self {
93-
let mut map = HashMap::new();
94-
if let Some(code) = value.status() {
95-
map.insert("status_code".to_string(), Value::String(code.to_string()));
96-
}
97-
map.insert("msg".to_string(), Value::String(value.to_string()));
98-
Value::Map(map)
99-
}
100-
}
101-
10290
/// Error conveyed through [`LiveEvent`].
10391
#[derive(Clone, Debug, Decode, Encode)]
10492
pub struct LiveError {

0 commit comments

Comments
 (0)