소스 검색

仓位转向后不能平反方向的单,明天检查吧,今天累了。

skyffire 9 달 전
부모
커밋
1c199263ec
3개의 변경된 파일10개의 추가작업 그리고 17개의 파일을 삭제
  1. 2 2
      standard/src/bybit_swap.rs
  2. 1 1
      strategy/src/bybit_usdt_swap.rs
  3. 7 14
      strategy/src/strategy.rs

+ 2 - 2
standard/src/bybit_swap.rs

@@ -412,7 +412,7 @@ impl Platform for BybitSwap {
             "pd" => {
                 params["side"] = json!("Sell");
                 // 减仓
-                params["reduceOnly"] = json!(true);
+                // params["reduceOnly"] = json!(true);
             }
             "kk" => {
                 params["side"] = json!("Sell");
@@ -421,7 +421,7 @@ impl Platform for BybitSwap {
             "pk" => {
                 params["side"] = json!("Buy");
                 // 减仓
-                params["reduceOnly"] = json!(true);
+                // params["reduceOnly"] = json!(true);
                 // params["positionIdx"] = json!(2);
             }
             _ => { error!("下单参数错误"); }

+ 1 - 1
strategy/src/bybit_usdt_swap.rs

@@ -29,7 +29,7 @@ pub(crate) async fn reference_bybit_swap_run(is_shutdown_arc: Arc<AtomicBool>,
         ws.set_subscribe(vec![
             BybitSwapSubscribeType::PuTrade,
             BybitSwapSubscribeType::PuOrderBook1,
-            BybitSwapSubscribeType::PuLiquidation,
+            // BybitSwapSubscribeType::PuLiquidation,
             // BybitSwapSubscribeType::PuKline("1".to_string())
             // BybitSwapSubscribeType::PuTickers
         ]);

+ 7 - 14
strategy/src/strategy.rs

@@ -807,7 +807,7 @@ impl Strategy {
         // }
         // // debug!(?command);
 
-        if predictor.inventory > Decimal::ZERO && predictor.ask_delta != dec!(-2) && predictor.ask_delta != Decimal::ZERO {
+        if predictor.ask_delta != dec!(-2) && predictor.ask_delta != Decimal::ZERO {
             if pd_order_num == 0 {
                 let mut price = (short_lower + short_upper) * dec!(0.5);
                 // 不限制大小
@@ -827,7 +827,7 @@ impl Strategy {
                 // debug!(?command);
             }
         }
-        if predictor.inventory < Decimal::ZERO && predictor.bid_delta != dec!(-2) && predictor.bid_delta != Decimal::ZERO {
+        if predictor.bid_delta != dec!(-2) && predictor.bid_delta != Decimal::ZERO {
             if pk_order_num == 0 {
                 let mut price = (long_upper + long_lower) * dec!(0.5);
                 // 不限制大小
@@ -991,12 +991,9 @@ impl Strategy {
             let mut target_buy_price = predictor.optimal_bid_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 amount = if predictor.inventory < Decimal::ZERO {
-                predictor.pos_amount.abs()
-            } else {
-                let value = min(long_free_value, predictor.one_grid_order_value);
-                utils::fix_amount(value / self.mp, self.step_size)
-            };
+
+            let value = min(long_free_value, predictor.one_grid_order_value);
+            let amount = utils::fix_amount(value / self.mp, self.step_size);
 
             // 下单价值判定
             let amount_value = amount * target_buy_price;
@@ -1024,12 +1021,8 @@ impl Strategy {
             // target_sell_price = utils::clip(target_sell_price, self.bp * dec!(0.9995), self.ap * dec!(1.03));
             // 取消大小限制
             target_sell_price = utils::fix_price(target_sell_price, self.tick_size);
-            let amount = if predictor.inventory > Decimal::ZERO {
-                predictor.pos_amount.abs()
-            } else {
-                let value = min(short_free_value, predictor.one_grid_order_value);
-                utils::fix_amount(value / self.mp, self.step_size)
-            };
+            let value = min(short_free_value, predictor.one_grid_order_value);
+            let amount = utils::fix_amount(value / self.mp, self.step_size);
 
             // 下单价值不能太大,也不能太小
             let amount_value = amount * target_sell_price;