| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849 |
- use tracing::trace;
- use exchanges::proxy;
- use crate::exchange::ExchangeEnum;
- /// 修改交易对连接符号
- /// - `symbol(str)`: 交易对, "BTC_USDT", 默认以下划线传递
- /// - `pat(str)`: 替换字符, "-", 把 “_” 替换为 "-"
- pub fn format_symbol(symbol: String, pat: &str) -> String {
- return symbol.to_uppercase().replace("_", pat);
- }
- // 检测是否走代理
- pub fn proxy_handle() {
- if proxy::ParsingDetail::http_enable_proxy() {
- trace!("检测有代理配置,配置走代理");
- }
- }
- /// 币种映射器
- #[allow(dead_code)]
- pub fn symbol_enter_mapper(exchange_enum: ExchangeEnum, symbol: &str) -> String {
- let symbol_upper = symbol.to_uppercase();
- match exchange_enum {
- ExchangeEnum::KucoinSwap => {
- if symbol_upper.contains("BTC") {
- symbol_upper.replace("BTC", "XBT")
- } else { symbol_upper.to_string() }
- }
- _ => {
- symbol_upper.to_string()
- }
- }
- }
- /// 币种映射器
- #[allow(dead_code)]
- pub fn symbol_out_mapper(exchange_enum: ExchangeEnum, symbol: &str) -> String {
- let symbol_upper = symbol.to_uppercase();
- match exchange_enum {
- ExchangeEnum::KucoinSwap => {
- if symbol_upper.contains("XBT") {
- symbol_upper.replace("XBT", "BTC")
- } else { symbol_upper.to_string() }
- }
- _ => {
- symbol_upper.to_string()
- }
- }
- }
|