Browse Source

改版

master
lizhixin 4 years ago
parent
commit
2ad976ee25
  1. 74
      src/components/Collapse/index.js
  2. 77
      src/layout/dashboard/DashboardLayout.vue
  3. 10
      src/main.js
  4. 43
      src/pages/Account/index.vue
  5. 5
      src/pages/ReCheck/MoveTrend.vue
  6. 150
      src/pages/ReCheck/index.vue
  7. 39
      src/pages/Robot/index.vue
  8. 352
      src/pages/prePages/ReCheck.vue
  9. 6
      src/router/routes.js

74
src/components/Collapse/index.js

@ -0,0 +1,74 @@
const elTransition = '0.3s height ease-in-out, 0.3s padding-top ease-in-out, 0.3s padding-bottom ease-in-out'
const Transition = {
'before-enter'(el) {
el.style.transition = elTransition
if (!el.dataset) el.dataset = {}
el.dataset.oldPaddingTop = el.style.paddingTop
el.dataset.oldPaddingBottom = el.style.paddingBottom
el.style.height = 0
el.style.paddingTop = 0
el.style.paddingBottom = 0
},
enter(el) {
el.dataset.oldOverflow = el.style.overflow
if (el.scrollHeight !== 0) {
el.style.height = el.scrollHeight + 'px'
el.style.paddingTop = el.dataset.oldPaddingTop
el.style.paddingBottom = el.dataset.oldPaddingBottom
} else {
el.style.height = ''
el.style.paddingTop = el.dataset.oldPaddingTop
el.style.paddingBottom = el.dataset.oldPaddingBottom
}
el.style.overflow = 'hidden'
},
'after-enter'(el) {
el.style.transition = ''
el.style.height = ''
el.style.overflow = el.dataset.oldOverflow
},
'before-leave'(el) {
if (!el.dataset) el.dataset = {}
el.dataset.oldPaddingTop = el.style.paddingTop
el.dataset.oldPaddingBottom = el.style.paddingBottom
el.dataset.oldOverflow = el.style.overflow
el.style.height = el.scrollHeight + 'px'
el.style.overflow = 'hidden'
},
leave(el) {
if (el.scrollHeight !== 0) {
el.style.transition = elTransition
el.style.height = 0
el.style.paddingTop = 0
el.style.paddingBottom = 0
}
},
'after-leave'(el) {
el.style.transition = ''
el.style.height = ''
el.style.overflow = el.dataset.oldOverflow
el.style.paddingTop = el.dataset.oldPaddingTop
el.style.paddingBottom = el.dataset.oldPaddingBottom
}
}
export default {
name: 'collapseTransition',
functional: true,
render(h, { children }) {
const data = {
on: Transition
}
return h('transition', data, children)
}
}

77
src/layout/dashboard/DashboardLayout.vue

