Change order of functions
This commit is contained in:
parent
12996a4d17
commit
819453aee5
|
|
@ -2,6 +2,7 @@ use crate::coex::assets_managing_team;
|
|||
use crate::coex::order_team;
|
||||
use crate::coex::order_team::{BuyOrderedCoinList, SellOrderedCoinList};
|
||||
use crate::coin_health_check_team::*;
|
||||
use crate::coin_health_check_team::request_others::ExchangeInfo;
|
||||
use crate::database_control::*;
|
||||
use crate::time_checking_team::{UserTime, *};
|
||||
use crate::RunningMode::*;
|
||||
|
|
@ -14,6 +15,7 @@ use sqlx::FromRow;
|
|||
use std::{io, io::Write, path::Path, process::Stdio};
|
||||
use tokio::{fs::*, io::ErrorKind, process::Command, task::JoinHandle, time::*};
|
||||
|
||||
|
||||
const STRATEGIST_NUMBER: u32 = 16;
|
||||
|
||||
pub async fn initialization() {
|
||||
|
|
@ -213,28 +215,6 @@ async fn initialize_database() {
|
|||
println!("Ok");
|
||||
}
|
||||
|
||||
// {
|
||||
// print!("table 'prev_valid_usdt_trades'...");
|
||||
// io::stdout().flush();
|
||||
|
||||
// let table_name = String::from("prev_valid_usdt_trades");
|
||||
// let exists_result = exists_table(&table_name).await;
|
||||
// let initial_table = vec![("id", "integer", Some("PK, AI")), ("symbol", "char(20)", None)];
|
||||
// let table_condition = None;
|
||||
|
||||
// if exists_result == false {
|
||||
// let mut result = new_table(&table_name, &initial_table, &table_condition).await;
|
||||
// if result.is_err() {
|
||||
// loop {
|
||||
// result = new_table(&table_name, &initial_table, &table_condition).await;
|
||||
// if result.is_ok(){ break; }
|
||||
// sleep(Duration::from_millis(10)).await;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// println!("Ok");
|
||||
// }
|
||||
|
||||
{
|
||||
print!("table 'stop_usdt_trades'...");
|
||||
io::stdout().flush();
|
||||
|
|
@ -259,6 +239,9 @@ async fn initialize_database() {
|
|||
}
|
||||
}
|
||||
}
|
||||
delete_all_rows(&table_name)
|
||||
.await
|
||||
.expect("Failed to delete rows!");
|
||||
println!("Ok");
|
||||
}
|
||||
|
||||
|
|
@ -286,33 +269,14 @@ async fn initialize_database() {
|
|||
}
|
||||
}
|
||||
}
|
||||
let mut valid_usdt_trade_vec_temp: Vec<String> = Vec::new();
|
||||
monitors::collect_valid_usde_trade(&mut valid_usdt_trade_vec_temp).await;
|
||||
delete_all_rows(&table_name)
|
||||
.await
|
||||
.expect("Failed to delete rows!");
|
||||
|
||||
monitors::initialize_valid_usde_trade().await;
|
||||
println!("Ok");
|
||||
}
|
||||
|
||||
// {
|
||||
// print!("table 'deceased_usdt_trades'...");
|
||||
// io::stdout().flush();
|
||||
|
||||
// let table_name = String::from("deceased_usdt_trades");
|
||||
// let exists_result = exists_table(&table_name).await;
|
||||
// let initial_table = vec![("id", "integer", Some("PK, AI")), ("symbol", "char(20)", None)];
|
||||
// let table_condition = None;
|
||||
|
||||
// if exists_result == false {
|
||||
// let mut result = new_table(&table_name, &initial_table, &table_condition).await;
|
||||
// if result.is_err() {
|
||||
// loop {
|
||||
// result = new_table(&table_name, &initial_table, &table_condition).await;
|
||||
// if result.is_ok(){ break; }
|
||||
// sleep(Duration::from_millis(10)).await;
|
||||
// }
|
||||
// }
|
||||
// }
|
||||
// println!("Ok");
|
||||
// }
|
||||
|
||||
{
|
||||
print!("table 'indices'...");
|
||||
io::stdout().flush();
|
||||
|
|
@ -786,6 +750,63 @@ async fn initialize_database() {
|
|||
println!("Ok");
|
||||
}
|
||||
|
||||
{
|
||||
// kelly_criterion
|
||||
print!("table 'kelly_criterion'...");
|
||||
io::stdout().flush();
|
||||
|
||||
let table_name = String::from("kelly_criterion");
|
||||
let exists_result = exists_table(&table_name).await;
|
||||
let initial_table = vec![
|
||||
("id", "integer", Some("PK, UN, AI")),
|
||||
("betting_rate", "double", None),
|
||||
("win_rate", "double", None),
|
||||
("lose_rate", "double", None),
|
||||
("profit_rate", "double", None),
|
||||
("loss_rate", "double", None),
|
||||
];
|
||||
let table_condition = None;
|
||||
|
||||
let insert_initial_columns = vec![
|
||||
"betting_rate",
|
||||
"win_rate",
|
||||
"lose_rate",
|
||||
"profit_rate",
|
||||
"loss_rate",
|
||||
];
|
||||
let insert_initial_value = vec![
|
||||
String::from("0.0"),
|
||||
String::from("0.0"),
|
||||
String::from("0.0"),
|
||||
String::from("0.0"),
|
||||
String::from("0.0"),
|
||||
];
|
||||
if exists_result == false {
|
||||
let mut result = new_table(&table_name, &initial_table, &table_condition).await;
|
||||
if result.is_err() {
|
||||
loop {
|
||||
result = new_table(&table_name, &initial_table, &table_condition).await;
|
||||
if result.is_ok() {
|
||||
break;
|
||||
}
|
||||
sleep(Duration::from_millis(10)).await;
|
||||
}
|
||||
}
|
||||
insert_one_record(&table_name, &insert_initial_columns, &insert_initial_value)
|
||||
.await
|
||||
.expect("Failed to insert initial row!");
|
||||
} else {
|
||||
delete_all_rows(&table_name)
|
||||
.await
|
||||
.expect("Failed to delete rows!");
|
||||
insert_one_record(&table_name, &insert_initial_columns, &insert_initial_value)
|
||||
.await
|
||||
.expect("Failed to insert initial row!");
|
||||
}
|
||||
|
||||
println!("Ok");
|
||||
}
|
||||
|
||||
{
|
||||
print!("table 'wallet'...");
|
||||
io::stdout().flush();
|
||||
|
|
@ -962,7 +983,7 @@ async fn initialize_database() {
|
|||
}
|
||||
|
||||
if RUNNING_MODE == SIMUL {
|
||||
assets_managing_team::add_extra_usdt(dec!(1700.0)).await;
|
||||
assets_managing_team::add_extra_usdt(dec!(2200.0)).await;
|
||||
assets_managing_team::update_current_total_usdt().await;
|
||||
} else {
|
||||
let mut table_name = String::new();
|
||||
|
|
@ -1001,63 +1022,6 @@ async fn initialize_database() {
|
|||
println!("Ok");
|
||||
}
|
||||
|
||||
{
|
||||
// kelly_criterion
|
||||
print!("table 'kelly_criterion'...");
|
||||
io::stdout().flush();
|
||||
|
||||
let table_name = String::from("kelly_criterion");
|
||||
let exists_result = exists_table(&table_name).await;
|
||||
let initial_table = vec![
|
||||
("id", "integer", Some("PK, UN, AI")),
|
||||
("betting_rate", "double", None),
|
||||
("win_rate", "double", None),
|
||||
("lose_rate", "double", None),
|
||||
("profit_rate", "double", None),
|
||||
("loss_rate", "double", None),
|
||||
];
|
||||
let table_condition = None;
|
||||
|
||||
let insert_initial_columns = vec![
|
||||
"betting_rate",
|
||||
"win_rate",
|
||||
"lose_rate",
|
||||
"profit_rate",
|
||||
"loss_rate",
|
||||
];
|
||||
let insert_initial_value = vec![
|
||||
String::from("50.0"), // initialize betting size: 50%
|
||||
String::from("0.0"),
|
||||
String::from("0.0"),
|
||||
String::from("0.0"),
|
||||
String::from("0.0"),
|
||||
];
|
||||
if exists_result == false {
|
||||
let mut result = new_table(&table_name, &initial_table, &table_condition).await;
|
||||
if result.is_err() {
|
||||
loop {
|
||||
result = new_table(&table_name, &initial_table, &table_condition).await;
|
||||
if result.is_ok() {
|
||||
break;
|
||||
}
|
||||
sleep(Duration::from_millis(10)).await;
|
||||
}
|
||||
}
|
||||
insert_one_record(&table_name, &insert_initial_columns, &insert_initial_value)
|
||||
.await
|
||||
.expect("Failed to insert initial row!");
|
||||
} else {
|
||||
delete_all_rows(&table_name)
|
||||
.await
|
||||
.expect("Failed to delete rows!");
|
||||
insert_one_record(&table_name, &insert_initial_columns, &insert_initial_value)
|
||||
.await
|
||||
.expect("Failed to insert initial row!");
|
||||
}
|
||||
|
||||
println!("Ok");
|
||||
}
|
||||
|
||||
{
|
||||
// filtered_indices
|
||||
print!("table 'filtered_indices'...");
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user