浏览代码

一些算法的优化

skyffire 1 年之前
父节点
当前提交
9ff5695c9d
共有 3 个文件被更改,包括 7 次插入7 次删除
  1. 二进制
      chart.png
  2. 2 2
      utils/chart-kit.js
  3. 5 5
      十面埋伏分析.js

二进制
chart.png


+ 2 - 2
utils/chart-kit.js

@@ -7,8 +7,8 @@ const echarts = require('echarts');
 module.exports = class ChartKit {
   static printChart(dataList) {
     // 创建一个 canvas 实例
-    const width = 1920; // 宽度
-    const height = 1080; // 高度
+    const width = 3840; // 宽度
+    const height = 2160; // 高度
     const canvas = createCanvas(width, height);
 
     // 初始化 ECharts 实例

+ 5 - 5
十面埋伏分析.js

@@ -153,7 +153,7 @@ function statisticD(kLines, index) {
   return NumKit.getSubFloat(totalRiseAndFall / kCount, 2)
 }
 
-// 过去30天的上影线幅度大于2.5%的次数,跟这个无关
+// 过去30天的上影线幅度大于2.5%,并且收盘是阴线的次数
 function statisticE(kLines, index) {
   let kCount = 0
   let count = 0
@@ -165,7 +165,7 @@ function statisticE(kLines, index) {
     kCount += 1
     let target = kLine.Close > kLine.Open ? kLine.Close : kLine.Open
     let rise = (100 * (kLine.High - target) / target)
-    count += (rise > 2.5 ? 1 : 0)
+    count += (rise > 2.5 && kLine.Close < kLine.Open ? 1 : 0)
   }
 
   if (kCount === 0) {
@@ -221,7 +221,7 @@ function statisticG(kLines, index) {
 function statisticH(kLines, index) {
   let kCount = 0
   let rst = 0
-  for (let i = index - 1; i >= index - 7; i--) {
+  for (let i = index - 1; i >= index - 3; i--) {
     let kLine = kLines[i]
 
     if (!kLines[i - 1]) break
@@ -246,7 +246,7 @@ function dragonAnalysis(kLinesMap, dragonMap, dayCount) {
     let kLines = kLinesMap[symbol]
     let index = kLines.length - (dayCount + 1)
 
-    let x = statisticA(kLines, index)
+    let x = statisticE(kLines, index)
     let y = dragonMap[symbol].Profit
 
     // logger.info(
@@ -262,7 +262,7 @@ function dragonAnalysis(kLinesMap, dragonMap, dayCount) {
 async function main() {
   let kLinesMap = await readData()
 
-  const FIRST_FEW_DAYS = 10            // 第几天的数据,0表示今天,1表示昨天,2表示前天,以此类推
+  const FIRST_FEW_DAYS = 1            // 第几天的数据,0表示今天,1表示昨天,2表示前天,以此类推
   const BUY_LIMIT_RATE = 2.5          // 从什么比例入场
   const BAKE_TEST_DAYS = 10           // 一共回测多少天