@ -1,7 +1,55 @@
<template> <template>
<div class="wrapper"> <div class="wrapper">
<side-bar :backgroundColor="'#333D54'"> <side-bar :backgroundColor="'#333D54'">
<template slot="links"> <el-menu
class="el-menu-vertical-demo"
:default-openeds="['1', '2']"
background-color="#333E54"
text-color="#fff"
active-text-color="#ffd04b"
>
<el-submenu index="1">
<template slot="title">
<i class="el-icon-medal-1"></i>
<span>动量现货</span>
</template>
<el-menu-item index="1-1" @click="to('/')">概况</el-menu-item>
<el-menu-item index="1-2" @click="to('/account/0')"
>账号管理</el-menu-item
>
<el-menu-item index="1-3" @click="to('/robot/0')"
>机器人管理</el-menu-item
>
</el-submenu>
<el-submenu index="2">
<template slot="title">
<i class="el-icon-medal"></i>
<span>动量趋势</span>
</template>
<el-menu-item index="2-1" @click="to('/')">概况</el-menu-item>
<el-menu-item index="2-2" @click="to('/account/1')">
账号管理</el-menu-item
>
<el-menu-item index="2-3" @click="to('/robot/1')"
>机器人管理</el-menu-item
>
</el-submenu>
<el-menu-item index="3" @click="to('/reCheck')">
<i class="el-icon-bicycle"></i>
<span slot="title">回测</span>
</el-menu-item>
<el-menu-item index="4" @click="to('/winRate')">
<i class="el-icon-aim"></i>
<span slot="title">短线胜率测试</span>
</el-menu-item>
<el-menu-item index="5" @click="to('/capital')">
<i class="el-icon-trophy"></i>
<span slot="title">总资金管理</span>
</el-menu-item>
</el-menu>
<!-- <template slot="links">
<span @click="test = !test" class="title">动量现货</span>
<sidebar-link <sidebar-link
to="/robot" to="/robot"
:name="'策略Robot'" :name="'策略Robot'"
@ -27,15 +75,7 @@
:name="'总资金管理'" :name="'总资金管理'"
icon="tim-icons icon-single-02" icon="tim-icons icon-single-02"
/> />
</template> -->
<!-- <sidebar-link to="/icons" :name="$t('sidebar.icons')" icon="tim-icons icon-atom"/>
<sidebar-link to="/maps" :name="$t('sidebar.maps')" icon="tim-icons icon-pin"/>
<sidebar-link to="/notifications" :name="$t('sidebar.notifications')" icon="tim-icons icon-bell-55"/>
<sidebar-link to="/profile" :name="$t('sidebar.userProfile')" icon="tim-icons icon-single-02"/>
<sidebar-link to="/table-list" :name="$t('sidebar.tableList')" icon="tim-icons icon-puzzle-10"/>
<sidebar-link to="/typography" :name="$t('sidebar.typography')" icon="tim-icons icon-align-center"/>
<sidebar-link to="/dashboard?enableRTL=true" :name="$t('sidebar.rtlSupport')" icon="tim-icons icon-world"/> -->
</template>
</side-bar> </side-bar>
<div class="main-panel"> <div class="main-panel">
<top-navbar></top-navbar> <top-navbar></top-navbar>
@ -52,18 +92,26 @@ import TopNavbar from "./TopNavbar.vue";
import ContentFooter from "./ContentFooter.vue"; import ContentFooter from "./ContentFooter.vue";
import DashboardContent from "./Content.vue"; import DashboardContent from "./Content.vue";
import MobileMenu from "./MobileMenu"; import MobileMenu from "./MobileMenu";
import Collapse from "../../components/Collapse";
export default { export default {
components: { components: {
TopNavbar, TopNavbar,
ContentFooter, ContentFooter,
DashboardContent, DashboardContent,
MobileMenu MobileMenu,
Collapse
},
data() {
return { test: false };
}, },
methods: { methods: {
toggleSidebar() { toggleSidebar() {
if (this.$sidebar.showSidebar) { if (this.$sidebar.showSidebar) {
this.$sidebar.displaySidebar(false); this.$sidebar.displaySidebar(false);
} }
},
to(path) {
if (this.$route.path != path.toLowerCase()) this.$router.push({ path });
} }
} }
}; };
@ -73,4 +121,11 @@ export default {
.off-canvas-sidebar { .off-canvas-sidebar {
background: linear-gradient(0deg, #333 0%, #333 100%) !important; background: linear-gradient(0deg, #333 0%, #333 100%) !important;
} }
.title {
cursor: pointer;
margin-left: 20px;
}
.el-menu {
border-right: none !important;
}
</style> </style>

10
src/main.js

@ -30,7 +30,11 @@ import {
Tabs, Tabs,
TabPane, TabPane,
Pagination, Pagination,
DatePicker DatePicker,
Menu,
MenuItem,
MenuItemGroup,
Submenu
} from "element-ui"; } from "element-ui";
import "element-ui/lib/theme-chalk/index.css"; import "element-ui/lib/theme-chalk/index.css";
import i18n from "./i18n"; import i18n from "./i18n";
@ -49,6 +53,10 @@ Vue.use(Tabs);
Vue.use(TabPane); Vue.use(TabPane);
Vue.use(Pagination); Vue.use(Pagination);
Vue.use(DatePicker); Vue.use(DatePicker);
Vue.use(Menu);
Vue.use(MenuItem);
Vue.use(MenuItemGroup);
Vue.use(Submenu);
/* eslint-disable no-new */ /* eslint-disable no-new */
new Vue({ new Vue({
router, router,

43
src/pages/Account/index.vue

@ -64,9 +64,7 @@
</card> </card>
</modal> </modal>
<base-button @click="modal.visible = true" <base-button @click="modal.visible = true">添加账号</base-button>
>添加账号</base-button
>
<custom-base-table <custom-base-table
:data="tableData" :data="tableData"
@ -100,6 +98,7 @@ export default {
components: { CustomBaseTable, Modal }, components: { CustomBaseTable, Modal },
data() { data() {
return { return {
type: 0,
tableData: [], tableData: [],
form: {}, form: {},
accountTypes, accountTypes,
@ -111,6 +110,7 @@ export default {
}; };
}, },
created() { created() {
this.type = this.$route.params.type;
this.getAccountList(); this.getAccountList();
// this.getAllSymbol(); // this.getAllSymbol();
// this.getAccountList(); // this.getAccountList();
@ -119,11 +119,13 @@ export default {
methods: { methods: {
// //
getAccountList() { getAccountList() {
this.$http.get("/Api/StockExchangeAccount/GetList").then(res => { this.$http
if (res.Code == 200) { .get(`/Api/StockExchangeAccount/GetList?policyType=${this.type}`)
this.tableData = res.Data; .then(res => {
} if (res.Code == 200) {
}); this.tableData = res.Data;
}
});
}, },
getMatchTitle(value, sourceArray) { getMatchTitle(value, sourceArray) {
@ -137,16 +139,21 @@ export default {
// //
createRobot() { createRobot() {
this.createLoading = true; this.createLoading = true;
this.$http.post("/Api/StockExchangeAccount/Add", this.form).then(res => { this.$http
this.createLoading = false; .post("/Api/StockExchangeAccount/Add", {
if (res.Code == 200) { ...this.form,
this.modal.visible = false; PolicyType: this.type
this.sMessage("success", "创建成功"); })
this.getAccountList(); .then(res => {
} else { this.createLoading = false;
this.sMessage("danger", res.Message); if (res.Code == 200) {
} this.modal.visible = false;
}); this.sMessage("success", "创建成功");
this.getAccountList();
} else {
this.sMessage("danger", res.Message);
}
});
}, },
// showNotification // showNotification

5
src/pages/ReCheck/MoveTrend.vue

@ -26,7 +26,10 @@
export default { export default {
model: { prop: "form", event: "formChange" }, model: { prop: "form", event: "formChange" },
props: { props: {
form: { type: Object, default: () => {} } form: {
type: Object,
default: () => {}
}
}, },
watch: { watch: {
form() { form() {

150
src/pages/ReCheck/index.vue

@ -161,10 +161,13 @@
<custom-base-table <custom-base-table
size="small" size="small"
:columns="logColumns" :columns="logColumns"
:dataSource="logData.filter(logShowCondition)" :data="logData.filter(logShowCondition)"
tbodyClasses="cTable"
> >
<template slot="LogType" slot-scope="text"> <template slot="LogType" slot-scope="item">
{{ LogTypes.filter(item => item.value == text)[0].title }} {{
LogTypes.filter(i => i.value == item.row.item.LogType)[0].title
}}
</template> </template>
</custom-base-table> </custom-base-table>
</el-tab-pane> </el-tab-pane>
@ -221,7 +224,12 @@ export default {
RobotPolicyType, RobotPolicyType,
policyMode: 0, policyMode: 0,
tradeData: [], tradeData: [],
trendForm: {}, trendForm: {
NowCapital: 10000,
OriginalCapital: 12000,
FrozenProfit: 12,
TradeAmountRatio: 50
},
startTime: null, startTime: null,
endTime: null, endTime: null,
kLineData: {}, kLineData: {},
@ -296,25 +304,25 @@ export default {
this.kLinesFromExcels.some(item => item.name == model) this.kLinesFromExcels.some(item => item.name == model)
) { ) {
let result = []; let result = [];
if (this.policyMode == 0) { // if (this.policyMode == 0) {
let data = this.kLinesFromExcels.filter(item => item.name == model)[0] let data = this.kLinesFromExcels.filter(item => item.name == model)[0]
.data; .data;
let temp = this.mutateData(data); //datadata let temp = this.mutateData(data); //datadata
result = this.splitData(temp.kLineData); //data result = this.splitData(temp.kLineData); //data
this.kLineDataList = temp.postData; this.kLineDataList = temp.postData;
this.kLineData = result; this.kLineData = result;
} else { // } else {
let index = 0; // let index = 0;
for (let i = 0; i < this.kLinesFromExcels.length; i++) { // for (let i = 0; i < this.kLinesFromExcels.length; i++) {
if (this.kLinesFromExcels[i].name == model) { // if (this.kLinesFromExcels[i].name == model) {
index = i; // index = i;
break; // break;
} // }
} // }
let temp = this.topMutateData(this.topTempDataList[index]); // let temp = this.topMutateData(this.topTempDataList[index]);
result = this.splitData(temp.kLineData); //data // result = this.splitData(temp.kLineData); //data
this.kLineData = result; // this.kLineData = result;
} // }
} }
}, },
excelImport() { excelImport() {
@ -324,28 +332,28 @@ export default {
Excel.importExcel(data => { Excel.importExcel(data => {
that.spinning = false; that.spinning = false;
if (data && data[0]) { if (data && data[0]) {
if (this.policyMode == 1) { // if (this.policyMode == 1) {
this.kLinesFromExcels = data; // this.kLinesFromExcels = data;
this.lineSelect = data[0].name; // this.lineSelect = data[0].name;
let _data = []; // let _data = [];
data.forEach(element => { // data.forEach(element => {
_data.push(element.data); // _data.push(element.data);
}); // });
this.topEndMutateData(_data); // this.topEndMutateData(_data);
console.log("final", _data); // console.log("final", _data);
this.topTempDataList = _data; // this.topTempDataList = _data;
let temp = that.topMutateData(_data[0]); // let temp = that.topMutateData(_data[0]);
result = this.splitData(temp.kLineData); //data // result = this.splitData(temp.kLineData); //data
this.kLineData = result; // this.kLineData = result;
} else { // } else {
this.kLinesFromExcels = data; this.kLinesFromExcels = data;
this.lineSelect = data[0].name; this.lineSelect = data[0].name;
let temp = that.mutateData(data[0].data); //datadata let temp = that.mutateData(data[0].data); //datadata
result = this.splitData(temp.kLineData); //data result = this.splitData(temp.kLineData); //data
console.log("what i got", result); console.log("what i got", result);
this.kLineDataList = temp.postData; this.kLineDataList = temp.postData;
this.kLineData = result; this.kLineData = result;
} // }
} }
}); });
}, },
@ -439,6 +447,7 @@ export default {
}, },
// //
//5- 6- 7- 8- 9- 10- 12-
mutateData(data) { mutateData(data) {
let result = []; let result = [];
let postResult = []; let postResult = [];
@ -453,14 +462,16 @@ export default {
this.startTime && this.startTime &&
this.endTime && this.endTime &&
!moment(data[i][j] * 1000).isBetween( !moment(data[i][j] * 1000).isBetween(
moment(this.startTime), this.startTime.startOf("day"),
moment(this.endTime) this.endTime.endOf("day")
) )
) { ) {
break; break;
} else if ( } else if (
this.startTime && this.startTime &&
!moment(data[i][j] * 1000).isAfter(moment(this.startTime)) !moment(data[i][j] * 1000).isAfter(
this.startTime.startOf("day")
)
) { ) {
break; break;
} }
@ -485,12 +496,32 @@ export default {
//close //close
subArray[2] = data[i][j]; subArray[2] = data[i][j];
postObj.C = data[i][j]; postObj.C = data[i][j];
} else if (j == 5) {
postObj.STP = data[i][j];
} else if (j == 6) {
postObj.MTP = data[i][j];
} else if (j == 7) { } else if (j == 7) {
postObj.TP = data[i][j]; postObj.BTP = data[i][j];
} else if (j == 13) { } else if (j == 8) {
if (data[i][j] != 0) postObj.N = 3; if (
} else if (j == 11) { data[i][j] != 0 &&
data[i][j] &&
data[i][j] != "NaN" &&
data[i][j] != NaN
)
postObj.N = 10;
} else if (j == 9) {
if (
data[i][j] != 0 &&
data[i][j] &&
data[i][j] != "NaN" &&
data[i][j] != NaN
)
postObj.N = 11;
} else if (j == 10) {
if (data[i][j] != 0) postObj.N = 2; if (data[i][j] != 0) postObj.N = 2;
} else if (j == 12) {
if (data[i][j] != 0) postObj.N = 3;
} else if (j == 15) { } else if (j == 15) {
subArray[5] = {}; subArray[5] = {};
if (data[i][j] != 0) { if (data[i][j] != 0) {
@ -692,8 +723,12 @@ export default {
executeTrendTest() { executeTrendTest() {
if (this.trendForm && this.kLineDataList.length > 0) { if (this.trendForm && this.kLineDataList.length > 0) {
this.$http this.$http
.post("/Api/Simulation/MomentumWaveTest", { .post("/Api/Simulation/MomentumTrendTest", {
Capital: this.trendForm, Capital: {
...this.trendForm,
FrozenProfit: this.trendForm.FrozenProfit / 100,
TradeAmountRatio: this.trendForm.TradeAmountRatio / 100
},
kLineDataList: this.kLineDataList kLineDataList: this.kLineDataList
}) })
.then(res => { .then(res => {
@ -723,4 +758,9 @@ export default {
}; };
</script> </script>
<style></style> <style>
.cTable {
height: 500px;
overflow: hidden;
}
</style>

39
src/pages/Robot/index.vue

@ -225,10 +225,12 @@ export default {
allSymbol: [], allSymbol: [],
modal: { visible: false }, modal: { visible: false },
createLoading: false, createLoading: false,
columns: tableColumns columns: tableColumns,
type: 0 //0- 1-
}; };
}, },
created() { created() {
this.type = this.$route.params.type;
this.getRobotList(); this.getRobotList();
this.getAllSymbol(); this.getAllSymbol();
this.getAccountList(); this.getAccountList();
@ -237,11 +239,13 @@ export default {
methods: { methods: {
// //
getAccountList() { getAccountList() {
this.$http.get("/Api/StockExchangeAccount/GetList").then(res => { this.$http
if (res.Code == 200) { .get(`/Api/StockExchangeAccount/GetList?policyType=${this.type}`)
this.accountList = res.Data; .then(res => {
} if (res.Code == 200) {
}); this.accountList = res.Data;
}
});
}, },
// //
@ -256,12 +260,23 @@ export default {
// //
getRobotList() { getRobotList() {
// this.spinning = true; // this.spinning = true;
this.$http.get("/Api/Robot/GetMomentumWaveTradeRobotList").then(res => { if (this.type == 0) {
// this.spinning = false; this.$http.get("/Api/Robot/GetMomentumWaveTradeRobotList").then(res => {
if (res.Code == 200) { // this.spinning = false;
this.tableData = res.Data; if (res.Code == 200) {
} this.tableData = res.Data;
}); }
});
} else {
this.$http
.get("/Api/Robot/GetMomentumTrendTradeRobotList")
.then(res => {
// this.spinning = false;
if (res.Code == 200) {
this.tableData = res.Data;
}
});
}
}, },
getMatchTitle(value, sourceArray) { getMatchTitle(value, sourceArray) {

352
src/pages/prePages/ReCheck.vue

@ -177,7 +177,7 @@
:dataSource="logData.filter(logShowCondition)" :dataSource="logData.filter(logShowCondition)"
> >
<template slot="LogType" slot-scope="text"> <template slot="LogType" slot-scope="text">
{{ LogTypes.filter((item) => item.value == text)[0].title }} {{ LogTypes.filter(item => item.value == text)[0].title }}
</template> </template>
</a-table> </a-table>
</a-tab-pane> </a-tab-pane>
@ -257,7 +257,7 @@ import { secToMin } from "../utils/TimeUtils";
import { import {
RobotPolicyType, RobotPolicyType,
ResetMomentumWaveTest, ResetMomentumWaveTest,
LogTypes, LogTypes
} from "./js/selectoptions"; } from "./js/selectoptions";
import MomentumWavePolicy from "../components/MomentumWavePolicy"; import MomentumWavePolicy from "../components/MomentumWavePolicy";
import moment from "moment"; import moment from "moment";
@ -289,12 +289,12 @@ export default {
topTempDataList: [], topTempDataList: [],
buyPointCountList: [], buyPointCountList: [],
salePointCountList: [], salePointCountList: [],
logShowCondition: (i) => true, logShowCondition: i => true
}; };
}, },
methods: { methods: {
onOk(value) { onOk(value) {
this.logShowCondition = (item) => this.logShowCondition = item =>
moment(item.CreateTime).isBetween(value[0], value[1]); moment(item.CreateTime).isBetween(value[0], value[1]);
}, },
changeFilter(value, type) { changeFilter(value, type) {
@ -314,9 +314,7 @@ export default {
if (buyKey && JSON.stringify(buyKey) != "{}") { if (buyKey && JSON.stringify(buyKey) != "{}") {
keyPoint.push(buyKey); keyPoint.push(buyKey);
if ( if (!this.buyPointCountList.some(item => item.value == buyKey.value))
!this.buyPointCountList.some((item) => item.value == buyKey.value)
)
this.buyPointCountList.push(buyKey); this.buyPointCountList.push(buyKey);
} }
@ -324,7 +322,7 @@ export default {
if (saleKey && JSON.stringify(saleKey) != "{}") { if (saleKey && JSON.stringify(saleKey) != "{}") {
keyPoint.push(saleKey); keyPoint.push(saleKey);
if ( if (
!this.salePointCountList.some((item) => item.value == saleKey.value) !this.salePointCountList.some(item => item.value == saleKey.value)
) )
this.salePointCountList.push(saleKey); this.salePointCountList.push(saleKey);
} }
@ -334,12 +332,12 @@ export default {
console.log({ console.log({
categoryData, categoryData,
values, values,
keyPoint, keyPoint
}); });
return { return {
categoryData, categoryData,
values, values,
keyPoint, keyPoint
}; };
}, },
//excel //excel
@ -348,60 +346,59 @@ export default {
if ( if (
this.kLinesFromExcels && this.kLinesFromExcels &&
this.kLinesFromExcels.length > 0 && this.kLinesFromExcels.length > 0 &&
this.kLinesFromExcels.some((item) => item.name == model) this.kLinesFromExcels.some(item => item.name == model)
) { ) {
let result = []; let result = [];
if (this.policyMode == 0) { // if (this.policyMode == 0 ) {
let data = this.kLinesFromExcels.filter( let data = this.kLinesFromExcels.filter(item => item.name == model)[0]
(item) => item.name == model .data;
)[0].data; let temp = this.mutateData(data); //datadata
let temp = this.mutateData(data); //datadata result = this.splitData(temp.kLineData); //data
result = this.splitData(temp.kLineData); //data this.kLineDataList = temp.postData;
this.kLineDataList = temp.postData; this.kLineData = result;
this.kLineData = result; // } else {
} else { // let index = 0;
let index = 0; // for (let i = 0; i < this.kLinesFromExcels.length; i++) {
for (let i = 0; i < this.kLinesFromExcels.length; i++) { // if (this.kLinesFromExcels[i].name == model) {
if (this.kLinesFromExcels[i].name == model) { // index = i;
index = i; // break;
break; // }
} // }
} // let temp = this.topMutateData(this.topTempDataList[index]);
let temp = this.topMutateData(this.topTempDataList[index]); // result = this.splitData(temp.kLineData); //data
result = this.splitData(temp.kLineData); //data // this.kLineData = result;
this.kLineData = result; // }
}
} }
}, },
excelImport() { excelImport() {
let that = this; let that = this;
let result = []; let result = [];
this.spinning = true; this.spinning = true;
Excel.importExcel((data) => { Excel.importExcel(data => {
that.spinning = false; that.spinning = false;
if (data && data[0]) { if (data && data[0]) {
if (this.policyMode == 1) { // if (this.policyMode == 1) {
this.kLinesFromExcels = data; // this.kLinesFromExcels = data;
this.lineSelect = data[0].name; // this.lineSelect = data[0].name;
let _data = []; // let _data = [];
data.forEach((element) => { // data.forEach(element => {
_data.push(element.data); // _data.push(element.data);
}); // });
this.topEndMutateData(_data); // this.topEndMutateData(_data);
console.log("final", _data); // console.log("final", _data);
this.topTempDataList = _data; // this.topTempDataList = _data;
let temp = that.topMutateData(_data[0]); // let temp = that.topMutateData(_data[0]);
result = this.splitData(temp.kLineData); //data // result = this.splitData(temp.kLineData); //data
this.kLineData = result; // this.kLineData = result;
} else { // } else {
this.kLinesFromExcels = data; this.kLinesFromExcels = data;
this.lineSelect = data[0].name; this.lineSelect = data[0].name;
let temp = that.mutateData(data[0].data); //datadata let temp = that.mutateData(data[0].data); //datadata
result = this.splitData(temp.kLineData); //data result = this.splitData(temp.kLineData); //data
console.log("what i got", result); console.log("what i got", result);
this.kLineDataList = temp.postData; this.kLineDataList = temp.postData;
this.kLineData = result; this.kLineData = result;
} // }
} }
}); });
}, },
@ -495,6 +492,7 @@ export default {
}, },
// //
//5- 6- 7- 8- 9- 10- 12-
mutateData(data) { mutateData(data) {
let result = []; let result = [];
let postResult = []; let postResult = [];
@ -543,12 +541,32 @@ export default {
//close //close
subArray[2] = data[i][j]; subArray[2] = data[i][j];
postObj.C = data[i][j]; postObj.C = data[i][j];
} else if (j == 5) {
postObj.STP = data[i][j];
} else if (j == 6) {
postObj.MTP = data[i][j];
} else if (j == 7) { } else if (j == 7) {
postObj.TP = data[i][j]; postObj.BTP = data[i][j];
} else if (j == 13) { } else if (j == 8) {
if (data[i][j] != 0) postObj.N = 3; if (
} else if (j == 11) { data[i][j] != 0 &&
data[i][j] &&
data[i][j] != "NaN" &&
data[i][j] != NaN
)
postObj.N = 10;
} else if (j == 9) {
if (
data[i][j] != 0 &&
data[i][j] &&
data[i][j] != "NaN" &&
data[i][j] != NaN
)
postObj.N = 11;
} else if (j == 10) {
if (data[i][j] != 0) postObj.N = 2; if (data[i][j] != 0) postObj.N = 2;
} else if (j == 12) {
if (data[i][j] != 0) postObj.N = 3;
} else if (j == 15) { } else if (j == 15) {
subArray[5] = {}; subArray[5] = {};
if (data[i][j] != 0) { if (data[i][j] != 0) {
@ -559,12 +577,12 @@ export default {
`${moment(data[i][0] * 1000).format( `${moment(data[i][0] * 1000).format(
"YYYY-MM-DD HH:mm:ss" "YYYY-MM-DD HH:mm:ss"
)}`, )}`,
data[i][2], data[i][2]
], ],
value: "1", value: "1",
itemStyle: { itemStyle: {
color: "rgb(23,160,93)", color: "rgb(23,160,93)"
}, }
}; };
} }
} else if (j == 14) { } else if (j == 14) {
@ -580,12 +598,12 @@ export default {
`${moment(data[i][0] * 1000).format( `${moment(data[i][0] * 1000).format(
"YYYY-MM-DD HH:mm:ss" "YYYY-MM-DD HH:mm:ss"
)}`, )}`,
data[i][3], data[i][3]
], ],
value: "0", value: "0",
itemStyle: { itemStyle: {
color: "rgb(221,82,70)", color: "rgb(221,82,70)"
}, }
}; };
} }
} }
@ -598,105 +616,105 @@ export default {
}, },
// //
topMutateData(data) { // topMutateData(data) {
let result = []; // let result = [];
let postResult = []; // let postResult = [];
if (data.length > 1) { // if (data.length > 1) {
for (let i = 0; i < data.length; i++) { // for (let i = 0; i < data.length; i++) {
if (i == 0) continue; // if (i == 0) continue;
let subArray = []; // let subArray = [];
let postObj = { N: null }; // let postObj = { N: null };
for (let j = 0; j < data[i].length; j++) { // for (let j = 0; j < data[i].length; j++) {
if (j == 0) { // if (j == 0) {
if ( // if (
this.startTime && // this.startTime &&
this.endTime && // this.endTime &&
!moment(data[i][j] * 1000).isBetween( // !moment(data[i][j] * 1000).isBetween(
this.startTime.startOf("day"), // this.startTime.startOf("day"),
this.endTime.endOf("day") // this.endTime.endOf("day")
) // )
) { // ) {
break; // break;
} else if ( // } else if (
this.startTime && // this.startTime &&
!moment(data[i][j] * 1000).isAfter( // !moment(data[i][j] * 1000).isAfter(
this.startTime.startOf("day") // this.startTime.startOf("day")
) // )
) { // ) {
break; // break;
} // }
subArray[0] = moment(data[i][j] * 1000).format( // subArray[0] = moment(data[i][j] * 1000).format(
"YYYY-MM-DD HH:mm:ss" // "YYYY-MM-DD HH:mm:ss"
); // );
postObj.T = data[i][j]; // postObj.T = data[i][j];
} else if (j == 1) { // } else if (j == 1) {
//open // //open
subArray[1] = data[i][j]; // subArray[1] = data[i][j];
postObj.OpenPrice = data[i][j]; // postObj.OpenPrice = data[i][j];
} else if (j == 2) { // } else if (j == 2) {
//highest // //highest
subArray[4] = data[i][j]; // subArray[4] = data[i][j];
postObj.H = data[i][j]; // postObj.H = data[i][j];
} else if (j == 3) { // } else if (j == 3) {
//lowest // //lowest
subArray[3] = data[i][j]; // subArray[3] = data[i][j];
postObj.L = data[i][j]; // postObj.L = data[i][j];
} else if (j == 4) { // } else if (j == 4) {
//close // //close
subArray[2] = data[i][j]; // subArray[2] = data[i][j];
postObj.C = data[i][j]; // postObj.C = data[i][j];
} else if (j == 5) { // } else if (j == 5) {
postObj.TP = data[i][j]; // postObj.TP = data[i][j];
} else if (j == 6) { // } else if (j == 6) {
if (data[i][j] != 0) postObj.N = 3; // if (data[i][j] != 0) postObj.N = 3;
} else if (j == 7) { // } else if (j == 7) {
subArray[5] = {}; // subArray[5] = {};
if (data[i][j] && data[i][j] != 0) { // if (data[i][j] && data[i][j] != 0) {
postObj.N = 1; // postObj.N = 1;
subArray[5] = { // subArray[5] = {
name: "买入Point", // name: "Point",
coord: [ // coord: [
`${moment(data[i][0] * 1000).format( // `${moment(data[i][0] * 1000).format(
"YYYY-MM-DD HH:mm:ss" // "YYYY-MM-DD HH:mm:ss"
)}`, // )}`,
data[i][3], // data[i][3]
], // ],
value: data[i][j], // value: data[i][j],
itemStyle: { // itemStyle: {
color: "rgb(23,160,93)", // color: "rgb(23,160,93)"
}, // }
}; // };
} // }
} else if (j == 8) { // } else if (j == 8) {
subArray[6] = {}; // subArray[6] = {};
if (data[i][j] && data[i][j] != 0) { // if (data[i][j] && data[i][j] != 0) {
postObj.N = 0; // postObj.N = 0;
subArray[6] = { // subArray[6] = {
name: "卖出Point", // name: "Point",
symbol: "diamond", // symbol: "diamond",
symbolSize: [15, 25], // symbolSize: [15, 25],
symbolOffset: [0, 25], // symbolOffset: [0, 25],
coord: [ // coord: [
`${moment(data[i][0] * 1000).format( // `${moment(data[i][0] * 1000).format(
"YYYY-MM-DD HH:mm:ss" // "YYYY-MM-DD HH:mm:ss"
)}`, // )}`,
data[i][2], // data[i][2]
], // ],
value: data[i][j], // value: data[i][j],
itemStyle: { // itemStyle: {
color: "rgb(221,82,70)", // color: "rgb(221,82,70)"
}, // }
}; // };
} // }
} // }
} // }
if (subArray.length > 0) result.push(subArray); // if (subArray.length > 0) result.push(subArray);
if (postObj.T != null) postResult.push(postObj); // if (postObj.T != null) postResult.push(postObj);
} // }
} // }
return { kLineData: result, postData: postResult }; // return { kLineData: result, postData: postResult };
}, // },
executeTest() { executeTest() {
if (this.policyFormData && this.kLineDataList.length > 0) { if (this.policyFormData && this.kLineDataList.length > 0) {
@ -704,10 +722,10 @@ export default {
this.$http this.$http
.post("/Api/Simulation/MomentumWaveTest", { .post("/Api/Simulation/MomentumWaveTest", {
MomentumWavePolicy: this.policyFormData, MomentumWavePolicy: this.policyFormData,
kLineDataList: this.kLineDataList, kLineDataList: this.kLineDataList
}) })
.then((res) => { .then(res => {
this.logShowCondition = (i) => true; this.logShowCondition = i => true;
this.spinning = false; this.spinning = false;
if (res.Code == 200) { if (res.Code == 200) {
console.log("回测成功"); console.log("回测成功");
@ -741,8 +759,8 @@ export default {
} }
}); });
} }
}, }
}, }
}; };
</script> </script>

6
src/router/routes.js

@ -20,10 +20,10 @@ const routes = [
{ {
path: "/", path: "/",
component: DashboardLayout, component: DashboardLayout,
redirect: "/Robot", redirect: "/robot/0",
children: [ children: [
{ {
path: "robot", path: "robot/:type",
name: "robot", name: "robot",
component: Robot component: Robot
}, },
@ -38,7 +38,7 @@ const routes = [
component: WinRate component: WinRate
}, },
{ {
path: "account", path: "account/:type",
name: "account", name: "account",
component: Account component: Account
}, },

Loading…
Cancel
Save