Add checking value boundary

This commit is contained in:
Sik Yoon 2024-05-15 22:22:04 +09:00
parent fd6edef5a6
commit 7ee0abc465

View File

@ -80,28 +80,30 @@ pub async fn update_realtime_price_data(
// reflect realtime data to the last element in rt_price_vec // reflect realtime data to the last element in rt_price_vec
if interval.contains("1m") { if interval.contains("1m") {
if let Some(current_price) = read_price.get(element) { if let Some(current_price) = read_price.get(element) {
// update close_price if current_price.is_normal() {
rt_price_vec.last_mut().unwrap().close_price = *current_price; // update close_price
// update opclo_price rt_price_vec.last_mut().unwrap().close_price = *current_price;
rt_price_vec.last_mut().unwrap().opclo_price = // update opclo_price
(rt_price_vec.last_mut().unwrap().open_price rt_price_vec.last_mut().unwrap().opclo_price =
+ rt_price_vec.last_mut().unwrap().close_price) (rt_price_vec.last_mut().unwrap().open_price
/ 2.0; + rt_price_vec.last_mut().unwrap().close_price)
// update candle_type / 2.0;
if rt_price_vec.last_mut().unwrap().close_price // update candle_type
>= rt_price_vec.last_mut().unwrap().open_price 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::UP;
rt_price_vec.last_mut().unwrap().candle_type = CandleType::DOWN; } 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 { // update high_price
rt_price_vec.last_mut().unwrap().high_price = *current_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 { // update low_price
rt_price_vec.last_mut().unwrap().low_price = *current_price; if rt_price_vec.last_mut().unwrap().low_price > *current_price {
rt_price_vec.last_mut().unwrap().low_price = *current_price;
}
} }
} }
} else { } else {
@ -181,9 +183,7 @@ pub async fn update_realtime_price_data(
rt_price_vec.last_mut().unwrap().quote_asset_volume = rt_price_vec.last_mut().unwrap().quote_asset_volume =
update_quote_asset_volume; update_quote_asset_volume;
} }
if update_closeprice != 0.0 if update_closeprice.is_normal()
&& !update_closeprice.is_nan()
&& update_closeprice.is_finite()
{ {
rt_price_vec.last_mut().unwrap().close_price = update_closeprice; rt_price_vec.last_mut().unwrap().close_price = update_closeprice;
rt_price_vec.last_mut().unwrap().opclo_price = (update_closeprice rt_price_vec.last_mut().unwrap().opclo_price = (update_closeprice