Skip to content

Commit c10ace9

Browse files
valeratradesclaude
andcommitted
feat: add Kucoin to healthcheck example
- Added check_kucoin() function with specific error handling - Detects common Kucoin API errors (400003-400007) - Requires KUCOIN_API_PUBKEY, KUCOIN_API_SECRET, and KUCOIN_API_PASSPHRASE - Updated healthcheck to require kucoin feature 🤖 Generated with [Claude Code](https://claude.com/claude-code) Co-Authored-By: Claude <[email protected]>
1 parent 43e83e3 commit c10ace9

File tree

2 files changed

+48
-1
lines changed

2 files changed

+48
-1
lines changed

examples/healthcheck.rs

Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ async fn main() {
1010

1111
check_binance().await;
1212
check_bybit().await;
13+
check_kucoin().await;
1314
check_mexc().await;
1415

1516
println!("\n=== Health Check Complete ===");
@@ -55,6 +56,52 @@ async fn check_bybit() {
5556
}
5657
}
5758

59+
async fn check_kucoin() {
60+
println!("🔍 Checking Kucoin...");
61+
62+
let key_var = "KUCOIN_API_PUBKEY";
63+
let secret_var = "KUCOIN_API_SECRET";
64+
let passphrase_var = "KUCOIN_API_PASSPHRASE";
65+
66+
match (env::var(key_var), env::var(secret_var), env::var(passphrase_var)) {
67+
(Ok(key), Ok(secret), Ok(passphrase)) => {
68+
#[cfg(feature = "kucoin")]
69+
{
70+
use v_exchanges_adapters::kucoin::KucoinOption;
71+
let mut kucoin = ExchangeName::Kucoin.init_client();
72+
kucoin.update_default_option(KucoinOption::Pubkey(key));
73+
kucoin.update_default_option(KucoinOption::Secret(secret.into()));
74+
kucoin.update_default_option(KucoinOption::Passphrase(passphrase.into()));
75+
76+
match kucoin.balances(Instrument::Spot, None).await {
77+
Ok(_) => println!("✅ Kucoin: API key is valid and active"),
78+
Err(e) => {
79+
let err_str = e.to_string();
80+
if err_str.contains("400003") || err_str.contains("KC-API-KEY not exists") {
81+
println!("❌ Kucoin: API key does not exist or has been deleted");
82+
} else if err_str.contains("400004") || err_str.contains("KC-API-PASSPHRASE") {
83+
println!("❌ Kucoin: Invalid passphrase");
84+
} else if err_str.contains("400005") || err_str.contains("Signature") {
85+
println!("❌ Kucoin: Invalid signature (check API secret)");
86+
} else if err_str.contains("400006") || err_str.contains("timestamp") {
87+
println!("❌ Kucoin: Invalid timestamp");
88+
} else if err_str.contains("400007") || err_str.contains("KC-API-KEY-VERSION") {
89+
println!("❌ Kucoin: Invalid API key version");
90+
} else {
91+
println!("❌ Kucoin: API key error - {}", e);
92+
}
93+
}
94+
}
95+
}
96+
#[cfg(not(feature = "kucoin"))]
97+
{
98+
println!("⚠️ Kucoin: Feature not enabled (compile with --features kucoin)");
99+
}
100+
}
101+
_ => println!("⚠️ Kucoin: Environment variables {}, {}, or {} not set", key_var, secret_var, passphrase_var),
102+
}
103+
}
104+
58105
async fn check_mexc() {
59106
println!("🔍 Checking MEXC...");
60107

v_exchanges/Cargo.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -115,5 +115,5 @@ path = "../examples/mexc.rs"
115115

116116
[[example]]
117117
name = "healthcheck"
118-
required-features = ["binance", "bybit", "mexc"]
118+
required-features = ["binance", "bybit", "kucoin", "mexc"]
119119
path = "../examples/healthcheck.rs"

0 commit comments

Comments
 (0)