|
|
@@ -57,7 +57,7 @@ pub struct Predictor {
|
|
|
pub prev_save_time: Decimal,
|
|
|
pub init_time: Decimal,
|
|
|
pub fitting_delay: Decimal,
|
|
|
- pub prev_fitting_time: Decimal,
|
|
|
+ pub prev_fitting_time_vec: Vec<Decimal>,
|
|
|
|
|
|
pub params: Params,
|
|
|
|
|
|
@@ -130,6 +130,7 @@ impl Predictor {
|
|
|
prices: vec![vec![VecDeque::new(); 2]; params.ref_exchange.len()],
|
|
|
ks: vec![Decimal::ZERO; params.ref_exchange.len()],
|
|
|
bs: vec![Decimal::ZERO; params.ref_exchange.len()],
|
|
|
+ prev_fitting_time_vec: vec![Decimal::ZERO; params.ref_exchange.len()],
|
|
|
|
|
|
record_vec: VecDeque::new(),
|
|
|
|
|
|
@@ -162,7 +163,6 @@ impl Predictor {
|
|
|
init_time: Decimal::from(Utc::now().timestamp_millis()),
|
|
|
|
|
|
fitting_delay: Default::default(),
|
|
|
- prev_fitting_time: Default::default(),
|
|
|
params,
|
|
|
|
|
|
debug_sender: tx,
|
|
|
@@ -215,13 +215,17 @@ impl Predictor {
|
|
|
|
|
|
// 拟合,60s拟合一次
|
|
|
let before_fitting = Utc::now().timestamp_millis();
|
|
|
- if Decimal::from(before_fitting) - self.prev_fitting_time > dec!(60_000) || self.prices[mid_index][0].len() < 1000 {
|
|
|
+ if Decimal::from(before_fitting) - self.prev_fitting_time_vec[mid_index] > dec!(60_000) || self.prices[mid_index][0].len() < 1000 {
|
|
|
+ // if Decimal::from(before_fitting) - self.prev_fitting_time_vec[mid_index] > dec!(60_000) {
|
|
|
+ // info!("{}, {},", mid_index, self.prices[mid_index][0].len());
|
|
|
+ // }
|
|
|
+
|
|
|
if let Some((k, b)) = self.linear_least_squares(mid_index).await {
|
|
|
self.ks[mid_index] = k;
|
|
|
self.bs[mid_index] = b;
|
|
|
|
|
|
self.fitting_delay = Decimal::from(Utc::now().timestamp_millis() - before_fitting);
|
|
|
- self.prev_fitting_time = Decimal::from(before_fitting)
|
|
|
+ self.prev_fitting_time_vec[mid_index] = Decimal::from(before_fitting)
|
|
|
} else {
|
|
|
return;
|
|
|
}
|