Add filtering

This commit is contained in:
Sik Yoon 2024-05-23 00:14:50 +09:00
parent 512bc46b39
commit 5937ee9be0

View File

@ -29,6 +29,30 @@ pub async fn list_up_for_buy(
for symbol in &alldata.valid_symbol_vec {
filtered_data.insert(symbol.clone(), FilteredDataValue::new());
}
let server_epoch = get_server_epoch().await;
// current Tema(30) < current Tema(60)
let mut keys_to_remove: HashSet<String> = HashSet::new();
let tema_15 = tema(15, &alldata.rt_price_1m_vec, &filtered_data).await?;
let tema_60 = tema(60, &alldata.rt_price_1m_vec, &filtered_data).await?;
let server_epoch = get_server_epoch().await;
let mut do_buy = false;
if let (Some(tema15_vec), Some(tema60_vec)) = (tema_15.get("BTCUSDT"), tema_60.get("BTCUSDT")) {
if tema15_vec.len() > 10
&& tema60_vec.len() > 10
&& tema15_vec.last().unwrap().close_time == tema60_vec.last().unwrap().close_time
&& tema15_vec.last().unwrap().close_time > server_epoch
&& tema60_vec.last().unwrap().close_time > server_epoch
{
if tema15_vec.last().unwrap().tema_value < tema60_vec.last().unwrap().tema_value {
do_buy = true;
}
}
}
if do_buy == false {
return Ok(());
}
// 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();
@ -96,9 +120,9 @@ pub async fn list_up_for_sell() -> Result<(), Box<dyn std::error::Error + Send +
// TODO: BNB 코인이 없으면
if !element.current_price.is_zero() {
if element.pure_profit_percent >= 1.0 {
if element.pure_profit_percent >= 0.6 {
is_sell = true;
} else if element.pure_profit_percent <= -1.0 {
} else if element.pure_profit_percent <= -0.8 {
is_sell = true;
} else if server_epoch - element.transact_time >= (1_800_000) * 1 {
// time up selling