Fixed selling coin problem
This commit is contained in:
parent
2d3b340123
commit
25b2c5ad51
|
|
@ -207,7 +207,7 @@ pub async fn limit_order_buy(
|
||||||
tif: TimeInForce,
|
tif: TimeInForce,
|
||||||
order_price: Decimal,
|
order_price: Decimal,
|
||||||
order_quantity: Decimal,
|
order_quantity: Decimal,
|
||||||
simul_used_usdt: Decimal,
|
used_usdt: Decimal,
|
||||||
simul_base_qty_fee_adjusted: &String,
|
simul_base_qty_fee_adjusted: &String,
|
||||||
client: &Client,
|
client: &Client,
|
||||||
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||||
|
|
@ -240,7 +240,7 @@ pub async fn limit_order_buy(
|
||||||
insert_value_container.push(server_epoch.to_string()); // transact_time
|
insert_value_container.push(server_epoch.to_string()); // transact_time
|
||||||
insert_value_container.push(element.close_time.to_string()); // close_time
|
insert_value_container.push(element.close_time.to_string()); // close_time
|
||||||
insert_value_container.push(String::from("SIMUL")); // status
|
insert_value_container.push(String::from("SIMUL")); // status
|
||||||
insert_value_container.push(simul_used_usdt.to_string()); // used_usdt
|
insert_value_container.push(used_usdt.to_string()); // used_usdt
|
||||||
insert_value_container.push(0.0.to_string()); // expected_get_usdt
|
insert_value_container.push(0.0.to_string()); // expected_get_usdt
|
||||||
insert_value_container.push(0.0.to_string()); // expected_usdt_profit
|
insert_value_container.push(0.0.to_string()); // expected_usdt_profit
|
||||||
insert_value_container.push(order_price.to_string()); // buy_price
|
insert_value_container.push(order_price.to_string()); // buy_price
|
||||||
|
|
@ -257,7 +257,7 @@ pub async fn limit_order_buy(
|
||||||
insert_records(&insert_table_name, &insert_columns, &insert_values).await;
|
insert_records(&insert_table_name, &insert_columns, &insert_values).await;
|
||||||
|
|
||||||
// reflect available_usdt in [asset_manage_announcement]
|
// reflect available_usdt in [asset_manage_announcement]
|
||||||
sub_available_usdt(simul_used_usdt).await;
|
sub_available_usdt(used_usdt).await;
|
||||||
} else {
|
} else {
|
||||||
// building URL and API-keys
|
// building URL and API-keys
|
||||||
let mut url = String::new();
|
let mut url = String::new();
|
||||||
|
|
@ -308,7 +308,6 @@ pub async fn limit_order_buy(
|
||||||
.unwrap();
|
.unwrap();
|
||||||
|
|
||||||
let body = res.text_with_charset("utf-8").await.unwrap();
|
let body = res.text_with_charset("utf-8").await.unwrap();
|
||||||
println!("limit_order_buy실행 body: {}", body);
|
|
||||||
// deserialize JSON and then insert record into table
|
// deserialize JSON and then insert record into table
|
||||||
let v = serde_json::from_str::<Value>(body.as_str());
|
let v = serde_json::from_str::<Value>(body.as_str());
|
||||||
|
|
||||||
|
|
@ -356,10 +355,10 @@ pub async fn limit_order_buy(
|
||||||
|
|
||||||
// reflect available_usdt in [asset_manage_announcement]
|
// reflect available_usdt in [asset_manage_announcement]
|
||||||
// sub_available_usdt(cummulative_quote_qty).await;
|
// sub_available_usdt(cummulative_quote_qty).await;
|
||||||
sub_available_usdt(simul_used_usdt).await;
|
sub_available_usdt(used_usdt).await;
|
||||||
println!(" buy coin 완료");
|
println!(" buy coin 완료");
|
||||||
} else {
|
} else {
|
||||||
insert_value_container.push(simul_used_usdt.to_string()); // used_usdt
|
insert_value_container.push(used_usdt.to_string()); // used_usdt
|
||||||
insert_value_container.push(0.0.to_string()); // expected_get_usdt
|
insert_value_container.push(0.0.to_string()); // expected_get_usdt
|
||||||
insert_value_container.push(0.0.to_string()); // expected_usdt_profit
|
insert_value_container.push(0.0.to_string()); // expected_usdt_profit
|
||||||
insert_value_container.push(0.0.to_string()); // buy_price
|
insert_value_container.push(0.0.to_string()); // buy_price
|
||||||
|
|
@ -369,7 +368,7 @@ pub async fn limit_order_buy(
|
||||||
insert_value_container.push(0.0.to_string()); // base_qty_fee_adjusted
|
insert_value_container.push(0.0.to_string()); // base_qty_fee_adjusted
|
||||||
|
|
||||||
// reflect available_usdt in [asset_manage_announcement]
|
// reflect available_usdt in [asset_manage_announcement]
|
||||||
sub_available_usdt(simul_used_usdt).await;
|
sub_available_usdt(used_usdt).await;
|
||||||
}
|
}
|
||||||
|
|
||||||
insert_value_container.push(0.0.to_string()); // pure_profit_percent
|
insert_value_container.push(0.0.to_string()); // pure_profit_percent
|
||||||
|
|
@ -566,19 +565,21 @@ pub async fn monitoring_filled_buy_order(
|
||||||
);
|
);
|
||||||
is_sell = true;
|
is_sell = true;
|
||||||
} else if element.maximum_profit_percent < target_profit_percent * 2.0
|
} else if element.maximum_profit_percent < target_profit_percent * 2.0
|
||||||
&& element.maximum_profit_percent >= target_profit_percent * 1.8
|
&& element.maximum_profit_percent >= target_profit_percent * 1.5
|
||||||
&& element.pure_profit_percent < target_profit_percent * 0.33
|
&& element.pure_profit_percent < target_profit_percent * 0.2
|
||||||
{
|
{
|
||||||
println!(
|
println!(
|
||||||
"Sold 33% target_profit_percent: {:.3}",
|
"Sold 20% target_profit_percent: {:.3}",
|
||||||
target_profit_percent * 0.33
|
target_profit_percent * 0.2
|
||||||
);
|
);
|
||||||
} else if server_epoch - element.transact_time > 12_600_000
|
is_sell = true;
|
||||||
|
} else if server_epoch - element.close_time > 12_600_000 // 30min * 7
|
||||||
{
|
{
|
||||||
println!(
|
println!(
|
||||||
"Sold time up {:.3}",
|
"Sold time up {:.3}",
|
||||||
element.pure_profit_percent
|
element.pure_profit_percent
|
||||||
);
|
);
|
||||||
|
is_sell = true;
|
||||||
}
|
}
|
||||||
|
|
||||||
// if element.maximum_profit_percent >= target_profit_percent * 1.0 {
|
// if element.maximum_profit_percent >= target_profit_percent * 1.0 {
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue
Block a user