|
|
@@ -25,7 +25,7 @@ pub async fn export_balance(config_info: BalanceConfigInfo) {
|
|
|
}
|
|
|
for exchange in config_info.exchanges.clone() {
|
|
|
let exchange_up = exchange.to_uppercase();
|
|
|
- let exchange_result = match exchange_up.as_str() {
|
|
|
+ match exchange_up.as_str() {
|
|
|
"GATE" => {
|
|
|
for account in config_info_clone.account_list.clone() {
|
|
|
let mut account_info: BTreeMap<String, String> = BTreeMap::new();
|
|
|
@@ -111,7 +111,7 @@ pub async fn export_balance(config_info: BalanceConfigInfo) {
|
|
|
}
|
|
|
}
|
|
|
// break;
|
|
|
- }
|
|
|
+ };
|
|
|
}
|
|
|
"BYBIT" => {
|
|
|
for account in config_info_clone.account_list.clone() {
|
|
|
@@ -119,12 +119,9 @@ pub async fn export_balance(config_info: BalanceConfigInfo) {
|
|
|
account_info.insert("account_name".to_string(), account[0].clone());
|
|
|
account_info.insert("access_key".to_string(), account[1].clone());
|
|
|
account_info.insert("secret_key".to_string(), account[2].clone());
|
|
|
- info!("账号:{:?}",account_info);
|
|
|
|
|
|
- let mut gate_exc = BybitSwapRest::new(false, account_info.clone());
|
|
|
- let data = gate_exc.get_account_transaction_log().await;
|
|
|
- // let data = gate_exc.get_position_closed_pnl("BSVUSDT".to_string()).await;
|
|
|
- // let data = gate_exc.get_account_wallet_fund_records(0, 0).await;
|
|
|
+ let mut bybit_exc = BybitSwapRest::new(false, account_info.clone());
|
|
|
+ let data = bybit_exc.get_account_transaction_log().await;
|
|
|
|
|
|
// info!("请求完成{:?}",data.clone());
|
|
|
if data.code.as_str() == "200" {
|
|
|
@@ -142,20 +139,11 @@ pub async fn export_balance(config_info: BalanceConfigInfo) {
|
|
|
let mut name_data_all: Vec<Vec<String>> = vec![];
|
|
|
|
|
|
for item in array {
|
|
|
- // info!("数据{:?}",item.clone().to_string());
|
|
|
-
|
|
|
let id = item.get("id").unwrap().as_str().unwrap();
|
|
|
let type_str = item.get("type").unwrap().as_str().unwrap();
|
|
|
- let b_symbol = item.get("symbol").unwrap().as_str().unwrap();
|
|
|
- let side = item.get("side").unwrap().as_str().unwrap();
|
|
|
- let currency = item.get("currency").unwrap().as_str().unwrap();
|
|
|
- let tradePrice = item.get("tradePrice").unwrap().as_str().unwrap();
|
|
|
- let funding = item.get("funding").unwrap().as_str().unwrap();
|
|
|
- let fee = item.get("fee").unwrap().as_str().unwrap();
|
|
|
- let cashFlow = item.get("cashFlow").unwrap().as_str().unwrap();
|
|
|
let change = item.get("change").unwrap().as_str().unwrap();
|
|
|
- let cashBalance = item.get("cashBalance").unwrap().as_str().unwrap();
|
|
|
- let transactionTime = item.get("transactionTime").unwrap().as_str().unwrap();
|
|
|
+ let cash_balance = item.get("cashBalance").unwrap().as_str().unwrap();
|
|
|
+ let transaction_time = item.get("transactionTime").unwrap().as_str().unwrap();
|
|
|
|
|
|
let type_str = match type_str {
|
|
|
"TRADE" => { "交易" }
|
|
|
@@ -165,24 +153,13 @@ pub async fn export_balance(config_info: BalanceConfigInfo) {
|
|
|
}
|
|
|
};
|
|
|
|
|
|
- // info!("result 数据\
|
|
|
- // transactionTime:{:?} id:{:?},symbol:{:?},side:{:?},currency:{:?},tradePrice:{:?},funding:{:?},fee:{:?},cashFlow:{:?},cashBalance:{:?},change:{:?}"
|
|
|
- // ,transactionTime, id,b_symbol,side,currency,tradePrice,funding,fee,cashFlow,cashBalance,change);//change 變更 = cashFlow + funding - fee
|
|
|
-
|
|
|
-// "{\"bonusChange\":\"0\",\"cashBalance\":\"97.95598152\",\"cashFlow\":\"0\",\"category\":\"linear\",\"change\":\"-0.01119174\",\"currency\":\"USDT\",\"fee\":\"0.01119174
|
|
|
-// \",\"feeRate\":\"0.00014\",\"funding\":\"0\",\"id\":\"123105018_INJUSDT_618678386870\",\"orderId\":\"3d3da36b-c803-441a-bb0b-24fdef56d6f3\",\"orderLinkId\":\"t-459097906\",\"qty\":\"2\",\"side\":\"Buy\",\"size\":\"2\",\"symbol\"
|
|
|
-// :\"INJUSDT\",\"tradeId\":\"ed458708-3de4-5bc8-bc27-f6b4ba7a8921\",\"tradePrice\":\"39.9705\",\"transactionTime\":\"1703224750479\",\"type\":\"TRADE\"}"
|
|
|
-
|
|
|
-// "{\"balance\":\"49.051791949878\",\"change\":\"-0.0576\",\"contract\":\"OP_USDT\",\"text\":\"OP_USDT:376554197685\",\"time\":1702110912,\"trade_id\":\"16306596\",\"type
|
|
|
-// \":\"pnl\"}"
|
|
|
-
|
|
|
- let time = transactionTime.parse::<i64>().unwrap() / 1000;
|
|
|
+ let time = transaction_time.parse::<i64>().unwrap() / 1000;
|
|
|
|
|
|
let mut name_data_array: Vec<String> = vec![];
|
|
|
name_data_array.push(time.to_string());
|
|
|
name_data_array.push(id.to_string());
|
|
|
name_data_array.push(change.to_string());
|
|
|
- name_data_array.push(cashBalance.to_string());
|
|
|
+ name_data_array.push(cash_balance.to_string());
|
|
|
name_data_array.push(type_str.to_string());
|
|
|
name_data_array.push("".to_string());
|
|
|
name_data_array.push("".to_string());
|
|
|
@@ -198,7 +175,7 @@ pub async fn export_balance(config_info: BalanceConfigInfo) {
|
|
|
}
|
|
|
}
|
|
|
// break;
|
|
|
- }
|
|
|
+ };
|
|
|
}
|
|
|
_ => {
|
|
|
error!("交易所输入错误!");
|
|
|
@@ -206,8 +183,6 @@ pub async fn export_balance(config_info: BalanceConfigInfo) {
|
|
|
}
|
|
|
};
|
|
|
}
|
|
|
- info!("all_account_balance_info:{:?}",all_account_balance_info);
|
|
|
-
|
|
|
|
|
|
// 根据账户变动填充
|
|
|
let mut count_time_list = vec![];
|
|
|
@@ -315,13 +290,11 @@ pub fn supply_balance(source_balance_info: BTreeMap<String, Vec<Vec<String>>>, t
|
|
|
let balance_info_filter: Vec<Vec<String>> = balance_info.iter().filter(|item| {
|
|
|
item[0].parse::<i64>().unwrap() < time
|
|
|
}).cloned().collect();
|
|
|
- info!("balance_info_filter:{:?}",balance_info_filter.clone());
|
|
|
- let mut last_balance_info = vec![];
|
|
|
- if balance_info_filter.len() == 0{
|
|
|
- last_balance_info = balance_info[0].clone();
|
|
|
- }else{
|
|
|
- last_balance_info = balance_info_filter[balance_info_filter.len() - 1].clone();
|
|
|
- }
|
|
|
+ let mut last_balance_info = if balance_info_filter.len() == 0 {
|
|
|
+ balance_info[0].clone()
|
|
|
+ } else {
|
|
|
+ balance_info_filter[balance_info_filter.len() - 1].clone()
|
|
|
+ };
|
|
|
last_balance_info.insert(0, key.clone());
|
|
|
total_price += Decimal::from_str(&last_balance_info[4]).unwrap();
|
|
|
balance_info_list.push(last_balance_info);
|