Add kelly_criterion table
This commit is contained in:
parent
7d54ee50e1
commit
02099ac1f6
|
|
@ -998,6 +998,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("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'...");
|
||||
|
|
@ -1074,6 +1131,7 @@ async fn initialize_database() {
|
|||
("minimum_profit_percent", "double", None),
|
||||
("maximum_profit_percent", "double", None),
|
||||
("registerer", "smallint", Some("UN")),
|
||||
("is_long", "tinyint", Some("UN")),
|
||||
];
|
||||
// let table_condition = Some("ENGINE = MEMORY");
|
||||
let table_condition = None;
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user