Update filtering

This commit is contained in:
Sik Yoon 2024-06-08 00:33:13 +09:00
parent 73e72bdd3c
commit eae8a367dd
2 changed files with 72 additions and 68 deletions

View File

@ -243,38 +243,39 @@ pub async fn list_up_for_buy(
// remove_keys(&mut filtered_data, keys_to_remove).await; // remove_keys(&mut filtered_data, keys_to_remove).await;
// Heatmap volume: filtering close price with Extra High is over the previous candle from 30 previous candles // Heatmap volume: filtering close price with Extra High is over the previous candle from 30 previous candles
// let mut keys_to_remove: HashSet<String> = HashSet::new(); let mut keys_to_remove: HashSet<String> = HashSet::new();
// let heatmap_volumes = heatmap_volume( let heatmap_volumes = heatmap_volume(
// 30, 30,
// 30, 30,
// 4.0, 4.0,
// 1.5, 1.5,
// 0.5, 0.5,
// -0.5, -0.5,
// &filtered_data, &filtered_data,
// &alldata.rt_price_1m_vec, &alldata.rt_price_30m_vec,
// ) )
// .await?; .await?;
// let server_epoch = get_server_epoch().await;
// for (symbol, values) in &mut filtered_data { for (symbol, values) in &mut filtered_data {
// let mut do_buy = false; let mut do_buy = true;
// if let Some(heatmap_volume_vec) = heatmap_volumes.get(symbol) { if let (Some(heatmap_volume_vec), Some(rt_price_vec)) = (heatmap_volumes.get(symbol), alldata.rt_price_30m_vec.get(symbol)) {
// if heatmap_volume_vec.len() > 100 if heatmap_volume_vec.len() > 100
// && heatmap_volume_vec.last().unwrap().close_time > server_epoch && heatmap_volume_vec.last().unwrap().close_time > server_epoch
// && (heatmap_volume_vec.last().unwrap().heatmap_level == HeatMapLevel::ExtraHigh || heatmap_volume_vec.last().unwrap().heatmap_level == HeatMapLevel::High && ((heatmap_volume_vec.last().unwrap().heatmap_level == HeatMapLevel::ExtraHigh && rt_price_vec.iter().find(|x| x.close_time == heatmap_volume_vec.last().unwrap().close_time).is_some_and(|x| x.candle_type == CandleType::UP))
// || heatmap_volume_vec[heatmap_volume_vec.len()-2].heatmap_level == HeatMapLevel::ExtraHigh || heatmap_volume_vec[heatmap_volume_vec.len()-2].heatmap_level == HeatMapLevel::High || (heatmap_volume_vec[heatmap_volume_vec.len()-2].heatmap_level == HeatMapLevel::ExtraHigh && rt_price_vec.iter().find(|x| x.close_time == heatmap_volume_vec[heatmap_volume_vec.len()-2].close_time).is_some_and(|x| x.candle_type == CandleType::UP))
// || heatmap_volume_vec[heatmap_volume_vec.len()-3].heatmap_level == HeatMapLevel::ExtraHigh || heatmap_volume_vec[heatmap_volume_vec.len()-3].heatmap_level == HeatMapLevel::High || (heatmap_volume_vec[heatmap_volume_vec.len()-3].heatmap_level == HeatMapLevel::ExtraHigh && rt_price_vec.iter().find(|x| x.close_time == heatmap_volume_vec[heatmap_volume_vec.len()-3].close_time).is_some_and(|x| x.candle_type == CandleType::UP))
// || heatmap_volume_vec[heatmap_volume_vec.len()-4].heatmap_level == HeatMapLevel::ExtraHigh || heatmap_volume_vec[heatmap_volume_vec.len()-4].heatmap_level == HeatMapLevel::High) || (heatmap_volume_vec[heatmap_volume_vec.len()-4].heatmap_level == HeatMapLevel::ExtraHigh && rt_price_vec.iter().find(|x| x.close_time == heatmap_volume_vec[heatmap_volume_vec.len()-4].close_time).is_some_and(|x| x.candle_type == CandleType::UP))
// { || (heatmap_volume_vec[heatmap_volume_vec.len()-5].heatmap_level == HeatMapLevel::ExtraHigh) && rt_price_vec.iter().find(|x| x.close_time == heatmap_volume_vec[heatmap_volume_vec.len()-5].close_time).is_some_and(|x| x.candle_type == CandleType::UP))
// do_buy = true; {
// } do_buy = false;
// } }
}
// if do_buy == false { if do_buy == false {
// keys_to_remove.insert(symbol.clone()); keys_to_remove.insert(symbol.clone());
// } }
// } }
// remove_keys(&mut filtered_data, keys_to_remove).await; remove_keys(&mut filtered_data, keys_to_remove).await;
// let mut keys_to_remove: HashSet<String> = HashSet::new(); // let mut keys_to_remove: HashSet<String> = HashSet::new();
// let server_epoch = get_server_epoch().await; // let server_epoch = get_server_epoch().await;
@ -399,7 +400,7 @@ pub async fn list_up_for_sell(all_data: &AllData, futures_exchange_info_map: &Ha
// is_sell = true; // is_sell = true;
// } else // } else
if element.pure_profit_percent.is_sign_positive() && lr_vec.last().unwrap().r_squared >= 0.75 { if element.pure_profit_percent.is_sign_positive() && lr_vec.last().unwrap().r_squared >= 0.65 {
is_sell = true; is_sell = true;
} else if server_epoch - element.close_time > 900_000 } else if server_epoch - element.close_time > 900_000
&& lr_vec[lr_vec.len()-1].lr_value < lr_vec[lr_vec.len()-2].lr_value { && lr_vec[lr_vec.len()-1].lr_value < lr_vec[lr_vec.len()-2].lr_value {
@ -409,8 +410,9 @@ pub async fn list_up_for_sell(all_data: &AllData, futures_exchange_info_map: &Ha
&& lr_vec[lr_vec.len()-2].r_squared > lr_vec[lr_vec.len()-3].r_squared && lr_vec[lr_vec.len()-2].r_squared > lr_vec[lr_vec.len()-3].r_squared
&& lr_vec[lr_vec.len()-3].r_squared > lr_vec[lr_vec.len()-4].r_squared { && lr_vec[lr_vec.len()-3].r_squared > lr_vec[lr_vec.len()-4].r_squared {
is_sell = true; is_sell = true;
} else if server_epoch - element.close_time > 600_000 } else if element.pure_profit_percent <= -0.8 {
&& element.pure_profit_percent <= -0.8 { is_sell = true;
} else if element.pure_profit_percent >= 2.0 {
is_sell = true; is_sell = true;
} }

View File

@ -242,38 +242,39 @@ pub async fn list_up_for_buy(
// remove_keys(&mut filtered_data, keys_to_remove).await; // remove_keys(&mut filtered_data, keys_to_remove).await;
// Heatmap volume: filtering close price with Extra High is over the previous candle from 30 previous candles // Heatmap volume: filtering close price with Extra High is over the previous candle from 30 previous candles
// let mut keys_to_remove: HashSet<String> = HashSet::new(); let mut keys_to_remove: HashSet<String> = HashSet::new();
// let heatmap_volumes = heatmap_volume( let heatmap_volumes = heatmap_volume(
// 30, 30,
// 30, 30,
// 4.0, 4.0,
// 1.5, 1.5,
// 0.5, 0.5,
// -0.5, -0.5,
// &filtered_data, &filtered_data,
// &alldata.rt_price_1m_vec, &alldata.rt_price_30m_vec,
// ) )
// .await?; .await?;
// let server_epoch = get_server_epoch().await;
// for (symbol, values) in &mut filtered_data { for (symbol, values) in &mut filtered_data {
// let mut do_buy = false; let mut do_buy = true;
// if let Some(heatmap_volume_vec) = heatmap_volumes.get(symbol) { if let (Some(heatmap_volume_vec), Some(rt_price_vec)) = (heatmap_volumes.get(symbol), alldata.rt_price_30m_vec.get(symbol)) {
// if heatmap_volume_vec.len() > 100 if heatmap_volume_vec.len() > 100
// && heatmap_volume_vec.last().unwrap().close_time > server_epoch && heatmap_volume_vec.last().unwrap().close_time > server_epoch
// && (heatmap_volume_vec.last().unwrap().heatmap_level == HeatMapLevel::ExtraHigh || heatmap_volume_vec.last().unwrap().heatmap_level == HeatMapLevel::High && ((heatmap_volume_vec.last().unwrap().heatmap_level == HeatMapLevel::ExtraHigh && rt_price_vec.iter().find(|x| x.close_time == heatmap_volume_vec.last().unwrap().close_time).is_some_and(|x| x.candle_type == CandleType::DOWN))
// || heatmap_volume_vec[heatmap_volume_vec.len()-2].heatmap_level == HeatMapLevel::ExtraHigh || heatmap_volume_vec[heatmap_volume_vec.len()-2].heatmap_level == HeatMapLevel::High || (heatmap_volume_vec[heatmap_volume_vec.len()-2].heatmap_level == HeatMapLevel::ExtraHigh && rt_price_vec.iter().find(|x| x.close_time == heatmap_volume_vec[heatmap_volume_vec.len()-2].close_time).is_some_and(|x| x.candle_type == CandleType::DOWN))
// || heatmap_volume_vec[heatmap_volume_vec.len()-3].heatmap_level == HeatMapLevel::ExtraHigh || heatmap_volume_vec[heatmap_volume_vec.len()-3].heatmap_level == HeatMapLevel::High || (heatmap_volume_vec[heatmap_volume_vec.len()-3].heatmap_level == HeatMapLevel::ExtraHigh && rt_price_vec.iter().find(|x| x.close_time == heatmap_volume_vec[heatmap_volume_vec.len()-3].close_time).is_some_and(|x| x.candle_type == CandleType::DOWN))
// || heatmap_volume_vec[heatmap_volume_vec.len()-4].heatmap_level == HeatMapLevel::ExtraHigh || heatmap_volume_vec[heatmap_volume_vec.len()-4].heatmap_level == HeatMapLevel::High) || (heatmap_volume_vec[heatmap_volume_vec.len()-4].heatmap_level == HeatMapLevel::ExtraHigh && rt_price_vec.iter().find(|x| x.close_time == heatmap_volume_vec[heatmap_volume_vec.len()-4].close_time).is_some_and(|x| x.candle_type == CandleType::DOWN))
// { || (heatmap_volume_vec[heatmap_volume_vec.len()-5].heatmap_level == HeatMapLevel::ExtraHigh) && rt_price_vec.iter().find(|x| x.close_time == heatmap_volume_vec[heatmap_volume_vec.len()-5].close_time).is_some_and(|x| x.candle_type == CandleType::DOWN))
// do_buy = true; {
// } do_buy = false;
// } }
}
// if do_buy == false { if do_buy == false {
// keys_to_remove.insert(symbol.clone()); keys_to_remove.insert(symbol.clone());
// } }
// } }
// remove_keys(&mut filtered_data, keys_to_remove).await; remove_keys(&mut filtered_data, keys_to_remove).await;
// let mut keys_to_remove: HashSet<String> = HashSet::new(); // let mut keys_to_remove: HashSet<String> = HashSet::new();
// let server_epoch = get_server_epoch().await; // let server_epoch = get_server_epoch().await;
@ -404,7 +405,7 @@ pub async fn list_up_for_sell(all_data: &AllData, futures_exchange_info_map: &Ha
// } else if element.pure_profit_percent <= element.stoploss_percent { // } else if element.pure_profit_percent <= element.stoploss_percent {
// is_sell = true; // is_sell = true;
// } else // } else
if element.pure_profit_percent.is_sign_positive() && lr_vec.last().unwrap().r_squared >= 0.75 { if element.pure_profit_percent.is_sign_positive() && lr_vec.last().unwrap().r_squared >= 0.65 {
is_sell = true; is_sell = true;
} else if server_epoch - element.close_time > 900_000 } else if server_epoch - element.close_time > 900_000
&& lr_vec[lr_vec.len()-1].lr_value > lr_vec[lr_vec.len()-2].lr_value { && lr_vec[lr_vec.len()-1].lr_value > lr_vec[lr_vec.len()-2].lr_value {
@ -414,8 +415,9 @@ pub async fn list_up_for_sell(all_data: &AllData, futures_exchange_info_map: &Ha
&& lr_vec[lr_vec.len()-2].r_squared > lr_vec[lr_vec.len()-3].r_squared && lr_vec[lr_vec.len()-2].r_squared > lr_vec[lr_vec.len()-3].r_squared
&& lr_vec[lr_vec.len()-3].r_squared > lr_vec[lr_vec.len()-4].r_squared { && lr_vec[lr_vec.len()-3].r_squared > lr_vec[lr_vec.len()-4].r_squared {
is_sell = true; is_sell = true;
} else if server_epoch - element.close_time > 600_000 } else if element.pure_profit_percent <= -0.8 {
&& element.pure_profit_percent <= -0.8 { is_sell = true;
} else if element.pure_profit_percent >= 2.0 {
is_sell = true; is_sell = true;
} }