Эх сурвалжийг харах

kucoin 下市单 和 取消开平仓记录限制

1. 增加kucoin 市/限价类型判断
2. 取消开/平仓距离限制判断
JiahengHe 1 жил өмнө
parent
commit
76ac04c6af

+ 3 - 0
standard/src/kucoin_swap.rs

@@ -401,6 +401,9 @@ impl Platform for KucoinSwap {
         });
         let size = (amount / ct_val).floor();
         params["size"] = json!(size);
+        if price.eq(&Decimal::ZERO){
+            params["type"] = json!("market");
+        }
         match origin_side {
             "kd" => {
                 params["side"] = json!("buy");

+ 10 - 4
strategy/src/strategy.rs

@@ -992,7 +992,8 @@ impl Strategy {
             if self.pos.long_pos > Decimal::ZERO {
                 if pd_order_num == 0 {
                     let mut price = (short_lower + short_upper) * dec!(0.5);
-                    price = utils::clip(price, self.bp * dec!(0.9995), self.ap * dec!(1.03));
+                    // 不限制大小
+                    // price = utils::clip(price, self.bp * dec!(0.9995), self.ap * dec!(1.03));
                     price = utils::fix_price(price, self.tick_size);
 
                     let order_client_id = utils::generate_client_id(Some(self.broker_id.clone()));
@@ -1025,7 +1026,8 @@ impl Strategy {
             if self.pos.short_pos > Decimal::ZERO {
                 if pk_order_num == 0 {
                     let mut price = (long_upper + long_lower) * dec!(0.5);
-                    price = utils::clip(price, self.bp * dec!(0.97), self.ap * dec!(1.0005));
+                    // 不限制大小
+                    // price = utils::clip(price, self.bp * dec!(0.97), self.ap * dec!(1.0005));
                     price = utils::fix_price(price, self.tick_size);
 
                     let order_client_id = utils::generate_client_id(Some(self.broker_id.clone()));
@@ -1200,7 +1202,9 @@ impl Strategy {
             // debug!(?buy_price_list);
             if buy_price_list.len() == 0 {
                 let mut target_buy_price = (long_upper + long_lower) * dec!(0.5);
-                target_buy_price = utils::clip(target_buy_price, self.bp * dec!(0.97), self.ap * dec!(1.0005));
+                // 取消大小限制
+                target_buy_price = target_buy_price;
+                // target_buy_price = utils::clip(target_buy_price, self.bp * dec!(0.97), self.ap * dec!(1.0005));
                 target_buy_price = utils::fix_price(target_buy_price, self.tick_size);
                 let value = min(one_hand_long_value, long_free_value);
                 let amount = utils::fix_amount(value / self.mp, self.step_size);
@@ -1227,7 +1231,9 @@ impl Strategy {
             // debug!(?sell_price_list);
             if sell_price_list.len() == 0 {
                 let mut target_sell_price = (short_lower + short_upper) * dec!(0.5);
-                target_sell_price = utils::clip(target_sell_price, self.bp * dec!(0.9995), self.ap * dec!(1.03));
+                // target_sell_price = utils::clip(target_sell_price, self.bp * dec!(0.9995), self.ap * dec!(1.03));
+                // 取消大小限制
+                target_sell_price = target_sell_price;
                 target_sell_price = utils::fix_price(target_sell_price, self.tick_size);
                 let value = min(one_hand_short_value, short_free_value);
                 let amount = utils::fix_amount(value / self.mp, self.step_size);