Browse Source

rest订单成交均价修改,增加仓位推送打印

JiahengHe 1 year ago
parent
commit
03a8006ea3
2 changed files with 4 additions and 3 deletions
  1. 2 2
      standard/src/phemex_swap.rs
  2. 2 1
      strategy/src/phemex_usdt_swap.rs

+ 2 - 2
standard/src/phemex_swap.rs

@@ -274,7 +274,7 @@ impl Platform for PhemexSwap {
         let order_info = res_data_json.iter().find(|item| item["orderId"].as_str().unwrap() == order_id || item["clOrdId"] == custom_id);
         match order_info {
             None => {
-                error!("phemex_swap:获取order信息错误!\nget_order_detail:res_data={:?},order_id={},custom_id:{}", response, order_id, custom_id);
+                // error!("phemex_swap:获取order信息错误!\nget_order_detail:res_data={:?},order_id={},custom_id:{}", response, order_id, custom_id);
                 Err(Error::new(ErrorKind::Other, response.to_string()))
             }
             Some(order) => {
@@ -609,7 +609,7 @@ pub fn format_order_item(order: Value, ct_val: Decimal) -> Order {
     let price = Decimal::from_str(order["priceRp"].as_str().unwrap()).unwrap();
     let amount = Decimal::from_str(order["orderQtyRq"].as_str().unwrap()).unwrap() * ct_val;
     let deal_amount = Decimal::from_str(order["cumQtyRq"].as_str().unwrap()).unwrap() * ct_val;
-    let avg_price = Decimal::from_str(order["cumValueRv"].as_str().unwrap()).unwrap();
+    let avg_price = Decimal::from_str(order["cumValueRv"].as_str().unwrap()).unwrap()/deal_amount;
 
     let status = order["ordStatus"].as_str().unwrap();
     let custom_status;

+ 2 - 1
strategy/src/phemex_usdt_swap.rs

@@ -1,5 +1,5 @@
 use std::cmp::Ordering;
-use tracing::{error};
+use tracing::{error, info};
 use std::collections::BTreeMap;
 use std::sync::Arc;
 use std::sync::atomic::AtomicBool;
@@ -141,6 +141,7 @@ async fn on_private_data(core_arc_clone: Arc<Mutex<Core>>,
             let mut position_res = response.clone();
             position_res.data = position_res.data["positions_p"].clone();
             let positions = standard::handle_info::HandleSwapInfo::handle_position(PhemexSwap, &position_res, &ct_val);
+            info!("仓位推送:{:?}", positions);
             // 只要正在运行中币对的仓位信息
             let run_position: Vec<Position> = positions.into_iter().filter(|position| position.symbol.contains(&target_symbol)).collect();
             if run_position.len() > 0 {