diff --git a/src/value_estimation_team/datapoints/price_data.rs b/src/value_estimation_team/datapoints/price_data.rs index fe9a935..5fee5cd 100644 --- a/src/value_estimation_team/datapoints/price_data.rs +++ b/src/value_estimation_team/datapoints/price_data.rs @@ -80,28 +80,30 @@ pub async fn update_realtime_price_data( // reflect realtime data to the last element in rt_price_vec if interval.contains("1m") { if let Some(current_price) = read_price.get(element) { - // update close_price - rt_price_vec.last_mut().unwrap().close_price = *current_price; - // update opclo_price - rt_price_vec.last_mut().unwrap().opclo_price = - (rt_price_vec.last_mut().unwrap().open_price - + rt_price_vec.last_mut().unwrap().close_price) - / 2.0; - // update candle_type - if rt_price_vec.last_mut().unwrap().close_price - >= rt_price_vec.last_mut().unwrap().open_price - { - rt_price_vec.last_mut().unwrap().candle_type = CandleType::UP; - } else { - rt_price_vec.last_mut().unwrap().candle_type = CandleType::DOWN; - } - // update high_price - if rt_price_vec.last_mut().unwrap().high_price < *current_price { - rt_price_vec.last_mut().unwrap().high_price = *current_price; - } - // update low_price - if rt_price_vec.last_mut().unwrap().low_price > *current_price { - rt_price_vec.last_mut().unwrap().low_price = *current_price; + if current_price.is_normal() { + // update close_price + rt_price_vec.last_mut().unwrap().close_price = *current_price; + // update opclo_price + rt_price_vec.last_mut().unwrap().opclo_price = + (rt_price_vec.last_mut().unwrap().open_price + + rt_price_vec.last_mut().unwrap().close_price) + / 2.0; + // update candle_type + if rt_price_vec.last_mut().unwrap().close_price + >= rt_price_vec.last_mut().unwrap().open_price + { + rt_price_vec.last_mut().unwrap().candle_type = CandleType::UP; + } else { + rt_price_vec.last_mut().unwrap().candle_type = CandleType::DOWN; + } + // update high_price + if rt_price_vec.last_mut().unwrap().high_price < *current_price { + rt_price_vec.last_mut().unwrap().high_price = *current_price; + } + // update low_price + if rt_price_vec.last_mut().unwrap().low_price > *current_price { + rt_price_vec.last_mut().unwrap().low_price = *current_price; + } } } } else { @@ -181,9 +183,7 @@ pub async fn update_realtime_price_data( rt_price_vec.last_mut().unwrap().quote_asset_volume = update_quote_asset_volume; } - if update_closeprice != 0.0 - && !update_closeprice.is_nan() - && update_closeprice.is_finite() + if update_closeprice.is_normal() { rt_price_vec.last_mut().unwrap().close_price = update_closeprice; rt_price_vec.last_mut().unwrap().opclo_price = (update_closeprice