Change calculation of target_profit_percent with using closure

This commit is contained in:
Sik Yoon 2023-08-15 13:05:11 +09:00
parent 4823b01d09
commit 90ea086a62

View File

@ -534,8 +534,10 @@ pub async fn monitoring_filled_buy_order(
let standard_deviation_amplitude = amplitude_variance.sqrt();
// let target_profit_percent = average_amplitude + (standard_deviation_amplitude * (average_ratio_amp_body));
let target_profit_percent =
(average_amplitude / 2.0) + (standard_deviation_amplitude * 1.5); // 2.0 sigma (recommand: 0.5 ~ 2.0(patient & greedy))
let target_profit_percent = |multiplier: f64| -> f64 {
((average_amplitude / 2.0) * multiplier) + (standard_deviation_amplitude * 2.0) // 2.0 sigma (recommand: 0.5 ~ 2.0(patient & greedy))
};
// if scoreboard_list.first().unwrap().pos_liquidation_signal == 1
// || scoreboard_list.first().unwrap().neg_liquidation_signal == 1
@ -556,23 +558,23 @@ pub async fn monitoring_filled_buy_order(
if element.pure_profit_percent >= 0.0 {
let mut is_sell = false;
if element.maximum_profit_percent >= target_profit_percent * 2.0
&& element.pure_profit_percent >= target_profit_percent * 2.0
if element.maximum_profit_percent >= target_profit_percent(2.0)
&& element.pure_profit_percent >= target_profit_percent(2.0)
{
println!(
"Selling {} 200% target_profit_percent: {:.3}",
element.symbol,
target_profit_percent * 2.0
target_profit_percent(2.0)
);
is_sell = true;
} else if element.maximum_profit_percent < target_profit_percent * 2.0
&& element.maximum_profit_percent >= target_profit_percent * 1.5
&& element.pure_profit_percent < target_profit_percent * 0.2
} else if element.maximum_profit_percent < target_profit_percent(2.0)
&& element.maximum_profit_percent >= target_profit_percent(1.5)
&& element.pure_profit_percent < target_profit_percent(0.2)
{
println!(
"selling {} 20% target_profit_percent: {:.3}",
element.symbol,
target_profit_percent * 0.2
target_profit_percent(0.2)
);
is_sell = true;
} else if server_epoch - element.close_time > 12_600_000 // 30min * 7
@ -630,7 +632,7 @@ pub async fn monitoring_filled_buy_order(
// limit_order_sell(&element, sell_price_ahead, base_qty_to_be_ordered, &client, &exchange_info_vec, &trade_fee_vec).await;
}
} else {
if element.pure_profit_percent < (target_profit_percent * -1.0) - 0.2 // -0.2 means about double trade fees.
if element.pure_profit_percent < target_profit_percent(-1.333) - 0.2 // -0.2 means about double trade fees.
{
println!(
"selling {} due to lower limit {:.3}",