okx_handle_test.rs 2.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768
  1. mod exchange_test;
  2. use tracing::{instrument};
  3. use exchanges::okx_swap_ws::OkxSwapSubscribeType;
  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 okx_subscribe_type = vec![
  13. OkxSwapSubscribeType::PuBooks5
  14. ];
  15. test_new_exchange_wss(ExchangeEnum::OkxSwap, SYMBOL, okx_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 okx_subscribe_type = vec![
  23. OkxSwapSubscribeType::PuBooks5
  24. ];
  25. test_new_exchange_wss(ExchangeEnum::OkxSwap, SYMBOL, okx_subscribe_type, "ticker").await;
  26. }
  27. // 测试订阅Account信息
  28. #[tokio::test(flavor = "multi_thread", worker_threads = 4)]
  29. #[instrument(level = "TRACE")]
  30. async fn test_get_wss_account() {
  31. global::log_utils::init_log_with_trace();
  32. let okx_subscribe_type = vec![
  33. OkxSwapSubscribeType::PrAccount("USDT".to_string())
  34. ];
  35. test_new_exchange_wss(ExchangeEnum::OkxSwap, SYMBOL, okx_subscribe_type, "account").await;
  36. }
  37. // 测试订阅Position信息
  38. #[tokio::test(flavor = "multi_thread", worker_threads = 4)]
  39. #[instrument(level = "TRACE")]
  40. async fn test_get_wss_position() {
  41. global::log_utils::init_log_with_trace();
  42. let okx_subscribe_type = vec![
  43. OkxSwapSubscribeType::PrPositions
  44. ];
  45. test_new_exchange_wss(ExchangeEnum::OkxSwap, SYMBOL, okx_subscribe_type, "position").await;
  46. }
  47. // 测试订阅Orders信息
  48. #[tokio::test(flavor = "multi_thread", worker_threads = 4)]
  49. #[instrument(level = "TRACE")]
  50. async fn test_get_wss_orders() {
  51. global::log_utils::init_log_with_trace();
  52. let okx_subscribe_type = vec![
  53. OkxSwapSubscribeType::PrOrders
  54. ];
  55. test_new_exchange_wss(ExchangeEnum::OkxSwap, SYMBOL, okx_subscribe_type, "orders").await;
  56. }