use rust_decimal_macros::dec; use tracing::{instrument, trace}; use standard::exchange::ExchangeEnum; use standard::Platform; use crate::exchange_test::test_new_exchange; mod exchange_test; const SYMBOL: &str = "CRO_USDT"; // 测试获取Exchange实体 #[tokio::test] #[instrument(level = "TRACE")] async fn test_get_self_exchange() { global::log_utils::init_log_with_trace(); let okx_swap_exchange: Box = test_new_exchange(ExchangeEnum::OkxSwap, SYMBOL).await; let okx_get_self_exchange = okx_swap_exchange.get_self_exchange(); trace!(?okx_get_self_exchange); } // 测试获取交易对信息 #[tokio::test] #[instrument(level = "TRACE")] async fn test_get_self_symbol() { global::log_utils::init_log_with_trace(); let okx_swap_exchange: Box = test_new_exchange(ExchangeEnum::OkxSwap, SYMBOL).await; let okx_get_self_symbol = okx_swap_exchange.get_self_symbol(); trace!(?okx_get_self_symbol); } // 测试获取是否使用高速通道 #[tokio::test] #[instrument(level = "TRACE")] async fn test_get_self_is_colo() { global::log_utils::init_log_with_trace(); let okx_swap_exchange: Box = test_new_exchange(ExchangeEnum::OkxSwap, SYMBOL).await; let okx_get_self_is_colo = okx_swap_exchange.get_self_is_colo(); trace!(?okx_get_self_is_colo); } // 测试获取登录params信息 #[tokio::test] #[instrument(level = "TRACE")] async fn test_get_self_params() { global::log_utils::init_log_with_trace(); let okx_swap_exchange: Box = test_new_exchange(ExchangeEnum::OkxSwap, SYMBOL).await; let okx_get_self_params = okx_swap_exchange.get_self_params(); trace!("okx_get_self_params={:?}",okx_get_self_params); } // 测试获取Market信息 #[tokio::test] #[instrument(level = "TRACE")] async fn test_get_self_market() { global::log_utils::init_log_with_trace(); let okx_swap_exchange: Box = test_new_exchange(ExchangeEnum::OkxSwap, SYMBOL).await; let okx_get_self_market = okx_swap_exchange.get_self_market(); trace!(?okx_get_self_market); } // 测试获取请求时间信息 #[tokio::test] #[instrument(level = "TRACE")] async fn test_get_request_delays() { global::log_utils::init_log_with_trace(); let okx_swap_exchange: Box = test_new_exchange(ExchangeEnum::OkxSwap, SYMBOL).await; let okx_get_request_delays = okx_swap_exchange.get_request_delays(); trace!(?okx_get_request_delays); } // 测试获取请求平均时间信息 #[tokio::test] #[instrument(level = "TRACE")] async fn test_get_request_avg_delay() { global::log_utils::init_log_with_trace(); let okx_swap_exchange: Box = test_new_exchange(ExchangeEnum::OkxSwap, SYMBOL).await; let okx_get_request_avg_delay = okx_swap_exchange.get_request_avg_delay(); trace!(?okx_get_request_avg_delay); } // 测试获取最大请求时间信息 #[tokio::test] #[instrument(level = "TRACE")] async fn test_get_request_max_delay() { global::log_utils::init_log_with_trace(); let okx_swap_exchange: Box = test_new_exchange(ExchangeEnum::OkxSwap, SYMBOL).await; let okx_get_request_max_delay = okx_swap_exchange.get_request_max_delay(); trace!(?okx_get_request_max_delay); } // 测试获取服务器时间 #[tokio::test] #[instrument(level = "TRACE")] async fn test_get_server_time() { global::log_utils::init_log_with_trace(); let mut okx_swap_exchange: Box = test_new_exchange(ExchangeEnum::OkxSwap, SYMBOL).await; let okx_get_server_time = okx_swap_exchange.get_server_time().await; trace!(?okx_get_server_time); } // 测试获取账号信息 #[tokio::test] #[instrument(level = "TRACE")] async fn test_get_account() { global::log_utils::init_log_with_trace(); let mut okx_swap_exchange: Box = test_new_exchange(ExchangeEnum::OkxSwap, SYMBOL).await; let okx_get_account = okx_swap_exchange.get_account().await; trace!(?okx_get_account); } // 测试获取仓位信息 #[tokio::test] #[instrument(level = "TRACE")] async fn test_get_position() { global::log_utils::init_log_with_trace(); let mut okx_swap_exchange: Box = test_new_exchange(ExchangeEnum::OkxSwap, SYMBOL).await; let okx_get_position = okx_swap_exchange.get_position().await; trace!(?okx_get_position); } // 测试获取Ticker信息 #[tokio::test] #[instrument(level = "TRACE")] async fn test_get_ticker() { global::log_utils::init_log_with_trace(); let mut okx_swap_exchange: Box = test_new_exchange(ExchangeEnum::OkxSwap, SYMBOL).await; let okx_get_ticker = okx_swap_exchange.get_ticker().await; trace!(?okx_get_ticker); } // 测试获取Market信息 #[tokio::test] #[instrument(level = "TRACE")] async fn test_get_market() { global::log_utils::init_log_with_trace(); let mut okx_swap_exchange: Box = test_new_exchange(ExchangeEnum::OkxSwap, SYMBOL).await; let okx_get_market = okx_swap_exchange.get_market().await; trace!(?okx_get_market); } // 测试获取Order详情信息 #[tokio::test] #[instrument(level = "TRACE")] async fn test_get_order_detail() { global::log_utils::init_log_with_trace(); let mut okx_swap_exchange: Box = test_new_exchange(ExchangeEnum::OkxSwap, SYMBOL).await; let okx_get_order_detail = okx_swap_exchange.get_order_detail("", "999997").await; trace!(?okx_get_order_detail); } // 测试获取Order列表信息 #[tokio::test] #[instrument(level = "TRACE")] async fn test_get_orders_list() { global::log_utils::init_log_with_trace(); let mut okx_swap_exchange: Box = test_new_exchange(ExchangeEnum::OkxSwap, SYMBOL).await; let okx_get_orders_list = okx_swap_exchange.get_orders_list("active").await; trace!(?okx_get_orders_list); } // 测试下单 #[tokio::test] #[instrument(level = "TRACE")] async fn test_take_order() { global::log_utils::init_log_with_trace(); let mut okx_swap_exchange: Box = test_new_exchange(ExchangeEnum::OkxSwap, SYMBOL).await; let okx_take_order = okx_swap_exchange.take_order("999997", "kk", dec!(0.0901), dec!(100)).await; trace!(?okx_take_order); } // 测试撤销订单 #[tokio::test] #[instrument(level = "TRACE")] async fn test_cancel_order() { global::log_utils::init_log_with_trace(); let mut okx_swap_exchange: Box = test_new_exchange(ExchangeEnum::OkxSwap, SYMBOL).await; let okx_cancel_order = okx_swap_exchange.cancel_order("", "999998").await; trace!(?okx_cancel_order); } // 测试撤销订单 #[tokio::test] #[instrument(level = "TRACE")] async fn test_cancel_orders() { global::log_utils::init_log_with_trace(); let mut kucoin_swap_exchange: Box = test_new_exchange(ExchangeEnum::KucoinSwap, SYMBOL).await; let kucoin_cancel_orders = kucoin_swap_exchange.cancel_orders().await; trace!(?kucoin_cancel_orders); } // 测试设置持仓模式 #[tokio::test] #[instrument(level = "TRACE")] async fn test_set_dual_mode() { global::log_utils::init_log_with_trace(); let mut okx_swap_exchange: Box = test_new_exchange(ExchangeEnum::OkxSwap, SYMBOL).await; let okx_set_dual_mode = okx_swap_exchange.set_dual_mode("usdt", true).await; trace!(?okx_set_dual_mode); } // 测试设置杠杆 #[tokio::test] #[instrument(level = "TRACE")] async fn test_set_dual_leverage() { global::log_utils::init_log_with_trace(); let mut okx_swap_exchange: Box = test_new_exchange(ExchangeEnum::OkxSwap, SYMBOL).await; let okx_set_dual_leverage = okx_swap_exchange.set_dual_leverage("10").await; trace!(?okx_set_dual_leverage); }