|
|
@@ -26,7 +26,7 @@ pub struct SeriesInfo {
|
|
|
pub data: Vec<Trades>,
|
|
|
}
|
|
|
|
|
|
-pub fn export_html(export_info: Vec<ExportExchangeTickerInfo>, start_at: &str, end_at: &str, config: ConfigInfo) {
|
|
|
+pub fn export_html(export_info: Vec<ExportExchangeTickerInfo>, start_at: &str, end_at: &str, config: ConfigInfo, robot_info: Vec<Trades>) {
|
|
|
info!("正在生成网页,请稍后!");
|
|
|
let export_path = if config.export_path == "" { "./" } else { config.export_path.as_str() };
|
|
|
let export_name = if config.export_name == "" { "export" } else { config.export_name.as_str() };
|
|
|
@@ -70,21 +70,22 @@ pub fn export_html(export_info: Vec<ExportExchangeTickerInfo>, start_at: &str, e
|
|
|
let long_volume_bool = long_volume / sum_volume >= config.long_volume_rate;
|
|
|
let short_volume_bool = short_volume / sum_volume >= config.short_volume_rate;
|
|
|
|
|
|
- if (long_volume_bool && last_bool != "long") || (short_volume_bool && last_bool != "short") || (!long_volume_bool && !short_volume_bool && last_bool != "none") {
|
|
|
+ if (long_volume_bool && last_bool != "initiative_long") || (short_volume_bool && last_bool != "initiative_short") || (!long_volume_bool && !short_volume_bool && last_bool != "initiative_none") {
|
|
|
// 新增订单流主动性数据
|
|
|
let max_price = max_price * dec!(1.005);
|
|
|
if long_volume_bool {
|
|
|
- last_bool = "long";
|
|
|
+ last_bool = "initiative_long";
|
|
|
}
|
|
|
if short_volume_bool {
|
|
|
- last_bool = "short";
|
|
|
+ last_bool = "initiative_short";
|
|
|
}
|
|
|
if !long_volume_bool && !short_volume_bool {
|
|
|
- last_bool = "none";
|
|
|
+ last_bool = "initiative_none";
|
|
|
}
|
|
|
ticker_info.push(Trades {
|
|
|
id: Uuid::new_v4().to_string()[0..8].to_string(),
|
|
|
data_type: last_bool.to_string(),
|
|
|
+ classify: "initiative".to_string(),
|
|
|
symbol: trades.symbol,
|
|
|
create_time: trades.create_time,
|
|
|
size: volume.to_string(),
|
|
|
@@ -114,6 +115,9 @@ pub fn export_html(export_info: Vec<ExportExchangeTickerInfo>, start_at: &str, e
|
|
|
let mut name_list: Vec<String> = vec![];
|
|
|
let mut legend_list: Vec<String> = vec![];
|
|
|
let mut series_info: Vec<SeriesInfo> = vec![];
|
|
|
+
|
|
|
+ let ref_robot_info: Vec<Trades> = robot_info.iter().filter(|trades| trades.data_type == "robot_ref_price").cloned().collect();
|
|
|
+
|
|
|
for item in export_info.clone() {
|
|
|
name_list.push(format!("'{}'", item.name));
|
|
|
series_info.push(SeriesInfo {
|
|
|
@@ -122,9 +126,21 @@ pub fn export_html(export_info: Vec<ExportExchangeTickerInfo>, start_at: &str, e
|
|
|
})
|
|
|
}
|
|
|
series_info.push(initiative_info);
|
|
|
+
|
|
|
+ series_info.push(SeriesInfo {
|
|
|
+ name: "预定价格".to_string(),
|
|
|
+ data: ref_robot_info.clone(),
|
|
|
+ });
|
|
|
+ let reg_robot_info: Vec<Trades> = robot_info.iter().filter(|trades| trades.data_type == "robot_reg_price").cloned().collect();
|
|
|
+ series_info.push(SeriesInfo {
|
|
|
+ name: "挂单价格".to_string(),
|
|
|
+ data: reg_robot_info.clone(),
|
|
|
+ });
|
|
|
+
|
|
|
for item in series_info.clone() {
|
|
|
legend_list.push(format!("'{}'", item.name));
|
|
|
}
|
|
|
+
|
|
|
let data = serde_json::json!({
|
|
|
"chart_title": format!("{} Ticker数据", name_list.join("、").replace("'","")),
|
|
|
"legend_data": format!("[{}]", legend_list.join(", ")),
|