New filtering

This commit is contained in:
Sik Yoon 2024-04-07 18:00:21 +09:00
parent 3b5ef82d44
commit 8322623878

View File

@ -3,7 +3,8 @@ use super::{
limit_order_sell, rsi, select_filled_buy_orders, stoch_rsi, supertrend, try_join_all, AllData,
Arc, Client, ClientBuilder, Decimal, EmaData, ExchangeInfo, FilteredDataValue, Mutex,
RealtimePriceData, RoundingStrategy, RsiData, StochRsiData, SupertrendData, TradeFee, update_record3, adx, AdxData, get_server_epoch, MacdData, ema_macd,
BollingerBandData, ToPrimitive, duplicate_filter, HashMap, HashSet, remove_keys, SuperTrendArea, SuperTrendSignal, get_current_price, dema, DemaData, tema, TemaData
BollingerBandData, ToPrimitive, duplicate_filter, HashMap, HashSet, remove_keys, SuperTrendArea, SuperTrendSignal, get_current_price, dema, DemaData, tema, TemaData,
heatmap_volume, HeatMapLevel, HeatmapVolumeData
};
// BUY conditions
@ -152,6 +153,37 @@ pub async fn list_up_for_buy(
}
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
let mut keys_to_remove: HashSet<String> = HashSet::new();
let heatmap_volumes = heatmap_volume(30, 30, 4.0, 2.5, 1.0, -0.5, &filtered_data, &alldata.rt_price_30m_vec).await?;
for (symbol, values) in &mut filtered_data {
if stoch_rsis.contains_key(symbol) {
let heatmap_volume_vec = heatmap_volumes.get(symbol).unwrap();
if heatmap_volume_vec.len() > 50 {
let heatmap_volume_trunc = heatmap_volume_vec.get(heatmap_volume_vec.len()-31..heatmap_volume_vec.len()-1).unwrap();
let windows = heatmap_volume_trunc.windows(2);
for slice in windows {
if slice[1].heatmap_level == HeatMapLevel::ExtraHigh {
if let (prev_candle_idx, current_candle_idx) = (
(&alldata.rt_price_30m_vec.get(symbol).unwrap().iter().position(|x| x.close_time == slice[0].close_time)).unwrap(),
(&alldata.rt_price_30m_vec.get(symbol).unwrap().iter().position(|x| x.close_time == slice[1].close_time)).unwrap()
) {
let prev_candle = &alldata.rt_price_30m_vec.get(symbol).unwrap()[prev_candle_idx];
let current_candle = &alldata.rt_price_30m_vec.get(symbol).unwrap()[current_candle_idx];
if current_candle.close_price > prev_candle.close_price ||
current_candle.close_price > prev_candle.open_price ||
current_candle.close_price > prev_candle.high_price ||
current_candle.close_price > prev_candle.low_price {
keys_to_remove.insert(symbol.clone());
}
}
}
}
}
}
}
remove_keys(&mut filtered_data, keys_to_remove).await;
// limit buy price: 0.25 * abs(이전 5 개 중 최대값 제거 한 opclo 값 평균 - 현재 open 값) + 현재 open 값 > current_price
let mut keys_to_remove: HashSet<String> = HashSet::new();
let server_epoch = get_server_epoch().await;