|
@@ -281,6 +281,9 @@ fn symbols_filter(symbols: &Vec<Value>, filters: &Vec<Value>, mode: &str, exchan
|
|
|
"AMP" => {
|
|
"AMP" => {
|
|
|
amp_filter(symbol, filter, exchanges)
|
|
amp_filter(symbol, filter, exchanges)
|
|
|
},
|
|
},
|
|
|
|
|
+ "TC" => {
|
|
|
|
|
+ tc_filter(symbol, filter, exchanges)
|
|
|
|
|
+ },
|
|
|
_ => {
|
|
_ => {
|
|
|
panic!("{}", format!("无法识别的过滤器: {}", filter["target"].as_str().unwrap()))
|
|
panic!("{}", format!("无法识别的过滤器: {}", filter["target"].as_str().unwrap()))
|
|
|
}
|
|
}
|
|
@@ -313,6 +316,24 @@ fn symbols_filter(symbols: &Vec<Value>, filters: &Vec<Value>, mode: &str, exchan
|
|
|
return rst
|
|
return rst
|
|
|
}
|
|
}
|
|
|
|
|
|
|
|
|
|
+// 交易次数过滤器
|
|
|
|
|
+fn tc_filter(symbol: &Value, filter: &Value, exchanges: &Vec<String>) -> bool {
|
|
|
|
|
+ let tc_limit = Decimal::from_str(filter["value"].as_str().unwrap().to_string().as_str()).unwrap();
|
|
|
|
|
+ let mut rst = true;
|
|
|
|
|
+
|
|
|
|
|
+ for exchange in exchanges {
|
|
|
|
|
+ let tc_map = symbol["tc"].clone();
|
|
|
|
|
+ let tc = Decimal::from_str(tc_map[exchange].as_str().unwrap().to_string().as_str()).unwrap();
|
|
|
|
|
+
|
|
|
|
|
+ rst = rst && tc > tc_limit;
|
|
|
|
|
+ if !rst {
|
|
|
|
|
+ break
|
|
|
|
|
+ }
|
|
|
|
|
+ }
|
|
|
|
|
+
|
|
|
|
|
+ return rst
|
|
|
|
|
+}
|
|
|
|
|
+
|
|
|
// 涨跌幅过滤器
|
|
// 涨跌幅过滤器
|
|
|
fn rise_filter(symbol: &Value, filter: &Value, exchanges: &Vec<String>) -> bool {
|
|
fn rise_filter(symbol: &Value, filter: &Value, exchanges: &Vec<String>) -> bool {
|
|
|
let rise_limit = Decimal::from_str(filter["value"].as_str().unwrap().to_string().as_str()).unwrap();
|
|
let rise_limit = Decimal::from_str(filter["value"].as_str().unwrap().to_string().as_str()).unwrap();
|