1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
use std::sync::{
atomic::{AtomicBool, AtomicUsize, Ordering},
Arc, Mutex,
};
use std::time::Duration;
use super::utils::{check_args, fetch_symbols_retry};
use crate::{msg::Message, MessageType};
use crypto_markets::MarketType;
use crypto_ws_client::*;
use log::*;
const EXCHANGE_NAME: &str = "bitz";
const MAX_SUBSCRIPTIONS_PER_CONNECTION: usize = usize::MAX;
#[rustfmt::skip]
gen_crawl_event!(crawl_trade_spot, BitzSpotWSClient, MessageType::Trade, subscribe_trade);
#[rustfmt::skip]
gen_crawl_event!(crawl_l2_event_spot, BitzSpotWSClient, MessageType::L2Event, subscribe_orderbook);
#[rustfmt::skip]
gen_crawl_event!(crawl_ticker_spot, BitzSpotWSClient, MessageType::Ticker, subscribe_ticker);
pub(crate) fn crawl_trade(
market_type: MarketType,
symbols: Option<&[String]>,
on_msg: Arc<Mutex<dyn FnMut(Message) + 'static + Send>>,
duration: Option<u64>,
) -> Option<std::thread::JoinHandle<()>> {
match market_type {
MarketType::Spot => crawl_trade_spot(market_type, symbols, on_msg, duration),
_ => panic!("Bitz does NOT have the {} market type", market_type),
}
}
pub(crate) fn crawl_l2_event(
market_type: MarketType,
symbols: Option<&[String]>,
on_msg: Arc<Mutex<dyn FnMut(Message) + 'static + Send>>,
duration: Option<u64>,
) -> Option<std::thread::JoinHandle<()>> {
match market_type {
MarketType::Spot => crawl_l2_event_spot(market_type, symbols, on_msg, duration),
_ => panic!("Bitz does NOT have the {} market type", market_type),
}
}
pub(crate) fn crawl_ticker(
market_type: MarketType,
symbols: Option<&[String]>,
on_msg: Arc<Mutex<dyn FnMut(Message) + 'static + Send>>,
duration: Option<u64>,
) -> Option<std::thread::JoinHandle<()>> {
match market_type {
MarketType::Spot => crawl_ticker_spot(market_type, symbols, on_msg, duration),
_ => panic!("Bitz does NOT have the {} market type", market_type),
}
}