|
@@ -1,6 +1,4 @@
|
|
|
use std::collections::BTreeMap;
|
|
use std::collections::BTreeMap;
|
|
|
-use std::fs::File;
|
|
|
|
|
-use std::io::BufReader;
|
|
|
|
|
use std::str::FromStr;
|
|
use std::str::FromStr;
|
|
|
use chrono::NaiveDateTime;
|
|
use chrono::NaiveDateTime;
|
|
|
use rust_decimal::Decimal;
|
|
use rust_decimal::Decimal;
|
|
@@ -9,7 +7,6 @@ use serde_json::json;
|
|
|
use tracing::{error, info};
|
|
use tracing::{error, info};
|
|
|
use crate::export_template;
|
|
use crate::export_template;
|
|
|
use crate::http::request::Response;
|
|
use crate::http::request::Response;
|
|
|
-use crate::swap_bybit::bybit_swap_rest_utils::BybitSwapRest;
|
|
|
|
|
use crate::swap_gate::gate_swap_rest_utils::GateSwapRest;
|
|
use crate::swap_gate::gate_swap_rest_utils::GateSwapRest;
|
|
|
use crate::utils::utils;
|
|
use crate::utils::utils;
|
|
|
use crate::utils::utils::BalanceConfigInfo;
|
|
use crate::utils::utils::BalanceConfigInfo;
|
|
@@ -32,9 +29,9 @@ pub async fn export_balance(config_info: BalanceConfigInfo) {
|
|
|
|
|
|
|
|
let mut count_balance_info = vec![];
|
|
let mut count_balance_info = vec![];
|
|
|
let mut count_time_list = vec![];
|
|
let mut count_time_list = vec![];
|
|
|
- let mut history_balance: serde_json::Value = utils::get_json_file("./config_history_balance.json");
|
|
|
|
|
|
|
+ let history_balance: serde_json::Value = utils::get_json_file("./config_history_balance.json");
|
|
|
let history_start_time = history_balance["start_time"].as_i64().unwrap_or(0);
|
|
let history_start_time = history_balance["start_time"].as_i64().unwrap_or(0);
|
|
|
- let mut history_end_time = history_balance["end_time"].as_i64().unwrap_or(0);
|
|
|
|
|
|
|
+ let history_end_time = history_balance["end_time"].as_i64().unwrap_or(0);
|
|
|
if history_end_time < end_time {
|
|
if history_end_time < end_time {
|
|
|
for exchange in config_info.exchanges.clone() {
|
|
for exchange in config_info.exchanges.clone() {
|
|
|
let exchange_up = exchange.to_uppercase();
|
|
let exchange_up = exchange.to_uppercase();
|
|
@@ -194,7 +191,7 @@ pub async fn export_balance(config_info: BalanceConfigInfo) {
|
|
|
let new_data = save_balance(history_balance.clone(), count_balance_info.clone(), save_start_time, save_end_time, history_end_time);
|
|
let new_data = save_balance(history_balance.clone(), count_balance_info.clone(), save_start_time, save_end_time, history_end_time);
|
|
|
let mut over_balance_info = vec![];
|
|
let mut over_balance_info = vec![];
|
|
|
let mut last_count_time_list = vec![];
|
|
let mut last_count_time_list = vec![];
|
|
|
- for (key, value) in new_data.clone() {
|
|
|
|
|
|
|
+ for (_key, value) in new_data.clone() {
|
|
|
last_count_time_list = vec![];
|
|
last_count_time_list = vec![];
|
|
|
for item in value {
|
|
for item in value {
|
|
|
over_balance_info.push(item.clone());
|
|
over_balance_info.push(item.clone());
|
|
@@ -244,7 +241,7 @@ pub fn save_balance(mut history_balance: serde_json::Value, new_balance: Vec<Vec
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|
|
|
for (key, value) in new_data.clone() {
|
|
for (key, value) in new_data.clone() {
|
|
|
- let mut value_clone = value.clone();
|
|
|
|
|
|
|
+ let value_clone = value.clone();
|
|
|
// if history_balance_list.contains_key(&key.clone()) { value_clone.remove(0); };
|
|
// if history_balance_list.contains_key(&key.clone()) { value_clone.remove(0); };
|
|
|
history_balance_list.entry(key.clone())
|
|
history_balance_list.entry(key.clone())
|
|
|
.and_modify(|v| v.extend(value_clone.clone()))
|
|
.and_modify(|v| v.extend(value_clone.clone()))
|
|
@@ -257,7 +254,7 @@ pub fn save_balance(mut history_balance: serde_json::Value, new_balance: Vec<Vec
|
|
|
history_balance_list
|
|
history_balance_list
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
-pub fn statistic_balance(balance_info: BTreeMap<String, Vec<Vec<String>>>, count_start_time: i64, end_start_time: i64, config: BalanceConfigInfo) -> String {
|
|
|
|
|
|
|
+pub fn statistic_balance(balance_info: BTreeMap<String, Vec<Vec<String>>>, count_start_time: i64, end_start_time: i64, _config: BalanceConfigInfo) -> String {
|
|
|
let mut max_withdrawal = dec!(0);
|
|
let mut max_withdrawal = dec!(0);
|
|
|
let mut max_total_withdrawal = dec!(0);
|
|
let mut max_total_withdrawal = dec!(0);
|
|
|
let mut total_income = dec!(0);
|
|
let mut total_income = dec!(0);
|
|
@@ -291,7 +288,7 @@ pub fn statistic_balance(balance_info: BTreeMap<String, Vec<Vec<String>>>, count
|
|
|
let mut present = Decimal::from_str(&balance[0][4]).unwrap();
|
|
let mut present = Decimal::from_str(&balance[0][4]).unwrap();
|
|
|
let mut past = dec!(0);
|
|
let mut past = dec!(0);
|
|
|
let mut earnings = dec!(0);
|
|
let mut earnings = dec!(0);
|
|
|
- for (index, info) in balance.iter().enumerate() {
|
|
|
|
|
|
|
+ for (_index, info) in balance.iter().enumerate() {
|
|
|
if info[5] == "transfer" {
|
|
if info[5] == "transfer" {
|
|
|
total_income += earnings;
|
|
total_income += earnings;
|
|
|
present = Decimal::from_str(&info[4]).unwrap();
|
|
present = Decimal::from_str(&info[4]).unwrap();
|