Change tema value

This commit is contained in:
Sik Yoon 2024-03-31 04:58:32 +09:00
parent 4c4d947b99
commit fc0aa80a2e

View File

@ -20,13 +20,13 @@ pub async fn list_up_for_buy(
filtered_data.insert(symbol.clone(), FilteredDataValue::new()); filtered_data.insert(symbol.clone(), FilteredDataValue::new());
} }
// current Tema(5) > current Tema(10) // current Tema(3) > current Tema(10)
let mut keys_to_remove: HashSet<String> = HashSet::new(); let mut keys_to_remove: HashSet<String> = HashSet::new();
let tema_5 = tema(5, &alldata.rt_price_1d_vec, &filtered_data).await?; let tema_3 = tema(3, &alldata.rt_price_1d_vec, &filtered_data).await?;
let tema_10 = tema(10, &alldata.rt_price_1d_vec, &filtered_data).await?; let tema_10 = tema(10, &alldata.rt_price_1d_vec, &filtered_data).await?;
let server_epoch = get_server_epoch().await; let server_epoch = get_server_epoch().await;
for (symbol, values) in &mut filtered_data { for (symbol, values) in &mut filtered_data {
if let (Some(tema5_vec), Some(tema10_vec)) = (tema_5.get(symbol), tema_10.get(symbol)) { if let (Some(tema5_vec), Some(tema10_vec)) = (tema_3.get(symbol), tema_10.get(symbol)) {
if tema5_vec.len() > 2 && tema10_vec.len() > 2 && if tema5_vec.len() > 2 && tema10_vec.len() > 2 &&
tema5_vec.last().unwrap().close_time == tema10_vec.last().unwrap().close_time && tema5_vec.last().unwrap().close_time == tema10_vec.last().unwrap().close_time &&
tema5_vec.last().unwrap().close_time > server_epoch && tema5_vec.last().unwrap().close_time > server_epoch &&
@ -215,11 +215,19 @@ pub async fn list_up_for_sell(
let lot_step_size = exchange_info.stepsize; let lot_step_size = exchange_info.stepsize;
let quote_commission_precision = exchange_info.quote_commission_precision; let quote_commission_precision = exchange_info.quote_commission_precision;
// TODO: BNB 코인이 있으면
let base_qty_to_be_ordered = let base_qty_to_be_ordered =
element.base_qty_ordered.round_dp_with_strategy( element.base_qty_ordered.round_dp_with_strategy(
lot_step_size.normalize().scale(), lot_step_size.normalize().scale(),
RoundingStrategy::ToZero, RoundingStrategy::ToZero,
); );
// TODO: BNB 코인이 없으면
// let base_qty_to_be_ordered =
// element.base_qty_fee_adjusted.round_dp_with_strategy(
// lot_step_size.normalize().scale(),
// RoundingStrategy::ToZero,
// );
let target_profit_percent = decimal_div(decimal_sub(element.target_price, element.buy_price), element.buy_price).to_f64().unwrap(); 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) if (element.is_long == 0 || element.is_long == 1)
&& !element.current_price.is_zero() && !element.current_price.is_zero()