From 0778575b747a56eb709f5df09561f1bd8c2b11bd Mon Sep 17 00:00:00 2001 From: Sik Yoon Date: Sat, 25 May 2024 02:57:20 +0900 Subject: [PATCH] Add checking boundary --- src/strategy_team/future_strategy_long.rs | 70 +++++++++++----------- src/strategy_team/future_strategy_short.rs | 70 +++++++++++----------- 2 files changed, 72 insertions(+), 68 deletions(-) diff --git a/src/strategy_team/future_strategy_long.rs b/src/strategy_team/future_strategy_long.rs index 82a694e..6fbeb70 100644 --- a/src/strategy_team/future_strategy_long.rs +++ b/src/strategy_team/future_strategy_long.rs @@ -153,41 +153,43 @@ pub async fn list_up_for_sell(alldata: &AllData) -> Result<(), Box server_epoch - && stoch_rsis_vec[stoch_rsis.len()-1].k < stoch_rsis_vec[stoch_rsis.len()-1].d - && stoch_rsis_vec[stoch_rsis.len()-2].k > stoch_rsis_vec[stoch_rsis.len()-2].d { - over_turned = true; - } - - // TODO: BNB 코인이 있으면 - // let base_qty_to_be_ordered = - // element.base_qty_ordered.round_dp_with_strategy( - // lot_step_size.normalize().scale(), - // RoundingStrategy::ToZero, - // ); - // TODO: BNB 코인이 없으면 - - if !element.current_price.is_zero() { - if element.pure_profit_percent >= 0.6 { - is_sell = true; - } else if element.pure_profit_percent <= -0.8 { - is_sell = true; - } else if server_epoch - element.transact_time >= (300_000) * 1 { - // time up selling - is_sell = true; - } else if over_turned == true { - is_sell = true; + if stoch_rsis_vec.len() > 10 { + if stoch_rsis_vec.last().unwrap().close_time > server_epoch + && stoch_rsis_vec[stoch_rsis.len()-1].k < stoch_rsis_vec[stoch_rsis.len()-1].d + && stoch_rsis_vec[stoch_rsis.len()-2].k > stoch_rsis_vec[stoch_rsis.len()-2].d { + over_turned = true; } - - if is_sell == true { - limit_order_close( - &element, - TimeInForce::Gtc, - element.current_price, - element.base_qty_ordered, - &client - ) - .await; + + // TODO: BNB 코인이 있으면 + // let base_qty_to_be_ordered = + // element.base_qty_ordered.round_dp_with_strategy( + // lot_step_size.normalize().scale(), + // RoundingStrategy::ToZero, + // ); + // TODO: BNB 코인이 없으면 + + if !element.current_price.is_zero() { + if element.pure_profit_percent >= 0.6 { + is_sell = true; + } else if element.pure_profit_percent <= -0.8 { + is_sell = true; + } else if server_epoch - element.transact_time >= (300_000) * 1 { + // time up selling + is_sell = true; + } else if over_turned == true { + is_sell = true; + } + + if is_sell == true { + limit_order_close( + &element, + TimeInForce::Gtc, + element.current_price, + element.base_qty_ordered, + &client + ) + .await; + } } } } diff --git a/src/strategy_team/future_strategy_short.rs b/src/strategy_team/future_strategy_short.rs index 5ccf93a..3c253cf 100644 --- a/src/strategy_team/future_strategy_short.rs +++ b/src/strategy_team/future_strategy_short.rs @@ -152,41 +152,43 @@ pub async fn list_up_for_sell(alldata: &AllData) -> Result<(), Box server_epoch - && stoch_rsis_vec[stoch_rsis.len()-1].k > stoch_rsis_vec[stoch_rsis.len()-1].d - && stoch_rsis_vec[stoch_rsis.len()-2].k < stoch_rsis_vec[stoch_rsis.len()-2].d { - over_turned = true; - } - - // TODO: BNB 코인이 있으면 - // let base_qty_to_be_ordered = - // element.base_qty_ordered.round_dp_with_strategy( - // lot_step_size.normalize().scale(), - // RoundingStrategy::ToZero, - // ); - // TODO: BNB 코인이 없으면 - - if !element.current_price.is_zero() { - if element.pure_profit_percent >= 0.6 { - is_sell = true; - } else if element.pure_profit_percent <= -0.8 { - is_sell = true; - } else if server_epoch - element.transact_time >= (300_000) * 1 { - // time up selling - is_sell = true; - } else if over_turned == true { - is_sell = true; + if stoch_rsis_vec.len() > 10 { + if stoch_rsis_vec.last().unwrap().close_time > server_epoch + && stoch_rsis_vec[stoch_rsis.len()-1].k > stoch_rsis_vec[stoch_rsis.len()-1].d + && stoch_rsis_vec[stoch_rsis.len()-2].k < stoch_rsis_vec[stoch_rsis.len()-2].d { + over_turned = true; } - - if is_sell == true { - limit_order_close( - &element, - TimeInForce::Gtc, - element.current_price, - element.base_qty_ordered, - &client - ) - .await; + + // TODO: BNB 코인이 있으면 + // let base_qty_to_be_ordered = + // element.base_qty_ordered.round_dp_with_strategy( + // lot_step_size.normalize().scale(), + // RoundingStrategy::ToZero, + // ); + // TODO: BNB 코인이 없으면 + + if !element.current_price.is_zero() { + if element.pure_profit_percent >= 0.6 { + is_sell = true; + } else if element.pure_profit_percent <= -0.8 { + is_sell = true; + } else if server_epoch - element.transact_time >= (300_000) * 1 { + // time up selling + is_sell = true; + } else if over_turned == true { + is_sell = true; + } + + if is_sell == true { + limit_order_close( + &element, + TimeInForce::Gtc, + element.current_price, + element.base_qty_ordered, + &client + ) + .await; + } } } }