| Crates.io | drm-exchange-kalshi |
| lib.rs | drm-exchange-kalshi |
| version | 0.1.3 |
| created_at | 2025-12-25 17:50:09.199866+00 |
| updated_at | 2025-12-28 08:44:57.004557+00 |
| description | Kalshi exchange implementation for dr-manhattan |
| homepage | |
| repository | https://github.com/gtg7784/dr-manhattan-rust |
| max_upload_size | |
| id | 2004799 |
| size | 89,466 |
Kalshi exchange implementation for dr-manhattan.
This crate provides a complete Kalshi integration including:
[dependencies]
drm-exchange-kalshi = "0.1"
use drm_core::Exchange;
use drm_exchange_kalshi::{Kalshi, KalshiConfig};
#[tokio::main]
async fn main() -> anyhow::Result<()> {
// Public API (limited endpoints)
let exchange = Kalshi::with_default_config()?;
// Fetch markets
let markets = exchange.fetch_markets(None).await?;
for market in markets.iter().take(5) {
println!("{}: {:?}", market.question, market.prices);
}
Ok(())
}
Kalshi uses RSA-PSS signatures for authentication. You need:
# Generate RSA private key
openssl genpkey -algorithm RSA -out kalshi_private_key.pem -pkeyopt rsa_keygen_bits:4096
# Extract public key (upload this to Kalshi)
openssl rsa -pubout -in kalshi_private_key.pem -out kalshi_public_key.pem
use drm_exchange_kalshi::{Kalshi, KalshiConfig};
// From file path
let config = KalshiConfig::new()
.with_api_key_id("your-api-key-id")
.with_private_key_path("/path/to/kalshi_private_key.pem");
// Or from PEM string
let config = KalshiConfig::new()
.with_api_key_id("your-api-key-id")
.with_private_key_pem(include_str!("../kalshi_private_key.pem"));
let exchange = Kalshi::new(config)?;
// Now you can create orders, fetch positions, etc.
use drm_exchange_kalshi::{Kalshi, KalshiConfig};
let config = KalshiConfig::demo()
.with_api_key_id("demo-api-key-id")
.with_private_key_path("/path/to/demo_private_key.pem");
let exchange = Kalshi::new(config)?;
| Feature | Status |
|---|---|
| Fetch markets | ✅ |
| Fetch market by ticker | ✅ |
| Fetch orderbook | ✅ (auth required) |
| Create orders | ✅ |
| Cancel orders | ✅ |
| Fetch orders | ✅ |
| Fetch positions | ✅ |
| Fetch balance | ✅ |
| WebSocket orderbook | - |
Kalshi uses ticker strings as market identifiers (e.g., "INXD-24DEC31-B5000").
use drm_core::{Exchange, OrderSide};
use std::collections::HashMap;
// Create a limit order to buy Yes at $0.55
let order = exchange.create_order(
"INXD-24DEC31-B5000", // ticker
"Yes", // outcome (Yes or No)
OrderSide::Buy, // action
0.55, // price in decimal (55 cents)
10.0, // size (number of contracts)
HashMap::new(),
).await?;
This crate is part of the dr-manhattan-rust project, a Rust port of guzus/dr-manhattan.
MIT