Update filtering
This commit is contained in:
parent
eb44e21768
commit
1bd4b30418
|
|
@ -44,20 +44,20 @@ pub async fn list_up_for_buy(
|
|||
}
|
||||
remove_keys(&mut filtered_data, keys_to_remove).await;
|
||||
|
||||
// current Dema(30) < current Tema(10)
|
||||
// previous Dema(30) > previous Tema(10)
|
||||
// current Tema(10) < current Tema(5)
|
||||
// previous Tema(10) > previous Tema(5)
|
||||
let mut keys_to_remove: HashSet<String> = HashSet::new();
|
||||
let dema_30 = dema(30, &alldata.rt_price_30m_vec, &filtered_data).await?;
|
||||
let tema_10 = tema(10, &alldata.rt_price_30m_vec, &filtered_data).await?;
|
||||
let tema_5 = tema(5, &alldata.rt_price_30m_vec, &filtered_data).await?;
|
||||
let server_epoch = get_server_epoch().await;
|
||||
for (symbol, values) in &mut filtered_data {
|
||||
if let (Some(dema_vec), Some(tema_vec)) = (dema_30.get(symbol), tema_10.get(symbol)) {
|
||||
if dema_vec.len() > 2 && tema_vec.len() > 2 &&
|
||||
dema_vec.last().unwrap().close_time == tema_vec.last().unwrap().close_time &&
|
||||
dema_vec.last().unwrap().close_time > server_epoch &&
|
||||
tema_vec.last().unwrap().close_time > server_epoch {
|
||||
if dema_vec.last().unwrap().dema_value < tema_vec.last().unwrap().tema_value &&
|
||||
dema_vec[dema_vec.len()-2].dema_value > tema_vec[tema_vec.len()-2].tema_value {
|
||||
if let (Some(tema10_vec), Some(tema5_vec)) = (tema_10.get(symbol), tema_5.get(symbol)) {
|
||||
if tema10_vec.len() > 2 && tema5_vec.len() > 2 &&
|
||||
tema10_vec.last().unwrap().close_time == tema5_vec.last().unwrap().close_time &&
|
||||
tema10_vec.last().unwrap().close_time > server_epoch &&
|
||||
tema5_vec.last().unwrap().close_time > server_epoch {
|
||||
if tema10_vec.last().unwrap().tema_value < tema5_vec.last().unwrap().tema_value &&
|
||||
tema10_vec[tema10_vec.len()-2].tema_value > tema5_vec[tema5_vec.len()-2].tema_value {
|
||||
} else {
|
||||
keys_to_remove.insert(symbol.clone());
|
||||
}
|
||||
|
|
@ -212,19 +212,19 @@ pub async fn list_up_for_sell(
|
|||
filtered_symbols.insert(element.symbol.clone(), FilteredDataValue::new());
|
||||
}
|
||||
let supertrend_30m = supertrend(10, 2.0, true, &all_data.rt_price_30m_vec, &filtered_symbols).await?;
|
||||
let dema_30 = dema(30, &all_data.rt_price_30m_vec, &filtered_symbols).await?;
|
||||
let tema_10 = tema(10, &all_data.rt_price_30m_vec, &filtered_symbols).await?;
|
||||
let tema_5 = tema(50, &all_data.rt_price_30m_vec, &filtered_symbols).await?;
|
||||
for element in filled_buy_orders {
|
||||
let mut is_sell = false;
|
||||
let mut is_overturned = false;
|
||||
if element.used_usdt >= dec!(10.0) {
|
||||
if let (Some(dema_vec), Some(tema_vec)) = (dema_30.get(&element.symbol), tema_10.get(&element.symbol)) {
|
||||
if dema_vec.len() > 2 && tema_vec.len() > 2 &&
|
||||
dema_vec.last().unwrap().close_time == tema_vec.last().unwrap().close_time &&
|
||||
dema_vec.last().unwrap().close_time > server_epoch &&
|
||||
tema_vec.last().unwrap().close_time > server_epoch &&
|
||||
dema_vec.last().unwrap().dema_value > tema_vec.last().unwrap().tema_value &&
|
||||
dema_vec[dema_vec.len()-2].dema_value < tema_vec[tema_vec.len()-2].tema_value {
|
||||
if let (Some(tema10_vec), Some(tema5_vec)) = (tema_10.get(&element.symbol), tema_5.get(&element.symbol)) {
|
||||
if tema10_vec.len() > 2 && tema5_vec.len() > 2 &&
|
||||
tema10_vec.last().unwrap().close_time == tema5_vec.last().unwrap().close_time &&
|
||||
tema10_vec.last().unwrap().close_time > server_epoch &&
|
||||
tema5_vec.last().unwrap().close_time > server_epoch &&
|
||||
tema10_vec.last().unwrap().tema_value > tema5_vec.last().unwrap().tema_value &&
|
||||
tema10_vec[tema10_vec.len()-2].tema_value < tema5_vec[tema5_vec.len()-2].tema_value {
|
||||
is_overturned = true;
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user