Automated Crypto Trading with the Kraken Module
Financial markets never sleep, and neither should your AI agent. Today we're releasing the Kraken module — a new marketplace module that gives Altclaw agents full access to the Kraken cryptocurrency exchange. Your agents can now monitor markets, analyze price action, execute trades, and manage portfolios autonomously — all while your API credentials remain cryptographically sealed and never exposed to script code.
Why Kraken?
Kraken is one of the most established and regulated cryptocurrency exchanges, trusted by millions of traders worldwide. Its robust REST API, deep liquidity, and comprehensive asset coverage make it an ideal foundation for automated trading strategies. By packaging the entire Kraken API into a single require("kraken") call, we've eliminated the authentication complexity and let agents focus on what matters — making intelligent trading decisions.
Getting Started in 30 Seconds
Setup is straightforward. Store your Kraken API keys as secrets, and the module handles the rest:
secret.set("KRAKEN_API_KEY", "your-public-key");
secret.set("KRAKEN_API_SECRET", "your-private-key");
var k = require("kraken");
// Check the current BTC price
var ticker = k.ticker("XBTUSD");
var price = ticker.result.XXBTZUSD.c[0];
ui.log("Bitcoin: $" + price);
// Preview a buy order (dry run — no real trade)
var preview = k.buy("XBTUSD", 0.001);
ui.log(preview.result.descr.order);Full API Coverage
The module wraps the complete Kraken Spot REST API into clean, intuitive methods:
- Market Data: Real-time tickers, OHLC candles, order book depth, recent trades, and spread data — all without authentication.
- Account Management: Balances, trade balances, open/closed orders, trade history, ledger entries, and margin positions.
- Trading: Market and limit orders with
buy()andsell()convenience methods, plus fulladdOrder()control for stop-losses, take-profits, trailing stops, and conditional closes. - Risk Management: Cancel individual orders, cancel all open orders, or set a dead man's switch with
cancelAfter()that auto-cancels everything if your agent stops sending heartbeats.
Safety First
We take the "real money" aspect seriously. Every trading function defaults to validate-only mode — a dry run that returns what the order would do without actually placing it. You must explicitly pass validate: false to execute a real trade. This prevents accidental orders during development and testing.
// Safe: dry run (default) — no real order placed
k.buy("ETHUSD", 2.0, {ordertype: "limit", price: 3500});
// Live: explicitly opt-in to real execution
k.buy("ETHUSD", 2.0, {
ordertype: "limit",
price: 3500,
validate: false // ← this places a real order
});Crypto Bridge: Secure HMAC Signing
Behind the scenes, the Kraken module required a significant upgrade to Altclaw's crypto bridge. Kraken authenticates every private request with an HMAC-SHA512 signature derived from the API secret — a cryptographic operation that must use the raw secret key.
In Altclaw's security model, secrets are never readable from JavaScript. To solve this, we expanded the crypto bridge with Node.js-compatible createHash() and createHmac() functions that support {{secrets.NAME}} expansion in the key parameter. The Go backend resolves the raw secret, performs the HMAC computation, and returns only the resulting signature — the actual key material never touches the JavaScript layer.
These new crypto functions aren't limited to Kraken. Any module that needs HMAC signing — Binance, Coinbase, AWS Signature V4, or custom webhooks — can now use the same secure pattern.
What You Can Build
With the Kraken module, your agents can implement sophisticated trading strategies that would otherwise require dedicated infrastructure:
- Dollar-cost averaging bots that place scheduled buys using
cron+kraken - Portfolio rebalancers that monitor allocations and adjust positions
- Price alert systems that notify you via email when targets are hit
- Research pipelines that combine web search, market data, and AI analysis before suggesting trades
"Autonomous trading demands two things: intelligence and security. The Kraken module brings both — your agent gets full market access while your keys stay mathematically sealed."
The Kraken module is available now in the Altclaw marketplace. Install it from the Modules panel or drop it in your modules directory to get started.