|
|
@@ -124,5 +124,27 @@ pub async fn init(params: Params,
|
|
|
}
|
|
|
});
|
|
|
|
|
|
+ // 定时仓位检测
|
|
|
+ let markt_price_core_arc = core_arc.clone();
|
|
|
+ tokio::spawn(async move {
|
|
|
+ info!("rest仓位检测定时任务启动(5s)...");
|
|
|
+ loop {
|
|
|
+ tokio::time::sleep(Duration::from_secs(5)).await;
|
|
|
+
|
|
|
+ let mut core = markt_price_core_arc.lock().await;
|
|
|
+ match core.platform_rest.get_position().await {
|
|
|
+ Ok(pos) => {
|
|
|
+ if pos.len() > 0 {
|
|
|
+ info!("rest仓位更新...");
|
|
|
+ core.update_position(pos).await;
|
|
|
+ }
|
|
|
+ },
|
|
|
+ Err(err) => {
|
|
|
+ error!("rest持仓数据获取异常 {}", err);
|
|
|
+ }
|
|
|
+ };
|
|
|
+ }
|
|
|
+ });
|
|
|
+
|
|
|
return core_arc;
|
|
|
}
|