-
Notifications
You must be signed in to change notification settings - Fork 3
/
stock_filter.rs
60 lines (55 loc) · 1.78 KB
/
stock_filter.rs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
use futuapi_rs::{
action::stock_filter::{AccumulateFilter, BaseFilter, GetStockFilterRequest},
client,
Qot_Common::QotMarket,
Qot_StockFilter::{AccumulateField, SortDir, StockField},
Result,
};
use std::collections::HashMap;
#[tokio::main]
pub async fn main() -> Result<()> {
let mut qot_client = client::qot_connect("127.0.0.1:11111").await?;
let code_info: Vec<_> = qot_client
.get_stock_filter(GetStockFilterRequest::new(
0,
10,
QotMarket::QotMarket_US_Security,
None,
vec![BaseFilter::new(
StockField::StockField_VolumeRatio,
Some(3.0), // min
None, // max
Some(false),
None, // sort
)],
vec![AccumulateFilter::new(
AccumulateField::AccumulateField_ChangeRate,
Some(4.0), // min
None, // max
Some(false),
Some(SortDir::SortDir_Descend),
1,
)],
))
.await?
.data_list
.iter()
.map(|stock_data| {
let mut base_field_map = HashMap::new();
for base_data in &stock_data.base_data_list {
base_field_map.insert(base_data.field_name, base_data.value);
}
let mut accumulate_field_map = HashMap::new();
for accumulate_data in &stock_data.accumulate_data_list {
accumulate_field_map.insert(accumulate_data.field_name, accumulate_data.value);
}
(
stock_data.security.to_string(),
base_field_map,
accumulate_field_map,
)
})
.collect();
println!("{:?}", code_info);
Ok(())
}