|
|
@@ -8,7 +8,6 @@ use tracing::{info, trace};
|
|
|
use crate::http_tool::RestTool;
|
|
|
use crate::response_base::ResponseData;
|
|
|
use ring::hmac;
|
|
|
-use serde_json::json;
|
|
|
|
|
|
#[derive(Clone, Debug)]
|
|
|
pub struct OkxSwapRest {
|
|
|
@@ -177,6 +176,31 @@ impl OkxSwapRest {
|
|
|
data
|
|
|
}
|
|
|
|
|
|
+ //获取成交明细(近三个月)
|
|
|
+ pub async fn get_trade_fills_history(&mut self, inst_id: String, begin: String, end: String, limit: String) -> ResponseData {
|
|
|
+ let mut params = serde_json::json!({
|
|
|
+ "instType": "SWAP",
|
|
|
+ "instId":inst_id,
|
|
|
+ "limit":100,
|
|
|
+ });
|
|
|
+
|
|
|
+ if begin.len() > 0 {
|
|
|
+ params["begin"] = serde_json::json!(begin);
|
|
|
+ }
|
|
|
+ if end.len() > 0 {
|
|
|
+ params["end"] = serde_json::json!(end);
|
|
|
+ }
|
|
|
+ if limit.len() > 0 {
|
|
|
+ params["limit"] = serde_json::json!(limit);
|
|
|
+ }
|
|
|
+ let data = self.request("GET".to_string(),
|
|
|
+ "/api/v5".to_string(),
|
|
|
+ "/trade/fills-history".to_string(),
|
|
|
+ true,
|
|
|
+ params.to_string(),
|
|
|
+ ).await;
|
|
|
+ data
|
|
|
+ }
|
|
|
|
|
|
//合约-下单
|
|
|
pub async fn swap_order(&mut self, params: serde_json::Value) -> ResponseData {
|
|
|
@@ -248,22 +272,22 @@ impl OkxSwapRest {
|
|
|
let mut params = serde_json::json!({
|
|
|
});
|
|
|
if sprd_id.len() > 0 {
|
|
|
- params["sprdId"] = json!(sprd_id);
|
|
|
+ params["sprdId"] = serde_json::json!(sprd_id);
|
|
|
}
|
|
|
if ord_type.len() > 0 {
|
|
|
- params["ordType"] = json!(ord_type);
|
|
|
+ params["ordType"] = serde_json::json!(ord_type);
|
|
|
}
|
|
|
if state.len() > 0 {
|
|
|
- params["state"] = json!(state);
|
|
|
+ params["state"] = serde_json::json!(state);
|
|
|
}
|
|
|
if begin.len() > 0 {
|
|
|
- params["begin"] = json!(begin);
|
|
|
+ params["begin"] = serde_json::json!(begin);
|
|
|
}
|
|
|
if end.len() > 0 {
|
|
|
- params["end"] = json!(end);
|
|
|
+ params["end"] = serde_json::json!(end);
|
|
|
}
|
|
|
if limit.len() > 0 {
|
|
|
- params["limit"] = json!(limit);
|
|
|
+ params["limit"] = serde_json::json!(limit);
|
|
|
}
|
|
|
let data = self.request("GET".to_string(),
|
|
|
"/api/v5".to_string(),
|
|
|
@@ -286,22 +310,22 @@ impl OkxSwapRest {
|
|
|
let mut params = serde_json::json!({
|
|
|
});
|
|
|
if sprd_id.len() > 0 {
|
|
|
- params["sprdId"] = json!(sprd_id);
|
|
|
+ params["sprdId"] = serde_json::json!(sprd_id);
|
|
|
}
|
|
|
if trade_id.len() > 0 {
|
|
|
- params["tradeId"] = json!(trade_id);
|
|
|
+ params["tradeId"] = serde_json::json!(trade_id);
|
|
|
}
|
|
|
if ord_id.len() > 0 {
|
|
|
- params["ordId"] = json!(ord_id);
|
|
|
+ params["ordId"] = serde_json::json!(ord_id);
|
|
|
}
|
|
|
if begin.len() > 0 {
|
|
|
- params["begin"] = json!(begin);
|
|
|
+ params["begin"] = serde_json::json!(begin);
|
|
|
}
|
|
|
if end.len() > 0 {
|
|
|
- params["end"] = json!(end);
|
|
|
+ params["end"] = serde_json::json!(end);
|
|
|
}
|
|
|
if limit.len() > 0 {
|
|
|
- params["limit"] = json!(limit);
|
|
|
+ params["limit"] = serde_json::json!(limit);
|
|
|
}
|
|
|
let data = self.request("GET".to_string(),
|
|
|
"/api/v5".to_string(),
|