htx_handle_test.rs 1.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556
  1. mod exchange_test;
  2. use tracing::{instrument};
  3. use exchanges::htx_swap_ws::HtxSwapSubscribeType;
  4. use standard::exchange::ExchangeEnum;
  5. use crate::exchange_test::{test_new_exchange_wss};
  6. const SYMBOL: &str = "USTC_USDT";
  7. // 测试订阅深度订阅
  8. #[tokio::test(flavor = "multi_thread", worker_threads = 4)]
  9. #[instrument(level = "TRACE")]
  10. async fn test_get_wss_depth() {
  11. global::log_utils::init_log_with_trace();
  12. let htx_subscribe_type = vec![
  13. HtxSwapSubscribeType::PuFuturesDepth
  14. ];
  15. test_new_exchange_wss(ExchangeEnum::HtxSwap, SYMBOL, htx_subscribe_type, "depth").await;
  16. }
  17. // 测试订阅Account信息
  18. #[tokio::test(flavor = "multi_thread", worker_threads = 4)]
  19. #[instrument(level = "TRACE")]
  20. async fn test_get_wss_account() {
  21. global::log_utils::init_log_with_trace();
  22. let htx_subscribe_type = vec![
  23. HtxSwapSubscribeType::PrFuturesBalances
  24. ];
  25. test_new_exchange_wss(ExchangeEnum::HtxSwap, SYMBOL, htx_subscribe_type, "account").await;
  26. }
  27. // 测试订阅Position信息
  28. #[tokio::test(flavor = "multi_thread", worker_threads = 4)]
  29. #[instrument(level = "TRACE")]
  30. async fn test_get_wss_position() {
  31. global::log_utils::init_log_with_trace();
  32. let htx_subscribe_type = vec![
  33. HtxSwapSubscribeType::PrFuturesPositions
  34. ];
  35. test_new_exchange_wss(ExchangeEnum::HtxSwap, SYMBOL, htx_subscribe_type, "position").await;
  36. }
  37. // 测试订阅Orders信息
  38. #[tokio::test(flavor = "multi_thread", worker_threads = 4)]
  39. #[instrument(level = "TRACE")]
  40. async fn test_get_wss_orders() {
  41. global::log_utils::init_log_with_trace();
  42. let htx_subscribe_type = vec![
  43. HtxSwapSubscribeType::PrFuturesOrders
  44. ];
  45. test_new_exchange_wss(ExchangeEnum::HtxSwap, SYMBOL, htx_subscribe_type, "orders").await;
  46. }