Add checking boundary

This commit is contained in:
Sik Yoon 2024-05-25 02:57:20 +09:00
parent a0a9f254e1
commit 0778575b74
2 changed files with 72 additions and 68 deletions

View File

@ -153,41 +153,43 @@ pub async fn list_up_for_sell(alldata: &AllData) -> Result<(), Box<dyn std::erro
if let Some(stoch_rsis_vec) = stoch_rsis.get(&element.symbol) {
let mut over_turned = false;
let mut is_sell = false;
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;
}
// 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;
}
}
}
}

View File

@ -152,41 +152,43 @@ pub async fn list_up_for_sell(alldata: &AllData) -> Result<(), Box<dyn std::erro
if let Some(stoch_rsis_vec) = stoch_rsis.get(&element.symbol) {
let mut over_turned = false;
let mut is_sell = false;
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;
}
// 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;
}
}
}
}