diff --git a/src/strategy_team/strategy_008.rs b/src/strategy_team/strategy_008.rs index ebea405..d3806a9 100644 --- a/src/strategy_team/strategy_008.rs +++ b/src/strategy_team/strategy_008.rs @@ -90,7 +90,7 @@ pub async fn list_up_for_buy( values.current_price = current_price; values.closetime = rt_price_vec.last().unwrap().close_time; values.stoploss = band_value; - values.target_price = decimal_add(decimal_mul(decimal_sub(current_price, values.stoploss), dec!(3.0)), current_price); + values.target_price = decimal_add(decimal_mul(decimal_sub(current_price, values.stoploss), dec!(4.0)), current_price); } else if supertrend_vec.last().unwrap().area == SuperTrendArea::DOWN && band_value > current_price && band_value > open_price @@ -98,7 +98,7 @@ pub async fn list_up_for_buy( values.current_price = current_price; values.closetime = rt_price_vec.last().unwrap().close_time; values.stoploss = decimal_sub(open_price, decimal_sub(band_value, open_price)); - values.target_price = decimal_add(decimal_mul(decimal_sub(open_price, values.stoploss), dec!(3.0)), current_price); + values.target_price = decimal_add(decimal_mul(decimal_sub(open_price, values.stoploss), dec!(4.0)), current_price); } else { keys_to_remove.insert(symbol.clone()); @@ -214,7 +214,7 @@ pub async fn list_up_for_sell( } let supertrend_30m = supertrend(10, 2.0, true, &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?; + let tema_5 = tema(5, &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; @@ -262,8 +262,7 @@ pub async fn list_up_for_sell( RoundingStrategy::ToZero, ); let target_profit_percent = decimal_div(decimal_sub(element.target_price, element.buy_price), element.buy_price).to_f64().unwrap(); - if (element.is_long == 0 || element.is_long == 1) - && !element.current_price.is_zero() + if !element.current_price.is_zero() { if element.current_price <= element.stoploss { is_sell = true; @@ -272,36 +271,51 @@ pub async fn list_up_for_sell( } else if server_epoch - element.transact_time > (1_800_000) * 1 && is_overturned == true { is_sell = true; } else if server_epoch - element.transact_time > (1_800_000) * 5 && - (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (10.0/11.0) <= element.pure_profit_percent) { + (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (15.0/16.0) <= element.pure_profit_percent) { is_sell = true; } else if server_epoch - element.transact_time > (1_800_000) * 6 && - (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (9.0/11.0) <= element.pure_profit_percent) { + (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (14.0/16.0) <= element.pure_profit_percent) { is_sell = true; } else if server_epoch - element.transact_time > (1_800_000) * 7 && - (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (8.0/11.0) <= element.pure_profit_percent) { + (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (13.0/16.0) <= element.pure_profit_percent) { is_sell = true; } else if server_epoch - element.transact_time > (1_800_000) * 8 && - (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (7.0/11.0) <= element.pure_profit_percent) { + (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (12.0/16.0) <= element.pure_profit_percent) { is_sell = true; } else if server_epoch - element.transact_time > (1_800_000) * 9 && - (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (6.0/11.0) <= element.pure_profit_percent) { + (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (11.0/16.0) <= element.pure_profit_percent) { is_sell = true; } else if server_epoch - element.transact_time > (1_800_000) * 10 && - (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (5.0/11.0) <= element.pure_profit_percent) { + (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (10.0/16.0) <= element.pure_profit_percent) { is_sell = true; } else if server_epoch - element.transact_time > (1_800_000) * 11 && - (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (4.0/11.0) <= element.pure_profit_percent) { + (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (9.0/16.0) <= element.pure_profit_percent) { is_sell = true; } else if server_epoch - element.transact_time > (1_800_000) * 12 && - (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (3.0/11.0) <= element.pure_profit_percent) { + (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (8.0/16.0) <= element.pure_profit_percent) { is_sell = true; } else if server_epoch - element.transact_time > (1_800_000) * 13 && - (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (2.0/11.0) <= element.pure_profit_percent) { + (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (7.0/16.0) <= element.pure_profit_percent) { is_sell = true; } else if server_epoch - element.transact_time > (1_800_000) * 14 && - (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (1.0/11.0) <= element.pure_profit_percent) { + (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (6.0/16.0) <= element.pure_profit_percent) { is_sell = true; - } else if server_epoch - element.transact_time > (1_800_000) * 15 { // time up selling + } else if server_epoch - element.transact_time > (1_800_000) * 15 && + (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (5.0/16.0) <= element.pure_profit_percent) { + is_sell = true; + } else if server_epoch - element.transact_time > (1_800_000) * 16 && + (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (4.0/16.0) <= element.pure_profit_percent) { + is_sell = true; + } else if server_epoch - element.transact_time > (1_800_000) * 17 && + (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (3.0/16.0) <= element.pure_profit_percent) { + is_sell = true; + } else if server_epoch - element.transact_time > (1_800_000) * 18 && + (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (2.0/16.0) <= element.pure_profit_percent) { + is_sell = true; + } else if server_epoch - element.transact_time > (1_800_000) * 19 && + (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * (1.0/16.0) <= element.pure_profit_percent) { + is_sell = true; + } else if server_epoch - element.transact_time > (1_800_000) * 20 { // time up selling is_sell = true; } // TODO: sell_count가 1일 때 적용하기