@@ -23,7 +23,6 @@ use v_utils::{log, trades::Timeframe};
2323/// * `symbol` - Trading symbol (Bybit format, e.g., "BTCUSDT")
2424/// * `side` - Order side ("Buy" or "Sell")
2525/// * `target_qty` - Total quantity to execute
26- /// * `qty_step` - Minimum quantity increment for the instrument
2726/// * `price_tick` - Minimum price increment for the instrument
2827/// * `duration` - Optional duration to spread the execution over
2928pub async fn execute_chase_limit (
@@ -32,11 +31,10 @@ pub async fn execute_chase_limit(
3231 symbol : & str ,
3332 side : & str ,
3433 target_qty : f64 ,
35- qty_step : f64 ,
3634 price_tick : f64 ,
3735 duration : Option < Timeframe > ,
3836) -> Result < f64 > {
39- log ! ( "Starting chase-limit execution for {} {} {}" , side , target_qty , symbol ) ;
37+ log ! ( "Starting chase-limit execution for {side } {target_qty } {symbol}" ) ;
4038
4139 // Calculate execution parameters based on duration
4240 let ( sleep_interval, end_time) = if let Some ( duration_tf) = duration {
@@ -56,6 +54,7 @@ pub async fn execute_chase_limit(
5654 let mut last_order_price: Option < f64 > = None ;
5755 let mut iteration = 0 ;
5856
57+ //LOOP: very bad interface from the old implementation. Shouldn't be done this way, - will transfer to implementation through protocol primitives
5958 loop {
6059 iteration += 1 ;
6160
@@ -134,7 +133,7 @@ pub async fn execute_chase_limit(
134133 _ => bail ! ( "Invalid side: {}" , side) ,
135134 } ;
136135
137- info ! ( "[{}] Market: bid={}, ask={}, target {} limit @ {}" , iteration , bid_price , ask_price , side , limit_price ) ;
136+ info ! ( "[{iteration }] Market: bid={bid_price }, ask={ask_price }, target {side } limit @ {limit_price}" ) ;
138137
139138 // Check if we should update the order
140139 // Only update if price changed significantly (to avoid unnecessary cancel-replace)
@@ -146,7 +145,7 @@ pub async fn execute_chase_limit(
146145 if should_update {
147146 // Cancel existing order if there is one
148147 if let Some ( ref old_order_link_id) = current_order_link_id {
149- log ! ( "[{}] Cancelling previous order to update price" , iteration ) ;
148+ log ! ( "[{iteration }] Cancelling previous order to update price" ) ;
150149
151150 let cancel_request = serde_json:: json!( {
152151 "category" : "linear" ,
@@ -162,10 +161,10 @@ pub async fn execute_chase_limit(
162161 }
163162
164163 // Create new orderLinkId for this order
165- let new_order_link_id = format ! ( "{}-{}" , base_order_link_id , iteration ) ;
164+ let new_order_link_id = format ! ( "{base_order_link_id }-{iteration}" ) ;
166165
167166 // Place new order at updated price
168- log ! ( "[{}] Placing {} limit order: {} @ {}" , iteration , side , target_qty , limit_price ) ;
167+ log ! ( "[{iteration }] Placing {side } limit order: {target_qty } @ {limit_price}" ) ;
169168
170169 let order_request = serde_json:: json!( {
171170 "category" : "linear" ,
@@ -183,15 +182,15 @@ pub async fn execute_chase_limit(
183182 if order_response. ret_code == 0 {
184183 current_order_link_id = Some ( new_order_link_id) ;
185184 last_order_price = Some ( limit_price) ;
186- info ! ( "[{}] Order placed successfully" , iteration ) ;
185+ info ! ( "[{iteration }] Order placed successfully" ) ;
187186 } else if order_response. ret_code == 10001 || order_response. ret_msg . contains ( "post only" ) || order_response. ret_msg . contains ( "would cross" ) {
188- info ! ( "[{}] PostOnly rejected (would cross spread): {}, will retry" , iteration , order_response. ret_msg) ;
187+ info ! ( "[{iteration }] PostOnly rejected (would cross spread): {}, will retry" , order_response. ret_msg) ;
189188 // Don't update last_order_price or current_order_link_id, will retry next iteration
190189 } else {
191190 log ! ( "Order placement warning: {} (code: {})" , order_response. ret_msg, order_response. ret_code) ;
192191 }
193192 } else {
194- info ! ( "[{}] Price unchanged, keeping order at {}" , iteration , last_order_price. unwrap_or( 0.0 ) ) ;
193+ info ! ( "[{iteration }] Price unchanged, keeping order at {}" , last_order_price. unwrap_or( 0.0 ) ) ;
195194 }
196195
197196 // Sleep before next iteration
@@ -204,6 +203,6 @@ pub async fn execute_chase_limit(
204203 }
205204 }
206205
207- log ! ( "Chase-limit execution completed for {} {}" , target_qty , symbol ) ;
206+ log ! ( "Chase-limit execution completed for {target_qty } {symbol}" ) ;
208207 Ok ( target_qty)
209208}
0 commit comments