| Crates.io | kraky |
| lib.rs | kraky |
| version | 0.1.2 |
| created_at | 2025-12-24 01:53:30.326867+00 |
| updated_at | 2025-12-24 14:47:32.420342+00 |
| description | Lightweight, production-ready Rust SDK for Kraken Exchange WebSocket API v2 with unique orderbook imbalance detection and WebSocket trading |
| homepage | https://github.com/sarptekin/kraky |
| repository | https://github.com/sarptekin/kraky |
| max_upload_size | |
| id | 2002631 |
| size | 465,643 |
A lightweight, production-ready Rust SDK for the Kraken Exchange WebSocket API v2 with built-in orderbook imbalance detection and Telegram alert integration.
Building with cryptocurrency exchange WebSocket APIs is complex. Kraky handles the hard parts:
Test the SDK in under 2 minutes - no credentials needed!
# Clone and test
git clone https://github.com/SarpTekin/kraky.git
cd kraky
# Run tests (69 passing)
cargo test
# Run the demo - shows all core features
cargo run --example demo --features full
The demo showcases:
# Basic examples (no credentials needed)
cargo run --example orderbook # Orderbook depth
cargo run --example trades --features trades # Real-time trades
cargo run --example ticker --features ticker # Price/volume updates
# Advanced examples (require Telegram/Kraken credentials - see SETUP.md)
cargo run --example whale_watcher --features telegram-alerts # Whale detection
cargo run --example telegram_imbalance_bot --features telegram-alerts # Imbalance alerts
cargo run --example telegram_trading_bot --features telegram,trading # Trading bot
📝 Need credentials? See SETUP.md for Telegram and Kraken API setup.
Add to your Cargo.toml:
[dependencies]
kraky = { git = "https://github.com/SarpTekin/kraky" }
tokio = { version = "1.35", features = ["full"] }
Kraky uses feature flags for modular compilation:
# Default (orderbook + reconnect + events)
kraky = { git = "..." }
# With analytics (imbalance detection)
kraky = { git = "...", features = ["analytics"] }
# With Telegram alerts
kraky = { git = "...", features = ["telegram-alerts"] }
# Everything (market data + analytics + telegram + trading)
kraky = { git = "...", features = ["full"] }
Available features:
orderbook, trades, ticker, ohlc - Market data typesanalytics - Orderbook imbalance detectiontelegram, telegram-alerts - Telegram bot integrationauth, private, trading - Authentication and tradingchecksum - CRC32 orderbook validationsimd - SIMD-accelerated JSON parsingSee docs.rs for complete feature documentation.
use kraky::KrakyClient;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
// Connect to Kraken WebSocket
let client = KrakyClient::connect().await?;
// Subscribe to BTC/USD orderbook (depth: 10 levels)
let mut orderbook = client.subscribe_orderbook("BTC/USD", 10).await?;
// Process real-time updates
while let Some(update) = orderbook.next().await {
// Access managed orderbook state
if let Some(ob) = client.get_orderbook("BTC/USD") {
println!("Best bid: ${:.2}", ob.best_bid().unwrap_or(0.0));
println!("Best ask: ${:.2}", ob.best_ask().unwrap_or(0.0));
println!("Spread: ${:.2}", ob.spread().unwrap_or(0.0));
// Get trading signal (requires 'analytics' feature)
#[cfg(feature = "analytics")]
{
let imbalance = ob.imbalance();
let signal = ob.imbalance_signal();
println!("Imbalance: {:.2}% - Signal: {:?}",
imbalance * 100.0, signal);
}
}
}
Ok(())
}
Kraky includes 18 working examples:
Basic (No Credentials):
orderbook.rs - Orderbook depth updatestrades.rs - Real-time trade streamticker.rs - Price and volume dataohlc.rs - Candlestick datamulti_subscribe.rs - Multiple concurrent subscriptionsdemo.rs - Comprehensive feature showcaseAdvanced (Requires Setup):
telegram_imbalance_bot.rs - Orderbook imbalance alertswhale_watcher.rs - Large order detectionsimple_price_alerts.rs - Price threshold alertstelegram_private_alerts.rs - Account activity notificationstelegram_trading_bot.rs - Automated trading with alertsexport_to_csv.rs - Market data exportSee examples/ directory for all examples.
Kraky is built with:
Binary Size:
See docs.rs/kraky for detailed architecture documentation.
# Run all tests
cargo test --all-features
# Results: 69 tests passing
# - 47 unit tests
# - 22 doctests
Contributions welcome! Please:
cargo test --all-features passesLicensed under the MIT License. See LICENSE for details.
Built for the Kraken Forge Hackathon 🐙