Move Client into function
This commit is contained in:
parent
f5ca681f9b
commit
38d5a305ad
|
|
@ -5,7 +5,7 @@ use crate::coin_health_check_team::request_others::{CoinPriceData, ExchangeInfo,
|
|||
use crate::database_control::*;
|
||||
use crate::decimal_funcs::{decimal, decimal_add, decimal_div, decimal_mul, decimal_sub};
|
||||
use crate::signal_association::signal_decision::*;
|
||||
use reqwest::Client;
|
||||
use reqwest::{Client, ClientBuilder};
|
||||
use rust_decimal::{prelude::FromPrimitive, prelude::ToPrimitive, Decimal, RoundingStrategy};
|
||||
use rust_decimal_macros::dec;
|
||||
use sqlx::FromRow;
|
||||
|
|
@ -113,13 +113,12 @@ pub struct MarketCapIndex {
|
|||
|
||||
// buy coin
|
||||
pub async fn buy_coin(
|
||||
client: &Client,
|
||||
exchange_info_vec: &Vec<ExchangeInfo>,
|
||||
trade_fee_vec: &Vec<TradeFee>,
|
||||
) -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
|
||||
let mut suggested_coin = get_suggested_coin_list().await;
|
||||
|
||||
if !suggested_coin.is_empty() {
|
||||
if !suggested_coin.is_empty() && exchange_info_vec.len() != 0 && trade_fee_vec.len() != 0 {
|
||||
let server_epoch = server_epoch().await;
|
||||
let mut filtered_suggested_coin_vec: Vec<&SuggestedCoin> = Vec::new();
|
||||
let mut is_exist_delete_symbol: bool = false;
|
||||
|
|
@ -132,7 +131,7 @@ pub async fn buy_coin(
|
|||
// 600_000 (600 secs = 10 mins)
|
||||
{
|
||||
filtered_suggested_coin_vec.push(element);
|
||||
} else if server_epoch - element.registered_server_epoch >= 1_800_000 {
|
||||
} else if server_epoch - element.registered_server_epoch >= 5_400_000 { // 30mins * 3
|
||||
delete_condition.push_str("id = ");
|
||||
delete_condition.push_str(element.id.to_string().as_str());
|
||||
delete_condition.push_str(" OR ");
|
||||
|
|
@ -153,6 +152,10 @@ pub async fn buy_coin(
|
|||
let mut expected_pure_profit_percent = 0.0;
|
||||
let insert_table_name = String::from("buy_ordered_coin_list");
|
||||
|
||||
let client = ClientBuilder::new()
|
||||
.timeout(tokio::time::Duration::from_millis(3000))
|
||||
.build()
|
||||
.unwrap();
|
||||
for element in &filtered_suggested_coin_vec {
|
||||
if is_tradable == true {
|
||||
let lot_step_size_result = exchange_info_vec
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user