|
|
@@ -15,7 +15,7 @@ use crate::struct_standard::Trades;
|
|
|
use crate::swap_okx::okx_swap_standard::SwapTrades;
|
|
|
use crate::utils::utils::TickerConfigInfo;
|
|
|
|
|
|
-pub async fn export_ticker(symbol: &str, exchange: &str, time_str: &str) {
|
|
|
+pub async fn export_ticker(symbol: &str, exchange: &str, time_str: &str, time_interval: i64) {
|
|
|
|
|
|
//从今天算起
|
|
|
let time_this = Utc::now().timestamp_millis();
|
|
|
@@ -37,6 +37,14 @@ pub async fn export_ticker(symbol: &str, exchange: &str, time_str: &str) {
|
|
|
name_html = "1小时";
|
|
|
(1000 * 60 * 60 * 1)
|
|
|
}
|
|
|
+ "2H" => {
|
|
|
+ name_html = "2小时";
|
|
|
+ (1000 * 60 * 60 * 2)
|
|
|
+ }
|
|
|
+ "3H" => {
|
|
|
+ name_html = "3小时";
|
|
|
+ (1000 * 60 * 60 * 3)
|
|
|
+ }
|
|
|
"4H" => {
|
|
|
name_html = "4小时";
|
|
|
(1000 * 60 * 60 * 4)
|
|
|
@@ -88,7 +96,7 @@ pub async fn export_ticker(symbol: &str, exchange: &str, time_str: &str) {
|
|
|
"GATE" => {
|
|
|
let mut start_at_ti = start_at;
|
|
|
loop {
|
|
|
- let end_at_ti = start_at_ti + (20 * 60);
|
|
|
+ let end_at_ti = start_at_ti + time_interval;
|
|
|
if start_at_ti > end_at {
|
|
|
break;
|
|
|
}
|
|
|
@@ -116,8 +124,22 @@ pub async fn export_ticker(symbol: &str, exchange: &str, time_str: &str) {
|
|
|
// {"contract": String("XRP_USDT"), "create_time": Number(1703146260.4), "create_time_ms": Number(1703146260.4), "id": Number(24663517), "price": String("0.6163"), "size": Number(132)}
|
|
|
// info!("数据:{:?}",row.clone());
|
|
|
let row_c = row.clone();
|
|
|
- let create_time = format!("{:?}", row["create_time"].as_f64().unwrap().to_i64().unwrap_or(0)).clone();
|
|
|
- let k = create_time.as_str();
|
|
|
+ // let create_time = format!("{:?}", row["create_time"].as_f64().unwrap().to_i64().unwrap_or(0)).clone();
|
|
|
+ // let k = create_time.as_str();
|
|
|
+
|
|
|
+ let create_time = format!("{:?}", row["create_time"].as_f64().unwrap_or(0.0)).clone();
|
|
|
+ let time_ttttt = create_time.clone();
|
|
|
+ let parts: Vec<&str> = time_ttttt.split('.').collect();
|
|
|
+ let seconds = parts[0].parse::<i64>().unwrap(); // 获取秒
|
|
|
+ let milliseconds = if parts.len() > 1 {
|
|
|
+ parts[1].parse::<u32>().unwrap_or(0) / 100
|
|
|
+ } else {
|
|
|
+ 0
|
|
|
+ };
|
|
|
+ let timestamp_millis_i64 = seconds * 1000 + (milliseconds as i64) *100;
|
|
|
+ let timestamp_millis_i64_string = timestamp_millis_i64.to_string(); // This is now owned and will live long enough.
|
|
|
+ let k = timestamp_millis_i64_string.as_str();
|
|
|
+
|
|
|
|
|
|
let mut def: Vec<Value> = vec![];
|
|
|
if exchange_list.contains_key(k) {
|
|
|
@@ -136,7 +158,7 @@ pub async fn export_ticker(symbol: &str, exchange: &str, time_str: &str) {
|
|
|
info!("数据请求错误:");
|
|
|
return;
|
|
|
}
|
|
|
- start_at_ti = start_at_ti + (20 * 60);
|
|
|
+ start_at_ti = start_at_ti + time_interval ;
|
|
|
}
|
|
|
|
|
|
// info!("数据:{:?}",exchange_list);
|
|
|
@@ -146,13 +168,17 @@ pub async fn export_ticker(symbol: &str, exchange: &str, time_str: &str) {
|
|
|
let mut keys: Vec<String> = exchange_list.keys().cloned().collect();
|
|
|
keys.sort_by(|&(ref a), &(ref b)| a.len().cmp(&b.len()));
|
|
|
for k in keys.clone() {
|
|
|
- let time_str = NaiveDateTime::from_timestamp_millis((k.clone().parse::<i64>().unwrap() + 8 * 3600) * 1000).unwrap().format("%Y-%m-%d %H:%M:%S%.3f").to_string();
|
|
|
+ let time_str = NaiveDateTime::from_timestamp_millis(k.clone().parse::<i64>().unwrap() + 8 * 3600 * 1000).unwrap().format("%Y-%m-%d %H:%M:%S%.3f").to_string();
|
|
|
let data = exchange_list.get(k.clone().as_str()).unwrap();
|
|
|
let mut str_array = vec![""];
|
|
|
+ let mut ti_str = vec![""];
|
|
|
for d in data.clone() {
|
|
|
str_array.push(" - ");
|
|
|
+ // ti_str.push(d.clone());
|
|
|
+ info!("数据: {:?} ",d);
|
|
|
}
|
|
|
- // info!("数据总数: {:?}: {:?}",time_str,str_array);
|
|
|
+
|
|
|
+ info!("数据总数: {:?}: {:?}",time_str,str_array);
|
|
|
|
|
|
|
|
|
let mut def: Vec<Value> = vec![];
|
|
|
@@ -196,7 +222,7 @@ pub async fn export_ticker(symbol: &str, exchange: &str, time_str: &str) {
|
|
|
let mut initiative_ticker_info = vec![];
|
|
|
for d in data {
|
|
|
let create_time = format!("{:?}", d["create_time"].as_f64().unwrap().to_i64().unwrap_or(0)).clone();
|
|
|
- let time_str = NaiveDateTime::from_timestamp_millis((create_time.clone().parse::<i64>().unwrap() + 8 * 3600) * 1000).unwrap().format("%Y-%m-%d %H:%M:%S%.3f").to_string();
|
|
|
+ let time_str = NaiveDateTime::from_timestamp_millis(create_time.clone().parse::<i64>().unwrap() * 1000 + 8 * 3600 * 1000).unwrap().format("%Y-%m-%d %H:%M:%S%.3f").to_string();
|
|
|
|
|
|
initiative_ticker_info.push(time_str);
|
|
|
};
|
|
|
@@ -225,10 +251,10 @@ pub async fn export_ticker(symbol: &str, exchange: &str, time_str: &str) {
|
|
|
for row in rows {
|
|
|
let price = row["price"].as_str().unwrap().parse::<f64>().unwrap();
|
|
|
// info!("price:{:?} " ,price);
|
|
|
- if max_v == 0.0{
|
|
|
- max_v = price
|
|
|
+ if max_v == 0.0 {
|
|
|
+ max_v = price
|
|
|
}
|
|
|
- if min_v == 0.0{
|
|
|
+ if min_v == 0.0 {
|
|
|
min_v = price
|
|
|
}
|
|
|
|