crypto-pair 2.3.20

Parse exchange-specific symbols to unified format
Documentation
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
use crypto_market_type::MarketType;

pub(crate) fn get_market_type(symbol: &str, is_spot: Option<bool>) -> MarketType {
    if symbol.ends_with("_USD") {
        MarketType::InverseSwap
    } else if symbol.ends_with("_USDT") {
        if let Some(is_spot) = is_spot {
            if is_spot { MarketType::Spot } else { MarketType::LinearSwap }
        } else {
            MarketType::LinearSwap
        }
    } else if symbol.contains('_') {
        MarketType::Spot
    } else {
        MarketType::Unknown
    }
}