Crate crypto_crawler
source · [−]Expand description
A rock-solid cryprocurrency crawler.
Crawl realtime trades
use crypto_crawler::{crawl_trade, MarketType};
#[tokio::main(flavor = "multi_thread")]
async fn main() {
let (tx, rx) = std::sync::mpsc::channel();
tokio::task::spawn(async move {
// Crawl realtime trades for all symbols of binance inverse_swap markets
crawl_trade("binance", MarketType::InverseSwap, None, tx).await;
});
let mut messages = Vec::new();
for msg in rx {
messages.push(msg);
break;
}
assert!(!messages.is_empty());
}
Crawl realtime level2 orderbook incremental updates
use crypto_crawler::{crawl_l2_event, MarketType};
#[tokio::main(flavor = "multi_thread")]
async fn main() {
let (tx, rx) = std::sync::mpsc::channel();
tokio::task::spawn(async move {
// Crawl realtime level2 incremental updates for all symbols of binance inverse_swap markets
crawl_l2_event("binance", MarketType::InverseSwap, None, tx).await;
});
let mut messages = Vec::new();
for msg in rx {
messages.push(msg);
break;
}
assert!(!messages.is_empty());
}
Crawl level2 orderbook full snapshots from RESTful API
use crypto_crawler::{crawl_l2_snapshot, MarketType};
let (tx, rx) = std::sync::mpsc::channel();
std::thread::spawn(move || {
// Crawl level2 full snapshots for all symbols of binance inverse_swap markets
crawl_l2_snapshot("binance", MarketType::InverseSwap, None, tx);
});
let mut messages = Vec::new();
for msg in rx {
messages.push(msg);
break;
}
assert!(!messages.is_empty());
Crawl realtime level2 orderbook top-K snapshots
use crypto_crawler::{crawl_l2_topk, MarketType};
#[tokio::main(flavor = "multi_thread")]
async fn main() {
let (tx, rx) = std::sync::mpsc::channel();
tokio::task::spawn(async move {
// Crawl realtime level2 top-k snapshots for all symbols of binance inverse_swap markets
crawl_l2_topk("binance", MarketType::InverseSwap, None, tx).await;
});
let mut messages = Vec::new();
for msg in rx {
messages.push(msg);
break;
}
assert!(!messages.is_empty());
}
Crawl realtime level3 orderbook incremental updates
use crypto_crawler::{crawl_l3_event, MarketType};
#[tokio::main(flavor = "multi_thread")]
async fn main() {
let (tx, rx) = std::sync::mpsc::channel();
tokio::task::spawn(async move {
// Crawl realtime level3 updates for all symbols of CoinbasePro spot market
crawl_l3_event("coinbase_pro", MarketType::Spot, None, tx).await;
});
let mut messages = Vec::new();
for msg in rx {
messages.push(msg);
break;
}
assert!(!messages.is_empty());
}
Crawl level3 orderbook full snapshots from RESTful API
use crypto_crawler::{crawl_l3_snapshot, MarketType};
let (tx, rx) = std::sync::mpsc::channel();
std::thread::spawn(move || {
// Crawl level3 orderbook full snapshots for all symbols of CoinbasePro spot markets
crawl_l3_snapshot("coinbase_pro", MarketType::Spot, None, tx);
});
let mut messages = Vec::new();
for msg in rx {
messages.push(msg);
break;
}
assert!(!messages.is_empty());
Crawl realtime BBO
use crypto_crawler::{crawl_bbo, MarketType};
#[tokio::main(flavor = "multi_thread")]
async fn main() {
let (tx, rx) = std::sync::mpsc::channel();
tokio::task::spawn(async move {
// Crawl realtime best bid and ask messages for all symbols of binance COIN-margined perpetual markets
crawl_bbo("binance", MarketType::InverseSwap, None, tx).await;
});
let mut messages = Vec::new();
for msg in rx {
messages.push(msg);
break;
}
assert!(!messages.is_empty());
}
Crawl 24hr rolling window tickers
use crypto_crawler::{crawl_ticker, MarketType};
#[tokio::main(flavor = "multi_thread")]
async fn main() {
let (tx, rx) = std::sync::mpsc::channel();
tokio::task::spawn(async move {
// Crawl 24hr rolling window tickers for all symbols of binance COIN-margined perpetual markets
crawl_ticker("binance", MarketType::InverseSwap, None, tx).await;
});
let mut messages = Vec::new();
for msg in rx {
messages.push(msg);
break;
}
assert!(!messages.is_empty());
}
Crawl candlesticks(i.e., OHLCV)
use crypto_crawler::{crawl_candlestick, MarketType};
#[tokio::main(flavor = "multi_thread")]
async fn main() {
let (tx, rx) = std::sync::mpsc::channel();
tokio::task::spawn(async move {
// Crawl candlesticks from 1 minute to 3 minutes for all symbols of binance COIN-margined perpetual markets
crawl_candlestick("binance", MarketType::InverseSwap, None, tx).await;
});
let mut messages = Vec::new();
for msg in rx {
messages.push(msg);
break;
}
assert!(!messages.is_empty());
}
Crawl funding rates
use crypto_crawler::{crawl_funding_rate, MarketType};
#[tokio::main(flavor = "multi_thread")]
async fn main() {
let (tx, rx) = std::sync::mpsc::channel();
tokio::task::spawn(async move {
// Crawl funding rates for all symbols of binance COIN-margined perpetual markets
crawl_funding_rate("binance", MarketType::InverseSwap, None, tx).await;
});
let mut messages = Vec::new();
for msg in rx {
messages.push(msg);
break;
}
assert!(!messages.is_empty());
}
Structs
Message represents messages received by crawlers.
Enums
Market type.
Crypto message types.
Functions
Crawl best bid and ask.
Crawl candlestick(i.e., OHLCV) data.
Crawl perpetual swap funding rates.
Crawl level2 orderbook update events.
Crawl level2 orderbook snapshots through RESTful APIs.
Crawl level2 orderbook top-k snapshots through websocket.
Crawl level3 orderbook update events.
Crawl level3 orderbook snapshots through RESTful APIs.
Crawl all open interest.
Crawl 24hr rolling window ticker.
Crawl realtime trades.
Subscribe to multiple message types of one symbol.