|
|
@@ -74,11 +74,12 @@ async fn test_binance_swap_account() {
|
|
|
let self_params = binance_swap_exchange.get_self_params();
|
|
|
trace!(?self_exchange);
|
|
|
trace!(?self_is_colo);
|
|
|
- trace!(?self_params);
|
|
|
+ trace!("self_params={:?}",self_params);
|
|
|
}
|
|
|
|
|
|
// 测试获取Binance交易所现货实体
|
|
|
#[tokio::test]
|
|
|
+#[instrument(level = "TRACE")]
|
|
|
async fn test_binance_spot_account() {
|
|
|
global::log_utils::init_log_with_trace();
|
|
|
|
|
|
@@ -88,7 +89,7 @@ async fn test_binance_spot_account() {
|
|
|
let self_params = binance_spot_exchange.get_self_params();
|
|
|
trace!(?self_exchange);
|
|
|
trace!(?self_is_colo);
|
|
|
- trace!(?self_params);
|
|
|
+ trace!("self_params={:?}",self_params);
|
|
|
}
|
|
|
|
|
|
// 测试获取Gate交易所期货实体
|
|
|
@@ -104,146 +105,237 @@ async fn test_gate_swap_account() {
|
|
|
let self_market = gate_swap_exchange.get_self_market();
|
|
|
trace!(?self_exchange);
|
|
|
trace!(?self_is_colo);
|
|
|
- trace!(?self_params);
|
|
|
+ trace!("self_params={:?}",self_params);
|
|
|
trace!(?self_market);
|
|
|
}
|
|
|
|
|
|
// 测试获取Gate交易所现货实体
|
|
|
#[tokio::test]
|
|
|
+#[instrument(level = "TRACE")]
|
|
|
async fn test_gate_spot_account() {
|
|
|
+ global::log_utils::init_log_with_trace();
|
|
|
+
|
|
|
let gate_spot_exchange = test_new_exchange(ExchangeEnum::GateSpot).await;
|
|
|
- println!("exchange: {:?}", gate_spot_exchange.get_self_exchange());
|
|
|
- println!("is_colo: {:?}", gate_spot_exchange.get_self_is_colo());
|
|
|
- println!("params: {:?}", gate_spot_exchange.get_self_params());
|
|
|
+ let self_exchange = gate_spot_exchange.get_self_exchange();
|
|
|
+ let self_is_colo = gate_spot_exchange.get_self_is_colo();
|
|
|
+ trace!(?self_exchange);
|
|
|
+ trace!(?self_is_colo);
|
|
|
}
|
|
|
|
|
|
// 测试获取Gate交易所现货实体
|
|
|
#[tokio::test]
|
|
|
+#[instrument(level = "TRACE")]
|
|
|
async fn test_kucoin_swap_account() {
|
|
|
+ global::log_utils::init_log_with_trace();
|
|
|
+
|
|
|
let kucoin_swap_exchange = test_new_exchange(ExchangeEnum::KucoinSwap).await;
|
|
|
- println!("exchange: {:?}", kucoin_swap_exchange.get_self_exchange());
|
|
|
- println!("is_colo: {:?}", kucoin_swap_exchange.get_self_is_colo());
|
|
|
- println!("params: {:?}", kucoin_swap_exchange.get_self_params());
|
|
|
+ let self_exchange = kucoin_swap_exchange.get_self_exchange();
|
|
|
+ let self_is_colo = kucoin_swap_exchange.get_self_is_colo();
|
|
|
+ let self_params = kucoin_swap_exchange.get_self_params();
|
|
|
+ trace!(?self_exchange);
|
|
|
+ trace!(?self_is_colo);
|
|
|
+ trace!("self_params={:?}",self_params);
|
|
|
}
|
|
|
|
|
|
// 测试币对连接符号替换
|
|
|
#[tokio::test]
|
|
|
+#[instrument(level = "TRACE")]
|
|
|
async fn test_replace_symbol() {
|
|
|
- println!("test_replace_symbol: {}", utils::format_symbol("BTC_USDT".to_string(), "-"))
|
|
|
+ global::log_utils::init_log_with_trace();
|
|
|
+
|
|
|
+ let format_symbol = utils::format_symbol("BTC_USDT".to_string(), "-");
|
|
|
+ trace!(?format_symbol);
|
|
|
}
|
|
|
|
|
|
// 测试Binance期货K线推送
|
|
|
#[tokio::test]
|
|
|
+#[instrument(level = "TRACE")]
|
|
|
async fn test_get_account() {
|
|
|
- let binance_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::BinanceSwap).await;
|
|
|
- println!("binance_swap account:{:?}", binance_swap_exchange.get_account().await);
|
|
|
- let gate_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::GateSwap).await;
|
|
|
- println!("gate_swap account:{:?}", gate_swap_exchange.get_account().await);
|
|
|
- let kucoin_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::KucoinSwap).await;
|
|
|
- println!("kucoin_swap account:{:?}", kucoin_swap_exchange.get_account().await);
|
|
|
+ global::log_utils::init_log_with_trace();
|
|
|
+
|
|
|
+ let mut binance_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::BinanceSwap).await;
|
|
|
+ let binance_account = binance_swap_exchange.get_account().await;
|
|
|
+ trace!(?binance_account);
|
|
|
+ let mut gate_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::GateSwap).await;
|
|
|
+ let gate_account = gate_swap_exchange.get_account().await;
|
|
|
+ trace!(?gate_account);
|
|
|
+ let mut kucoin_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::KucoinSwap).await;
|
|
|
+ let kucoin_account = kucoin_swap_exchange.get_account().await;
|
|
|
+ trace!(?kucoin_account);
|
|
|
}
|
|
|
|
|
|
// 测试Gate 获取持仓信息
|
|
|
#[tokio::test]
|
|
|
+#[instrument(level = "TRACE")]
|
|
|
async fn test_gate_swap_get_position() {
|
|
|
- let gate_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::GateSwap).await;
|
|
|
- println!("gate_swap get_position:{:?}", gate_swap_exchange.get_position().await);
|
|
|
+ global::log_utils::init_log_with_trace();
|
|
|
+
|
|
|
+ let mut gate_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::GateSwap).await;
|
|
|
+ let gate_get_position = gate_swap_exchange.get_position().await;
|
|
|
+ trace!(?gate_get_position);
|
|
|
}
|
|
|
|
|
|
// 测试Gate 获取所有持仓信息
|
|
|
#[tokio::test]
|
|
|
+#[instrument(level = "TRACE")]
|
|
|
async fn test_gate_swap_get_positions() {
|
|
|
- let gate_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::GateSwap).await;
|
|
|
- println!("gate_swap get_positions:{:?}", gate_swap_exchange.get_positions().await);
|
|
|
+ global::log_utils::init_log_with_trace();
|
|
|
+
|
|
|
+ let mut gate_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::GateSwap).await;
|
|
|
+ let gate_get_positions = gate_swap_exchange.get_positions().await;
|
|
|
+ trace!(?gate_get_positions);
|
|
|
}
|
|
|
|
|
|
// 测试Gate获取Ticker信息
|
|
|
#[tokio::test]
|
|
|
+#[instrument(level = "TRACE")]
|
|
|
async fn test_gate_swap_get_ticker() {
|
|
|
- let gate_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::GateSwap).await;
|
|
|
- println!("gate_swap get_ticker:{:?}", gate_swap_exchange.get_ticker().await);
|
|
|
+ global::log_utils::init_log_with_trace();
|
|
|
+
|
|
|
+ let mut gate_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::GateSwap).await;
|
|
|
+ let gate_get_ticker = gate_swap_exchange.get_ticker().await;
|
|
|
+ trace!(?gate_get_ticker);
|
|
|
}
|
|
|
|
|
|
// 测试Gate获取Market信息
|
|
|
#[tokio::test]
|
|
|
+#[instrument(level = "TRACE")]
|
|
|
async fn test_gate_swap_get_market() {
|
|
|
- let gate_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::GateSwap).await;
|
|
|
- println!("gate_swap get_market:{:?}", gate_swap_exchange.get_market().await);
|
|
|
+ global::log_utils::init_log_with_trace();
|
|
|
+
|
|
|
+ let mut gate_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::GateSwap).await;
|
|
|
+ let gate_get_market = gate_swap_exchange.get_market().await;
|
|
|
+ trace!(?gate_get_market);
|
|
|
}
|
|
|
|
|
|
// 测试Gate获取Order详情信息
|
|
|
#[tokio::test]
|
|
|
+#[instrument(level = "TRACE")]
|
|
|
async fn test_gate_swap_get_order_detail() {
|
|
|
- let gate_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::GateSwap).await;
|
|
|
- println!("gate_swap get_order_detail:{:?}", gate_swap_exchange.get_order_detail("336321097375", "").await);
|
|
|
+ global::log_utils::init_log_with_trace();
|
|
|
+
|
|
|
+ let mut gate_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::GateSwap).await;
|
|
|
+ let gate_get_order_detail = gate_swap_exchange.get_order_detail("336321097375", "").await;
|
|
|
+ trace!(?gate_get_order_detail);
|
|
|
}
|
|
|
|
|
|
// 测试Gate获取Order列表信息
|
|
|
#[tokio::test]
|
|
|
+#[instrument(level = "TRACE")]
|
|
|
async fn test_gate_swap_get_orders_list() {
|
|
|
- let gate_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::GateSwap).await;
|
|
|
- println!("gate_swap get_orders_list:{:?}", gate_swap_exchange.get_orders_list("finished").await);
|
|
|
+ global::log_utils::init_log_with_trace();
|
|
|
+
|
|
|
+ let mut gate_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::GateSwap).await;
|
|
|
+ let gate_get_orders_list = gate_swap_exchange.get_orders_list("finished").await;
|
|
|
+ trace!(?gate_get_orders_list);
|
|
|
}
|
|
|
|
|
|
// 测试Gate 设置持仓模式
|
|
|
#[tokio::test]
|
|
|
+#[instrument(level = "TRACE")]
|
|
|
async fn test_set_dual_mode() {
|
|
|
- let gate_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::GateSwap).await;
|
|
|
- println!("gate_swap set_dual_mode:{:?}", gate_swap_exchange.set_dual_mode("usdt", true).await);
|
|
|
+ global::log_utils::init_log_with_trace();
|
|
|
+
|
|
|
+ let mut gate_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::GateSwap).await;
|
|
|
+ let gate_set_dual_mode = gate_swap_exchange.set_dual_mode("usdt", true).await;
|
|
|
+ trace!(?gate_set_dual_mode);
|
|
|
}
|
|
|
|
|
|
// 测试Gate 设置持仓模式
|
|
|
#[tokio::test]
|
|
|
+#[instrument(level = "TRACE")]
|
|
|
async fn test_set_dual_leverage() {
|
|
|
- let gate_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::GateSwap).await;
|
|
|
- println!("gate_swap set_dual_leverage:{:?}", gate_swap_exchange.set_dual_leverage("10").await);
|
|
|
+ global::log_utils::init_log_with_trace();
|
|
|
+
|
|
|
+ let mut gate_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::GateSwap).await;
|
|
|
+ let gate_set_dual_leverage = gate_swap_exchange.set_dual_leverage("10").await;
|
|
|
+ trace!(?gate_set_dual_leverage);
|
|
|
}
|
|
|
|
|
|
// 测试Gate 测试下单
|
|
|
#[tokio::test]
|
|
|
+#[instrument(level = "TRACE")]
|
|
|
async fn test_take_order() {
|
|
|
- let gate_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::GateSwap).await;
|
|
|
- println!("gate_swap take_order:{:?}", gate_swap_exchange.take_order("123", "kd", dec!(25000), dec!(0.0001)).await);
|
|
|
+ global::log_utils::init_log_with_trace();
|
|
|
+
|
|
|
+ let mut gate_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::GateSwap).await;
|
|
|
+ let gate_take_order = gate_swap_exchange.take_order("123", "kd", dec!(25000), dec!(0.0001)).await;
|
|
|
+ trace!(?gate_take_order);
|
|
|
}
|
|
|
|
|
|
// 测试Gate 撤销订单
|
|
|
#[tokio::test]
|
|
|
+#[instrument(level = "TRACE")]
|
|
|
async fn test_cancel_order() {
|
|
|
- let gate_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::GateSwap).await;
|
|
|
- println!("gate_swap cancel_order:{:?}", gate_swap_exchange.cancel_order("", "123").await);
|
|
|
+ global::log_utils::init_log_with_trace();
|
|
|
+
|
|
|
+ let mut gate_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::GateSwap).await;
|
|
|
+ let gate_cancel_order = gate_swap_exchange.cancel_order("", "123").await;
|
|
|
+ trace!(?gate_cancel_order);
|
|
|
}
|
|
|
|
|
|
// 测试kucoin 获取持仓信息
|
|
|
#[tokio::test]
|
|
|
+#[instrument(level = "TRACE")]
|
|
|
async fn test_kucoin_swap_get_position() {
|
|
|
- let kucoin_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::KucoinSwap).await;
|
|
|
- println!("kucoin_swap get_position:{:?}", kucoin_swap_exchange.get_position().await);
|
|
|
+ global::log_utils::init_log_with_trace();
|
|
|
+
|
|
|
+ let mut kucoin_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::KucoinSwap).await;
|
|
|
+ let kucoin_get_position = kucoin_swap_exchange.get_position().await;
|
|
|
+ trace!(?kucoin_get_position);
|
|
|
}
|
|
|
|
|
|
// 测试kucoin 获取所有持仓信息
|
|
|
#[tokio::test]
|
|
|
+#[instrument(level = "TRACE")]
|
|
|
async fn test_kucoin_swap_get_positions() {
|
|
|
- let kucoin_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::KucoinSwap).await;
|
|
|
- println!("kucoin_swap get_positions:{:?}", kucoin_swap_exchange.get_positions().await);
|
|
|
+ global::log_utils::init_log_with_trace();
|
|
|
+
|
|
|
+ let mut kucoin_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::KucoinSwap).await;
|
|
|
+ let kucoin_get_positions = kucoin_swap_exchange.get_positions().await;
|
|
|
+ trace!(?kucoin_get_positions);
|
|
|
}
|
|
|
|
|
|
// 测试kucoin 获取Ticker信息
|
|
|
#[tokio::test]
|
|
|
+#[instrument(level = "TRACE")]
|
|
|
async fn test_kucoin_swap_get_ticker() {
|
|
|
- let kucoin_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::KucoinSwap).await;
|
|
|
- println!("kucoin_swap get_ticker:{:?}", kucoin_swap_exchange.get_ticker().await);
|
|
|
+ global::log_utils::init_log_with_trace();
|
|
|
+
|
|
|
+ let mut kucoin_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::KucoinSwap).await;
|
|
|
+ let kucoin_get_ticker = kucoin_swap_exchange.get_ticker().await;
|
|
|
+ trace!(?kucoin_get_ticker);
|
|
|
}
|
|
|
|
|
|
// 测试kucoin 获取Market信息
|
|
|
#[tokio::test]
|
|
|
+#[instrument(level = "TRACE")]
|
|
|
async fn test_kucoin_swap_get_market() {
|
|
|
- let kucoin_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::KucoinSwap).await;
|
|
|
- println!("kucoin_swap get_market:{:?}", kucoin_swap_exchange.get_market().await);
|
|
|
+ global::log_utils::init_log_with_trace();
|
|
|
+
|
|
|
+ let mut kucoin_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::KucoinSwap).await;
|
|
|
+ let kucoin_get_market = kucoin_swap_exchange.get_market().await;
|
|
|
+ trace!(?kucoin_get_market);
|
|
|
}
|
|
|
|
|
|
// 测试kucoin 获取订单信息
|
|
|
#[tokio::test]
|
|
|
+#[instrument(level = "TRACE")]
|
|
|
async fn test_kucoin_swap_get_order_detail() {
|
|
|
- let kucoin_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::KucoinSwap).await;
|
|
|
- println!("kucoin_swap get_market:{:?}", kucoin_swap_exchange.get_order_detail("123", "").await);
|
|
|
+ global::log_utils::init_log_with_trace();
|
|
|
+
|
|
|
+ let mut kucoin_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::KucoinSwap).await;
|
|
|
+ let kucoin_get_order_detail = kucoin_swap_exchange.get_order_detail("123", "").await;
|
|
|
+ trace!(?kucoin_get_order_detail);
|
|
|
+}
|
|
|
+
|
|
|
+// 测试kucoin 获取订单列表
|
|
|
+#[tokio::test]
|
|
|
+#[instrument(level = "TRACE")]
|
|
|
+async fn test_kucoin_swap_get_orders_list() {
|
|
|
+ global::log_utils::init_log_with_trace();
|
|
|
+
|
|
|
+ let mut kucoin_swap_exchange: Box<dyn Platform> = test_new_exchange(ExchangeEnum::KucoinSwap).await;
|
|
|
+ let kucoin_get_orders_list = kucoin_swap_exchange.get_orders_list("").await;
|
|
|
+ trace!(?kucoin_get_orders_list);
|
|
|
}
|