Quellcode durchsuchen

bug修复完毕,能上路跑一跑了

skyfffire vor 2 Wochen
Ursprung
Commit
469c6ed70e
2 geänderte Dateien mit 9 neuen und 5 gelöschten Zeilen
  1. 3 3
      src/exchange/extended_rest_client.rs
  2. 6 2
      src/strategy.rs

+ 3 - 3
src/exchange/extended_rest_client.rs

@@ -196,7 +196,7 @@ impl ExtendedRestClient {
         ).await
     }
 
-    pub async fn post_order(&mut self, order_type: &str, side: &str, qty: &str, price: &str) -> Result<Response> {
+    pub async fn post_order(&mut self, order_type: &str, side: &str, qty: &str, price: &str, reduce_only: bool) -> Result<Response> {
         let account = self.account.clone().ok_or_else(|| anyhow!("请将账户传入再进行下单操作"))?;
 
         // 时间戳处理
@@ -342,7 +342,7 @@ impl ExtendedRestClient {
             "fee": total_fee_rate.to_string(),
             "nonce": nonce,
             "postOnly": false,
-            "reduceOnly": false,
+            "reduceOnly": reduce_only,
             "settlement": settlement,
             "selfTradeProtectionLevel": self_trade_protection_level,
         });
@@ -574,7 +574,7 @@ mod tests {
     async fn test_create_order() {
         let _guard = setup_logging().unwrap();
         let mut client = get_client().await;
-        let response_result = client.post_order("LIMIT", "BUY", "0.0001", "100000").await;
+        let response_result = client.post_order("LIMIT", "BUY", "0.0001", "100000", false).await;
 
         match response_result {
             Ok(response) => {

+ 6 - 2
src/strategy.rs

@@ -259,7 +259,9 @@ impl Strategy {
             "LIMIT",
             "BUY",
             quantity.to_string().as_str(),
-            price.to_string().as_str()).await;
+            price.to_string().as_str(),
+            false,
+        ).await;
 
         // 解析下单结果并返回
         self.match_create_order_result(&create_result)
@@ -275,7 +277,9 @@ impl Strategy {
             "MARKET",
             "SELL",
             quantity.to_string().as_str(),
-            price.to_string().as_str()).await;
+            price.to_string().as_str(),
+            true,
+        ).await;
 
         // 解析下单结果并返回
         self.match_create_order_result(&create_result)