-
-
+
+
胜率测试
-
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
+
@@ -58,9 +116,9 @@ export default {
return {
radio: "radio0",
name: "",
- form: { deadProfitRatio: 0.3, sliderRatio: 0 },
+ form: { deadProfitRatio: 0.3, sliderRatio: 0, lostFloatRatio: 0 },
data: [],
- result: {}
+ result: { maxWin: 0, maxLose: 0 }
};
},
methods: {
@@ -92,24 +150,44 @@ export default {
rs();
});
},
- //time open high low close 做多 做空
+ //time[0] open[1] high[2] low[3] close[4] 做多 做空
winRateTest() {
this.validateForm().then(rs => {
let tradeCount = 0;
let win = 0;
let lose = 0;
+ let tempWin = 0;
+ let tempLose = 0;
+ let maxLose = 0;
+ let maxWin = 0;
+ let maxLostRate = 0;
+ let totalLostRate = 0;
for (let i = 0; i < this.data.length; i++) {
if (this.isSignal(this.data[i])) {
let { up, low } = this.isSignal(this.data[i]);
if (!up && !low) {
//doing nothing
} else {
+ if (this.form.filterRatio) {
+ let condition = up
+ ? (this.data[i][4] - this.data[i][1]) / this.data[i][1]
+ : (this.data[i][1] - this.data[i][4]) / this.data[i][1];
+ // console.log("信号过滤比", condition);
+ if (condition > this.form.filterRatio / 100) continue;
+ }
tradeCount++;
+ let result;
if (up) {
let buyPrice =
this.data[i][4] * (1 + this.form.sliderRatio / 100); //收盘价 *滑点比率
- let stopLost = this.data[i][3]; //止损价
+ let stopLost =
+ this.data[i][3] -
+ Math.abs(
+ ((this.data[i][4] - this.data[i][1]) *
+ this.form.lostFloatRatio) /
+ 100
+ ); //止损价
let stopWin;
//止盈价
if (this.radio == "radio0")
@@ -120,21 +198,26 @@ export default {
(buyPrice - stopLost) * (this.form.profitRatio / 100) +
buyPrice;
- console.log(buyPrice, stopWin, stopLost);
- let result = this.reachEnd(
+ // console.log(buyPrice, stopWin, stopLost);
+ result = this.reachEnd(
0,
i + 1,
stopWin,
stopLost,
- this.data[i][0]
+ this.data[i][0],
+ buyPrice
);
- if (result == 1) win++;
- if (result == -1) lose++;
}
if (low) {
let buyPrice =
this.data[i][4] * (1 - this.form.sliderRatio / 100); //收盘价 *滑点比率
- let stopLost = this.data[i][2]; //止损价
+ let stopLost =
+ this.data[i][2] +
+ Math.abs(
+ ((this.data[i][1] - this.data[i][4]) *
+ this.form.lostFloatRatio) /
+ 100
+ ); //止损价
let stopWin;
//止盈价
if (this.radio == "radio0")
@@ -145,16 +228,29 @@ export default {
buyPrice -
(buyPrice - stopLost) * (this.form.profitRatio / 100);
- console.log(buyPrice, stopWin, stopLost);
- let result = this.reachEnd(
+ // console.log(buyPrice, stopWin, stopLost);
+ result = this.reachEnd(
1,
i + 1,
stopWin,
stopLost,
- this.data[i][0]
+ this.data[i][0],
+ buyPrice
);
- if (result == 1) win++;
- if (result == -1) lose++;
+ }
+ if (result == 1) {
+ win++;
+ tempLose = 0;
+ tempWin++;
+ if (maxWin < tempWin) maxWin = tempWin;
+ }
+ if (result < 0) {
+ lose++;
+ tempWin = 0;
+ tempLose++;
+ if (maxLose < tempLose) maxLose = tempLose;
+ if (maxLostRate > result) maxLostRate = result;
+ totalLostRate += result;
}
}
}
@@ -162,9 +258,14 @@ export default {
this.result = {
tradeCount,
winRate: ((win / tradeCount) * 100).toFixed(2),
- loseRate: ((lose / tradeCount) * 100).toFixed(2)
+ loseRate: ((lose / tradeCount) * 100).toFixed(2),
+ maxWin,
+ maxLose,
+ totalLostRate: totalLostRate.toFixed(2),
+ maxLostRate: maxLostRate.toFixed(2),
+ avgLost: (totalLostRate / lose).toFixed(2)
};
- console.log(tradeCount, win);
+ // console.log(tradeCount, win);
});
},
@@ -178,48 +279,52 @@ export default {
},
// type: 0 做多 1 做空
- reachEnd(type, index, stopWin, stopLost, timeStamp) {
+ reachEnd(type, index, stopWin, stopLost, timeStamp, buyPrice) {
let result = 0;
if (type == 0) {
- console.log(
- `=====================================================(${timeStamp})做多信号开始===止盈${stopWin}====止损${stopLost}========================================`
- );
+ // console.log(
+ // `=====================================================(${timeStamp})做多信号开始===止盈${stopWin}====止损${stopLost}========================================`
+ // );
//做多
for (let i = index; i < this.data.length; i++) {
if (this.data[i][2] > stopWin) {
- console.log(`---->触发止盈点`, this.data[i]);
+ // console.log(`---->触发止盈点`, this.data[i]);
result = 1;
break;
} else if (this.data[i][3] < stopLost) {
- console.log(`---->触发止损点`, this.data[i]);
- result = -1;
+ // console.log(`---->触发止损点`, this.data[i]);
+ let lostPercent = ((stopLost - buyPrice) / buyPrice) * 100;
+ // console.log("做多亏损比", lostPercent);
+ result = lostPercent;
break;
} else {
- console.log(`->未触发止盈止损点`, this.data[i]);
+ // console.log(`->未触发止盈止损点`, this.data[i]);
}
}
} else {
- console.log(
- `=====================================================(${timeStamp})做空信号开始===止盈${stopWin}====止损${stopLost}========================================`
- );
+ // console.log(
+ // `=====================================================(${timeStamp})做空信号开始===止盈${stopWin}====止损${stopLost}========================================`
+ // );
//做空
for (let i = index; i < this.data.length; i++) {
if (this.data[i][3] < stopWin) {
- console.log(`---->触发止盈点`, this.data[i]);
+ // console.log(`---->触发止盈点`, this.data[i]);
result = 1;
break;
} else if (this.data[i][2] > stopLost) {
- console.log(`---->触发止损点`, this.data[i]);
- result = -1;
+ // console.log(`---->触发止损点`, this.data[i]);
+ let lostPercent = ((buyPrice - stopLost) / buyPrice) * 100;
+ // console.log("做空亏损比", lostPercent, buyPrice, stopLost);
+ result = lostPercent;
break;
} else {
- console.log(`->未触发止盈止损点`, this.data[i]);
+ // console.log(`->未触发止盈止损点`, this.data[i]);
}
}
}
- console.log(
- `=====================================================信号交易结束===止盈${stopWin}====止损${stopLost}========================================`
- );
+ // console.log(
+ // `=====================================================信号交易结束===止盈${stopWin}====止损${stopLost}========================================`
+ // );
return result;
},
reachFail() {},
diff --git a/src/router/routes.js b/src/router/routes.js
index 77cc51b..b92db23 100644
--- a/src/router/routes.js
+++ b/src/router/routes.js
@@ -14,7 +14,7 @@ const Robot = () => import("@/pages/Robot");
const Account = () => import("@/pages/Account");
const Edit = () => import("@/pages/Robot/edit.vue");
const WinRate = () => import("@/pages/WinRate");
-
+const ReCheck = () => import("@/pages/ReCheck");
const routes = [
{
path: "/",
@@ -40,6 +40,11 @@ const routes = [
path: "account",
name: "account",
component: Account
+ },
+ {
+ path: "reCheck",
+ name: "reCheck",
+ component: ReCheck
}
// {
// path: "profile",
diff --git a/vue.config.js b/vue.config.js
index 5a7829d..3d3e0ba 100644
--- a/vue.config.js
+++ b/vue.config.js
@@ -1,37 +1,52 @@
-const webpack = require('webpack');
-
+const webpack = require("webpack");
+const UglifyJsPlugin = require("uglifyjs-webpack-plugin");
module.exports = {
lintOnSave: false,
configureWebpack: {
// Set up all the aliases we use in our app.
resolve: {
alias: {
- 'chart.js': 'chart.js/dist/Chart.js'
+ "chart.js": "chart.js/dist/Chart.js"
}
},
plugins: [
new webpack.optimize.LimitChunkCountPlugin({
maxChunks: 6
})
- ]
+ ],
+ optimization: {
+ minimizer: [
+ new UglifyJsPlugin({
+ uglifyOptions: {
+ output: {
+ comments: false
+ },
+ compress: {
+ drop_debugger: true,
+ drop_console: true
+ }
+ }
+ })
+ ]
+ }
},
pwa: {
- name: 'Vue Black Dashboard',
- themeColor: '#344675',
- msTileColor: '#344675',
- appleMobileWebAppCapable: 'yes',
- appleMobileWebAppStatusBarStyle: '#344675'
+ name: "Vue Black Dashboard",
+ themeColor: "#344675",
+ msTileColor: "#344675",
+ appleMobileWebAppCapable: "yes",
+ appleMobileWebAppStatusBarStyle: "#344675"
},
pluginOptions: {
i18n: {
- locale: 'en',
- fallbackLocale: 'en',
- localeDir: 'locales',
+ locale: "en",
+ fallbackLocale: "en",
+ localeDir: "locales",
enableInSFC: false
}
},
css: {
// Enable CSS source maps.
- sourceMap: process.env.NODE_ENV !== 'production'
+ sourceMap: process.env.NODE_ENV !== "production"
}
};