gepangpang 1 жил өмнө
parent
commit
c97f05f3b0

+ 4 - 0
config.toml.sample

@@ -8,6 +8,10 @@ exchanges = ["binance", "gate", "okx", ]
 range_time = ["2023-12-5 15:00:00", "2023-12-5 15:01:00"]
 # 前置时间(单位ms)
 recall_time = 30000
+# 主动性跌比率(0.01代表1%)
+short_volume_rate = 0.7
+# 主动性涨比率(0.01代表1%)
+long_volume_rate = 0.7
 # 导出路径(不填则为默认路径"./")
 export_path = ""
 # 导出文件名字(不填则为默认名字"export")

+ 2 - 2
src/export/html.rs

@@ -47,7 +47,7 @@ pub fn export_html(export_info: Vec<ExportExchangeTickerInfo>, start_at: &str, e
             let mut short_volume = Decimal::ONE;
             let mut long_volume = Decimal::ONE;
             let mut sum_volume = Decimal::ONE;
-            let mut recall_ticker_info: Vec<Trades> = export_exchange_ticker_info.recall_ticker_info.iter().filter(|recall_trades| {
+            let recall_ticker_info: Vec<Trades> = export_exchange_ticker_info.recall_ticker_info.iter().filter(|recall_trades| {
                 let recall_create_time = Decimal::from_str(&recall_trades.create_time).unwrap();
                 let create_time = Decimal::from_str(&trades.create_time).unwrap();
                 let recall_time = Decimal::from_i64(config.recall_time).unwrap();
@@ -59,7 +59,7 @@ pub fn export_html(export_info: Vec<ExportExchangeTickerInfo>, start_at: &str, e
                 sum_volume += size.abs();
                 if size > dec!(0) { long_volume += size } else { short_volume += size.abs() }
             };
-            if long_volume / sum_volume >= dec!(0.7) || short_volume / sum_volume >= dec!(0.7) {
+            if long_volume / sum_volume >= config.long_volume_rate || short_volume / sum_volume >= config.short_volume_rate {
                 // 新增订单流主动性数据
                 let max_price = Decimal::from_str(&export_exchange_ticker_info.max_price.clone()).unwrap() * dec!(1.005);
                 ticker_info.push(Trades {

+ 5 - 0
src/utils/utils.rs

@@ -1,5 +1,6 @@
 use std::fs::File;
 use std::io::Read;
+use rust_decimal::Decimal;
 use serde::Deserialize;
 use toml::from_str;
 use tracing::error;
@@ -18,6 +19,8 @@ pub struct ConfigInfo {
     pub symbol: String,
     pub range_time: Vec<String>,
     pub recall_time: i64,
+    pub short_volume_rate: Decimal,
+    pub long_volume_rate: Decimal,
     pub export_path: String,
     pub export_name: String,
 }
@@ -30,6 +33,8 @@ impl ConfigInfo {
             symbol: "".to_string(),
             range_time: vec![],
             recall_time: 0,
+            short_volume_rate: Decimal::ZERO,
+            long_volume_rate: Decimal::ZERO,
             export_path: "".to_string(),
             export_name: "".to_string(),
         }