|
|
@@ -10,13 +10,14 @@ use exchanges::binance_swap_ws::{BinanceSubscribeType, BinanceSwapWs, BinanceWsT
|
|
|
use exchanges::coinex_swap_rest::CoinexSwapRest;
|
|
|
use exchanges::kucoin_swap_rest::KucoinSwapRest;
|
|
|
use exchanges::kucoin_swap_ws::{KucoinSubscribeType, KucoinSwapWs, KucoinWsType};
|
|
|
+use exchanges::okx_swap_rest::OkxSwapRest;
|
|
|
use exchanges::okx_swap_ws::{OkxSubscribeType, OkxSwapWs, OkxWsType};
|
|
|
use exchanges::proxy;
|
|
|
use exchanges::response_base::ResponseData;
|
|
|
|
|
|
-const ACCESS_KEY: &str = "";
|
|
|
-const SECRET_KEY: &str = "";
|
|
|
-const PASS_KEY: &str = "";
|
|
|
+const ACCESS_KEY: &str = "b812814f-b792-432c-9c65-44ebe3b8976b";
|
|
|
+const SECRET_KEY: &str = "D6AF4764DF5FDC74BF2CC88A4A8FD035";
|
|
|
+const PASS_KEY: &str = "Astest!@#1";
|
|
|
|
|
|
|
|
|
//ws-订阅公共频道信息
|
|
|
@@ -28,7 +29,7 @@ async fn ws_custom_subscribe_pu() {
|
|
|
let mut btree_map: BTreeMap<String, String> = BTreeMap::new();
|
|
|
btree_map.insert("access_key".to_string(), ACCESS_KEY.to_string());
|
|
|
btree_map.insert("secret_key".to_string(), SECRET_KEY.to_string());
|
|
|
- btree_map.insert("passphrase".to_string(), PASS_KEY.to_string());
|
|
|
+ btree_map.insert("pass_key".to_string(), PASS_KEY.to_string());
|
|
|
let (tx, mut rx) = channel(1024);
|
|
|
let mut ws = get_ws(btree_map, OkxWsType::Public, tx).await;
|
|
|
ws.set_subscribe(vec![
|
|
|
@@ -57,7 +58,6 @@ async fn ws_custom_subscribe_pu() {
|
|
|
#[tokio::test(flavor = "multi_thread", worker_threads = 2)]
|
|
|
async fn ws_custom_subscribe_bu() {
|
|
|
global::log_utils::init_log_with_trace();
|
|
|
-
|
|
|
}
|
|
|
|
|
|
//ws-订阅私有频道信息
|
|
|
@@ -70,7 +70,7 @@ async fn ws_custom_subscribe_pr() {
|
|
|
|
|
|
btree_map.insert("access_key".to_string(), ACCESS_KEY.to_string());
|
|
|
btree_map.insert("secret_key".to_string(), SECRET_KEY.to_string());
|
|
|
- btree_map.insert("passphrase".to_string(), PASS_KEY.to_string());
|
|
|
+ btree_map.insert("pass_key".to_string(), PASS_KEY.to_string());
|
|
|
|
|
|
let (tx, mut rx) = channel(1024);
|
|
|
let mut ws = get_ws(btree_map, OkxWsType::Private, tx).await;
|
|
|
@@ -78,7 +78,6 @@ async fn ws_custom_subscribe_pr() {
|
|
|
OkxSubscribeType::PrBalanceAndPosition,
|
|
|
OkxSubscribeType::PrAccount("USDT".to_string()),
|
|
|
OkxSubscribeType::PrOrders,
|
|
|
-
|
|
|
]);
|
|
|
|
|
|
let t1 = tokio::spawn(async move {
|
|
|
@@ -95,14 +94,14 @@ async fn ws_custom_subscribe_pr() {
|
|
|
try_join!(t1,t2).unwrap();
|
|
|
}
|
|
|
|
|
|
-
|
|
|
-//rest-用戶持倉
|
|
|
+//rest-订单查询
|
|
|
#[tokio::test]
|
|
|
-async fn rest_get_server_time_test() {
|
|
|
+async fn rest_get_order_test() {
|
|
|
global::log_utils::init_log_with_trace();
|
|
|
|
|
|
- let e = ResponseData::error("12".to_string(), "登陆参数错误!".to_string());
|
|
|
- println!("{}", e.to_string())
|
|
|
+ let mut ret = get_rest();
|
|
|
+ let req_data = ret.get_order("BTC-USDT".to_string(), "".to_string(), "".to_string()).await;
|
|
|
+ println!("okx--订单查询--{:?}", req_data);
|
|
|
}
|
|
|
|
|
|
|
|
|
@@ -111,14 +110,12 @@ async fn get_ws(btree_map: BTreeMap<String, String>, type_v: OkxWsType, tx: Send
|
|
|
ku_ws
|
|
|
}
|
|
|
|
|
|
-fn get_rest() -> CoinexSwapRest {
|
|
|
+fn get_rest() -> OkxSwapRest {
|
|
|
let mut btree_map: BTreeMap<String, String> = BTreeMap::new();
|
|
|
- // btree_map.insert("access_key".to_string(), ACCESS_KEY.to_string());
|
|
|
- // btree_map.insert("secret_key".to_string(), SECRET_KEY.to_string());
|
|
|
btree_map.insert("access_key".to_string(), ACCESS_KEY.to_string());
|
|
|
btree_map.insert("secret_key".to_string(), SECRET_KEY.to_string());
|
|
|
btree_map.insert("pass_key".to_string(), PASS_KEY.to_string());
|
|
|
|
|
|
- let mut co_exc = CoinexSwapRest::new(false, btree_map);
|
|
|
- co_exc
|
|
|
+ let mut okx_exc = OkxSwapRest::new(false, btree_map.clone());
|
|
|
+ okx_exc
|
|
|
}
|