231个稳定版本
4.7.9 | 2023年3月19日 |
---|---|
4.7.4 | 2022年12月28日 |
4.7.2 | 2022年11月13日 |
4.5.7 | 2022年7月21日 |
0.1.0 |
|
#926 在 神奇豆
620 每月下载量
在 wmjtyd-libstock 中使用
665KB
15K SLoC
crypto-crawler
一个稳健的加密货币爬虫。
爬取实时交易
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 {
for msg in rx {
println!("{}", msg);
}
});
// Crawl realtime trades for all symbols of binance inverse_swap markets
crawl_trade("binance", MarketType::InverseSwap, None, tx).await;
}
爬取实时二级订单簿增量更新
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 {
for msg in rx {
println!("{}", msg);
}
});
// Crawl realtime level2 incremental updates for all symbols of binance inverse_swap markets
crawl_l2_event("binance", MarketType::InverseSwap, None, tx).await;
}
通过RESTful API爬取二级订单簿完整快照
use crypto_crawler::{crawl_l2_snapshot, MarketType};
fn main() {
let (tx, rx) = std::sync::mpsc::channel();
std::thread::spawn(move || {
for msg in rx {
println!("{}", msg);
}
});
// Crawl level2 full snapshots for all symbols of binance inverse_swap markets
crawl_l2_snapshot("binance", MarketType::InverseSwap, None, tx);
}
爬取实时二级订单簿前K快照
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 {
for msg in rx {
println!("{}", msg);
}
});
// Crawl realtime level2 top-k snapshots for all symbols of binance inverse_swap markets
crawl_l2_topk("binance", MarketType::InverseSwap, None, tx).await;
}
爬取实时三级订单簿增量更新
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 {
for msg in rx {
println!("{}", msg);
}
});
// Crawl realtime level3 updates for all symbols of CoinbasePro spot market
crawl_l3_event("coinbase_pro", MarketType::Spot, None, tx).await;
}
通过RESTful API爬取三级订单簿完整快照
use crypto_crawler::{crawl_l3_snapshot, MarketType};
fn main() {
let (tx, rx) = std::sync::mpsc::channel();
std::thread::spawn(move || {
for msg in rx {
println!("{}", msg);
}
});
// Crawl level3 orderbook full snapshots for all symbols of CoinbasePro spot markets
crawl_l3_snapshot("coinbase_pro", MarketType::Spot, None, tx);
}
爬取实时买卖报价
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 {
for msg in rx {
println!("{}", msg);
}
});
// Crawl realtime best bid and ask messages for all symbols of binance COIN-margined perpetual markets
crawl_bbo("binance", MarketType::InverseSwap, None, tx).await;
}
爬取24小时滚动窗口的报价
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 {
for msg in rx {
println!("{}", msg);
}
});
// Crawl 24hr rolling window tickers for all symbols of binance COIN-margined perpetual markets
crawl_ticker("binance", MarketType::InverseSwap, None, tx).await;
}
爬取蜡烛图(即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 {
for msg in rx {
println!("{}", msg);
}
});
// 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;
}
爬取资金费率
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 {
for msg in rx {
println!("{}", msg);
}
});
// Crawl funding rates for all symbols of binance COIN-margined perpetual markets
crawl_funding_rate("binance", MarketType::InverseSwap, None, tx).await;
}
依赖项
~15–32MB
~479K SLoC