Update filtering
This commit is contained in:
parent
1e64873e4c
commit
64e6e92747
|
|
@ -121,6 +121,57 @@ pub async fn list_up_for_buy(
|
|||
}
|
||||
remove_keys(&mut filtered_data, keys_to_remove).await;
|
||||
|
||||
let mut keys_to_remove: HashSet<String> = HashSet::new();
|
||||
let server_epoch = get_server_epoch().await;
|
||||
for (symbol, values) in &mut filtered_data {
|
||||
let mut do_buy = false;
|
||||
let opclo_sample_length: usize = 60; // 15 candle samsples
|
||||
let mut target_profit_percent = 0.0;
|
||||
if let Some(price_1m_vec) = alldata.rt_price_1m_vec.get(symbol) {
|
||||
let vec_len = price_1m_vec.len();
|
||||
if let Some(candles) =
|
||||
price_1m_vec.get(vec_len - opclo_sample_length - 2..vec_len - 1)
|
||||
{
|
||||
let windows = candles.windows(2);
|
||||
let mut sum_amplitude_candles = 0.0;
|
||||
let mut sum_ratio_amp_body = 0.0;
|
||||
let mut average_amplitude = 0.0;
|
||||
|
||||
for window in windows {
|
||||
sum_amplitude_candles += ((window.last().unwrap().high_price
|
||||
- window.last().unwrap().low_price)
|
||||
* 100.0)
|
||||
/ window.first().unwrap().close_price;
|
||||
}
|
||||
let average_amplitude = sum_amplitude_candles / opclo_sample_length as f64; // percent unit
|
||||
let mut amplitude_variance = 0.0;
|
||||
|
||||
let windows = candles.windows(2);
|
||||
for window in windows {
|
||||
amplitude_variance += ((((window.last().unwrap().high_price
|
||||
- window.last().unwrap().low_price)
|
||||
* 100.0)
|
||||
/ window.first().unwrap().close_price)
|
||||
- average_amplitude)
|
||||
.powi(2);
|
||||
}
|
||||
amplitude_variance = amplitude_variance / (opclo_sample_length - 1) as f64;
|
||||
let standard_deviation_amplitude = amplitude_variance.sqrt();
|
||||
target_profit_percent =
|
||||
average_amplitude + (standard_deviation_amplitude * 0.5);
|
||||
|
||||
if target_profit_percent * 2.0 > 0.14 {
|
||||
do_buy = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if do_buy == false {
|
||||
keys_to_remove.insert(symbol.clone());
|
||||
}
|
||||
}
|
||||
remove_keys(&mut filtered_data, keys_to_remove).await;
|
||||
|
||||
// StochRSI (RSI_len: 30, StochRSI_len: 30, K: 2, D: 2) K_current < 70, K_prev < 70, K_prev_1 < 70
|
||||
// let server_epoch = get_server_epoch().await;
|
||||
// let mut keys_to_remove: HashSet<String> = HashSet::new();
|
||||
|
|
|
|||
|
|
@ -121,6 +121,57 @@ pub async fn list_up_for_buy(
|
|||
}
|
||||
remove_keys(&mut filtered_data, keys_to_remove).await;
|
||||
|
||||
let mut keys_to_remove: HashSet<String> = HashSet::new();
|
||||
let server_epoch = get_server_epoch().await;
|
||||
for (symbol, values) in &mut filtered_data {
|
||||
let mut do_buy = false;
|
||||
let opclo_sample_length: usize = 60; // 15 candle samsples
|
||||
let mut target_profit_percent = 0.0;
|
||||
if let Some(price_1m_vec) = alldata.rt_price_1m_vec.get(symbol) {
|
||||
let vec_len = price_1m_vec.len();
|
||||
if let Some(candles) =
|
||||
price_1m_vec.get(vec_len - opclo_sample_length - 2..vec_len - 1)
|
||||
{
|
||||
let windows = candles.windows(2);
|
||||
let mut sum_amplitude_candles = 0.0;
|
||||
let mut sum_ratio_amp_body = 0.0;
|
||||
let mut average_amplitude = 0.0;
|
||||
|
||||
for window in windows {
|
||||
sum_amplitude_candles += ((window.last().unwrap().high_price
|
||||
- window.last().unwrap().low_price)
|
||||
* 100.0)
|
||||
/ window.first().unwrap().close_price;
|
||||
}
|
||||
let average_amplitude = sum_amplitude_candles / opclo_sample_length as f64; // percent unit
|
||||
let mut amplitude_variance = 0.0;
|
||||
|
||||
let windows = candles.windows(2);
|
||||
for window in windows {
|
||||
amplitude_variance += ((((window.last().unwrap().high_price
|
||||
- window.last().unwrap().low_price)
|
||||
* 100.0)
|
||||
/ window.first().unwrap().close_price)
|
||||
- average_amplitude)
|
||||
.powi(2);
|
||||
}
|
||||
amplitude_variance = amplitude_variance / (opclo_sample_length - 1) as f64;
|
||||
let standard_deviation_amplitude = amplitude_variance.sqrt();
|
||||
target_profit_percent =
|
||||
average_amplitude + (standard_deviation_amplitude * 0.5);
|
||||
|
||||
if target_profit_percent * 2.0 > 0.14 {
|
||||
do_buy = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if do_buy == false {
|
||||
keys_to_remove.insert(symbol.clone());
|
||||
}
|
||||
}
|
||||
remove_keys(&mut filtered_data, keys_to_remove).await;
|
||||
|
||||
// StochRSI (RSI_len: 30, StochRSI_len: 30, K: 2, D: 2) K_current < 70, K_prev < 70, K_prev_1 < 70
|
||||
// let server_epoch = get_server_epoch().await;
|
||||
// let mut keys_to_remove: HashSet<String> = HashSet::new();
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user