Răsfoiți Sursa

修改analyze导出信息

gepangpang 1 an în urmă
părinte
comite
2f18c33ab9
4 a modificat fișierele cu 80 adăugiri și 83 ștergeri
  1. 1 5
      config_analyze.toml.sample
  2. 1 1
      src/export_analyze.rs
  3. 77 76
      src/export_template/template_analyze.rs
  4. 1 1
      src/main.rs

+ 1 - 5
config_analyze.toml.sample

@@ -4,11 +4,7 @@ is_export = true
 proxy_address = "127.0.0.1:7890"
 # 查询币对列表,突发行情时查单个可以注释掉其他的
 # 注:不建议一次查太多,免得限频,小心封ip(试过6个没有事)
-symbols = [
-#    "BAKE_USDT",
-#    "OP_USDT",
-    "KAS_USDT"
-]
+symbols = ["BAKE_USDT","OP_USDT","KAS_USDT"]
 # 配置交易所 目前支持["binance", "gate"]
 exchanges = ["gate"]
 # 时间范围 m:分钟, H:小时, D:天, W:周, M:月(分钟和月份区分大小写,其余不区分。例:10m)

+ 1 - 1
src/export_analyze.rs

@@ -21,7 +21,7 @@ pub struct RangeInterval {
     pub interval_text: String,
 }
 
-pub async fn export_ticker(symbol: &str, exchange: &str, range_interval: &str, range_limit: Decimal) {
+pub async fn export_analyze(symbol: &str, exchange: &str, range_interval: &str, range_limit: Decimal) {
     // 从此刻往前算时间
     let timestamp_seconds_now = Utc::now().timestamp();
     let range_interval = parse_range_interval(range_interval);

+ 77 - 76
src/export_template/template_analyze.rs

@@ -53,84 +53,85 @@ pub fn export_html(title: &str, symbol: &str, x_values: Vec<Decimal>, y_values:
             var option;
 
             option = {
-                  title: {
-                    text: '{{chart_title}}'
-                  },
-                  tooltip: {
-                    trigger: 'axis',
-                    axisPointer: {
-                      type: 'cross',
-                      lineStyle: {
-                          type: 'dashed',
-                          width: 1
-                      }
-                    },
-                    formatter: function (value) {
-                      let time = dayjs(value[0].name *1).format('YYYY-MM-DD HH:mm:ss.SSS');
-                      let price = value[0].value;
-                      return `时间:${time}<br/>价格:${price}`
-                    },
+              title: {
+                text: '{{chart_title}}'
+              },
+              tooltip: {
+                trigger: 'axis',
+                axisPointer: {
+                  type: 'cross',
+                  lineStyle: {
+                      type: 'dashed',
+                      width: 1
+                  }
+                },
+                formatter: function (value) {
+                  let time = dayjs(value[0].name *1).format('YYYY-MM-DD HH:mm:ss.SSS');
+                  let price = value[0].value;
+                  return `时间:${time}<br/>价格:${price}`
+                },
+              },
+              toolbox: {
+                feature: {
+                  brush: {
+                    type: ['rect', 'clear']
+                  }
+                }
+              },
+              dataZoom: [
+                {
+                    type: 'inside',
+                    start: 0,
+                    end: 100
+                },
+                {
+                    start: 0,
+                    end: 100
+                }
+              ],
+              legend: {
+                   data: {{x_values}}
+              },
+              xAxis: {
+                type: 'category',
+                boundaryGap: false,
+                data: {{x_values}},
+                show : false
+              },
+              yAxis: {
+                type: 'value',
+                boundaryGap: [0, '100%'],
+                formatter: function (value) {
+                  return dayjs(value[0].name *1).format('YYYY-MM-DD HH:mm:ss.SSS');
+                },
+              },
+              series: [
+                {
+                  name: '价格',
+                  type: 'line',
+                  symbol: 'none',
+                  sampling: 'lttb',
+                  itemStyle: {
+                    color: 'rgb(55, 162, 255)'
                   },
-                   toolbox: {
-                    feature: {
-                      dataZoom: {},
-                      brush: {
-                        type: ['rect', 'clear']
+                  areaStyle: {
+                    color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
+                      {
+                        opacity: 0.4,
+                        offset: 0,
+                        color: 'rgb(55, 162, 255)'
+                      },
+                      {
+                        opacity: 0.1,
+                        offset: 1,
+                        color: 'rgb(55, 162, 255)'
                       }
-                    }
-                  },
-                  legend: {
-                       data: {{x_values}}
+                    ])
                   },
-                  xAxis: {
-                    type: 'category',
-                    boundaryGap: false,
-                    data: {{x_values}},
-                    show : false
-                  },
-                  yAxis: {
-                    type: 'value',
-                    boundaryGap: [0, '100%'],
-                    formatter: function (value) {
-                      return dayjs(value[0].name *1).format('YYYY-MM-DD HH:mm:ss.SSS');
-                    },
-                  },
-                  dataZoom: [
-                    {
-                      type: 'inside',
-                      start: 0,
-                      end: 10
-                    },
-                    {
-                      start: 0,
-                      end: 10
-                    }
-                  ],
-                  series: [
-                    {
-                      name: '价格',
-                      type: 'line',
-                      symbol: 'none',
-                      sampling: 'lttb',
-                      itemStyle: {
-                        color: 'rgb(255, 70, 131)'
-                      },
-                      areaStyle: {
-                        color: new echarts.graphic.LinearGradient(0, 0, 0, 1, [
-                          {
-                            offset: 0,
-                            color: 'rgb(255, 158, 68)'
-                          },
-                          {
-                            offset: 1,
-                            color: 'rgb(255, 70, 131)'
-                          }
-                        ])
-                      },
-                      data: {{y_values}}
-                    }
-                  ]
-                };
+                  data: {{y_values}}
+                }
+              ]
+            };
 
             option && myChart.setOption(option);
             </script>
@@ -150,5 +151,5 @@ pub fn export_html(title: &str, symbol: &str, x_values: Vec<Decimal>, y_values:
     // 将 HTML 写入文件
     let mut file = File::create(&path).expect("创建文件失败!");
     file.write_all(output.as_bytes()).expect("写入文件到本地失败!");
-    info!("Balance信息网页生成成功!路径:{:?}\n\n", path);
+    info!("Analyze信息网页生成成功!路径:{:?}\n\n", path);
 }

+ 1 - 1
src/main.rs

@@ -67,7 +67,7 @@ async fn main() {
             let ri = config_clone.range_interval.clone();
             let rl = config_clone.range_limit;
             let handle = spawn(async move {
-                export_analyze::export_ticker(&s, &e, &ri, rl).await;
+                export_analyze::export_analyze(&s, &e, &ri, rl).await;
             });
             handles.push(handle);
         }