binance_handle_test.rs 3.0 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091
  1. mod exchange_test;
  2. use tracing::instrument;
  3. use exchanges::binance_swap_ws::BinanceSwapSubscribeType;
  4. use standard::exchange::ExchangeEnum;
  5. use crate::exchange_test::test_new_exchange_wss;
  6. const SYMBOL: &str = "BTC_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 binance_subscribe_type = vec![
  13. BinanceSwapSubscribeType::PuDepth20levels100ms,
  14. ];
  15. test_new_exchange_wss(ExchangeEnum::BinanceSwap, SYMBOL, binance_subscribe_type, "depth").await;
  16. }
  17. // 测试订阅Ticker信息
  18. #[tokio::test(flavor = "multi_thread", worker_threads = 4)]
  19. #[instrument(level = "TRACE")]
  20. async fn test_get_wss_ticker() {
  21. global::log_utils::init_log_with_trace();
  22. let binance_subscribe_type = vec![
  23. BinanceSwapSubscribeType::PuBookTicker,
  24. ];
  25. test_new_exchange_wss(ExchangeEnum::BinanceSwap, SYMBOL, binance_subscribe_type, "ticker").await;
  26. }
  27. // 测试订阅Trade信息
  28. #[tokio::test(flavor = "multi_thread", worker_threads = 4)]
  29. #[instrument(level = "TRACE")]
  30. async fn test_get_wss_trade() {
  31. global::log_utils::init_log_with_trace();
  32. let binance_subscribe_type = vec![
  33. BinanceSwapSubscribeType::PuAggTrade,
  34. ];
  35. test_new_exchange_wss(ExchangeEnum::BinanceSwap, SYMBOL, binance_subscribe_type, "trade").await;
  36. }
  37. // // 测试订阅Record信息
  38. // #[tokio::test(flavor = "multi_thread", worker_threads = 4)]
  39. // #[instrument(level = "TRACE")]
  40. // async fn test_get_wss_record() {
  41. // global::log_utils::init_log_with_trace();
  42. //
  43. // let binance_subscribe_type = vec![
  44. // BinanceSwapSubscribeType::PuDepth20levels100ms,
  45. // ];
  46. // test_new_exchange_wss(ExchangeEnum::BinanceSwap, SYMBOL, binance_subscribe_type, "record").await;
  47. // }
  48. // 测试订阅Account信息
  49. #[tokio::test(flavor = "multi_thread", worker_threads = 4)]
  50. #[instrument(level = "TRACE")]
  51. async fn test_get_wss_account() {
  52. global::log_utils::init_log_with_trace();
  53. let binance_subscribe_type = vec![
  54. BinanceSwapSubscribeType::PrBalance,
  55. ];
  56. test_new_exchange_wss(ExchangeEnum::BinanceSwap, SYMBOL, binance_subscribe_type, "account").await;
  57. }
  58. // 测试订阅Order信息
  59. #[tokio::test(flavor = "multi_thread", worker_threads = 4)]
  60. #[instrument(level = "TRACE")]
  61. async fn test_get_wss_order() {
  62. global::log_utils::init_log_with_trace();
  63. let binance_subscribe_type = vec![
  64. BinanceSwapSubscribeType::PrAccount,
  65. ];
  66. test_new_exchange_wss(ExchangeEnum::BinanceSwap, SYMBOL, binance_subscribe_type, "order").await;
  67. }
  68. // 测试订阅Position信息
  69. #[tokio::test(flavor = "multi_thread", worker_threads = 4)]
  70. #[instrument(level = "TRACE")]
  71. async fn test_get_wss_position() {
  72. global::log_utils::init_log_with_trace();
  73. let binance_subscribe_type = vec![
  74. BinanceSwapSubscribeType::PrPosition,
  75. ];
  76. test_new_exchange_wss(ExchangeEnum::BinanceSwap, SYMBOL, binance_subscribe_type, "position").await;
  77. }