diff --git a/src/strategy_team/strategy_006.rs b/src/strategy_team/strategy_006.rs index c7fcd1b..c96055e 100644 --- a/src/strategy_team/strategy_006.rs +++ b/src/strategy_team/strategy_006.rs @@ -8,7 +8,7 @@ use super::{ // BUY conditions // (1) 1d MACD (3, 7, 30): MACD_current - Signal_current < 0, MACD_prev - Signal_prev < MACD_current - Signal_current -// (2) stoch RSI(3, 3, 2, 2): K_prev < 10, K_prev < K_current +// (2) stoch RSI(30, 30, 2, 2): K_prev < 10, K_prev < K_current // stoploss: (update) supertrend(10, 1.5) lowerband // target price: (fixed) stoploss inverse x 3 times profit pub async fn list_up_for_buy( @@ -51,7 +51,7 @@ pub async fn list_up_for_buy( } remove_keys(&mut filtered_data, keys_to_remove).await; - // 1d StochRSI (RSI_len: 3, StochRSI_len: 3, K: 2, D: 2) K_prev < 10, K_prev < K_current + // 1d StochRSI (RSI_len: 30, StochRSI_len: 30, K: 3, D: 3) K_prev < 10, K_prev < K_current let mut keys_to_remove: HashSet = HashSet::new(); let stoch_rsis = stoch_rsi(30, 30, 3, 3, &alldata.rt_price_1d_vec, &filtered_data).await?; for (symbol, values) in &mut filtered_data { @@ -169,6 +169,7 @@ pub async fn list_up_for_sell( } let supertrend_1d = supertrend(14, 1.2, true, &all_data.rt_price_1d_vec, &filtered_symbols).await?; for element in filled_buy_orders { + let mut is_sell = false; let opclo_sample_length: usize = 10; // 10 candle samsples let mut target_profit_percent = 0.0; if let Some(price_1d_vec) = all_data @@ -198,8 +199,7 @@ pub async fn list_up_for_sell( let standard_deviation_amplitude = amplitude_variance.sqrt(); // let target_profit_percent = average_amplitude + (standard_deviation_amplitude * (average_ratio_amp_body)); - target_profit_percent = - 3.0 * (average_amplitude - standard_deviation_amplitude); + target_profit_percent = (average_amplitude - standard_deviation_amplitude); } } @@ -232,55 +232,19 @@ pub async fn list_up_for_sell( && !element.current_price.is_zero() { if element.current_price <= element.stoploss { - limit_order_sell( - &element, - element.current_price, - base_qty_to_be_ordered, - &client, - &exchange_info_map, - &trade_fee_map, - ) - .await; + is_sell = true; } else if element.current_price >= element.target_price { - limit_order_sell( - &element, - element.current_price, - base_qty_to_be_ordered, - &client, - &exchange_info_map, - &trade_fee_map, - ) - .await; - } else if element.pure_profit_percent >= 20.0 { - limit_order_sell( - &element, - element.current_price, - base_qty_to_be_ordered, - &client, - &exchange_info_map, - &trade_fee_map, - ) - .await; - } else if target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent <= element.pure_profit_percent { - limit_order_sell( - &element, - element.current_price, - base_qty_to_be_ordered, - &client, - &exchange_info_map, - &trade_fee_map, - ) - .await; - } else if server_epoch - element.transact_time > (86_400_000) * 7 { // 7 days timeout selling - limit_order_sell( - &element, - element.current_price, - base_qty_to_be_ordered, - &client, - &exchange_info_map, - &trade_fee_map, - ) - .await; + is_sell = true; + } else if element.pure_profit_percent >= target_profit_percent * 3.0 { // absolute sell profit percent + is_sell = true; + } else if server_epoch - element.transact_time > (86_400_000) * 5 && + (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * 2.0 <= element.pure_profit_percent){ // scaled selling with time up selling (5 days) + is_sell = true; + } else if server_epoch - element.transact_time > (86_400_000) * 6 && + (target_profit_percent != 0.0 && target_profit_percent.is_sign_positive() && target_profit_percent * 1.5 <= element.pure_profit_percent){ // scaled selling with time up selling (6 days) + is_sell = true; + } else if server_epoch - element.transact_time > (86_400_000) * 7 { // time up selling + is_sell = true; } // TODO: sell_count가 1일 때 적용하기 // else if (supertrend_vec @@ -306,6 +270,17 @@ pub async fn list_up_for_sell( // ) // .await; // } + if is_sell == true { + limit_order_sell( + &element, + element.current_price, + base_qty_to_be_ordered, + &client, + &exchange_info_map, + &trade_fee_map, + ) + .await; + } } } }