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,6 +80,7 @@ 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) {
if current_price.is_normal() {
// update close_price // update close_price
rt_price_vec.last_mut().unwrap().close_price = *current_price; rt_price_vec.last_mut().unwrap().close_price = *current_price;
// update opclo_price // update opclo_price
@ -104,6 +105,7 @@ pub async fn update_realtime_price_data(
rt_price_vec.last_mut().unwrap().low_price = *current_price; rt_price_vec.last_mut().unwrap().low_price = *current_price;
} }
} }
}
} else { } else {
// for 30m, uses 1m candle // for 30m, uses 1m candle
// for 1d, uses 30m candle // for 1d, uses 30m candle
@ -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