From 8c0580fffbf63e84bbc789b324cf27faf4b0856b Mon Sep 17 00:00:00 2001 From: lizhixin <382352532@qq.com> Date: Sat, 29 May 2021 09:14:10 +0800 Subject: [PATCH] =?UTF-8?q?=E5=8A=A8=E9=87=8F=E8=B6=8B=E5=8A=BF/=E6=80=BB?= =?UTF-8?q?=E8=B5=84=E9=87=91=E7=AE=A1=E7=90=86/=E6=9C=BA=E5=99=A8?= =?UTF-8?q?=E4=BA=BA=E5=90=8C=E6=AD=A5=E8=AE=A2=E5=8D=95?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/pages/ReCheck/MoveTrend.vue | 40 +++++++++++ src/pages/ReCheck/index.vue | 75 +++++++++++---------- src/pages/Robot/index.vue | 91 ++++++++++++++++++++------ src/pages/prePages/js/selectoptions.js | 27 ++++---- 4 files changed, 166 insertions(+), 67 deletions(-) create mode 100644 src/pages/ReCheck/MoveTrend.vue diff --git a/src/pages/ReCheck/MoveTrend.vue b/src/pages/ReCheck/MoveTrend.vue new file mode 100644 index 0000000..c00ce66 --- /dev/null +++ b/src/pages/ReCheck/MoveTrend.vue @@ -0,0 +1,40 @@ + + diff --git a/src/pages/ReCheck/index.vue b/src/pages/ReCheck/index.vue index b2b5f05..18668ee 100644 --- a/src/pages/ReCheck/index.vue +++ b/src/pages/ReCheck/index.vue @@ -46,42 +46,10 @@ > - 执行回测 + 执行回测 重置回测 -
@@ -155,6 +123,10 @@ v-if="policyMode == 0" v-model="policyFormData" /> + @@ -221,6 +193,7 @@ import MovementPolicyForm from "../../components/MovementPolicyForm"; import moment from "moment"; import OrderTable from "./OrderTable"; import CustomBaseTable from "../../components/CustomBaseTable.vue"; +import MoveTrend from "./MoveTrend"; // import TopEndPolicy from "../components/TopEndPolicy.vue"; export default { components: { @@ -228,7 +201,8 @@ export default { AccountInfo, MovementPolicyForm, OrderTable, - CustomBaseTable + CustomBaseTable, + MoveTrend // HQKline // TopEndPolicy @@ -247,6 +221,7 @@ export default { RobotPolicyType, policyMode: 0, tradeData: [], + trendForm: {}, startTime: null, endTime: null, kLineData: {}, @@ -665,6 +640,11 @@ export default { return { kLineData: result, postData: postResult }; }, + test() { + if (this.policyMode == 0) this.executeTest(); + else if (this.policyMode == 2) this.executeTrendTest(); + }, + executeTest() { if (this.policyFormData && this.kLineDataList.length > 0) { this.spinning = true; @@ -709,6 +689,33 @@ export default { }); } }, + executeTrendTest() { + if (this.trendForm && this.kLineDataList.length > 0) { + this.$http + .post("/Api/Simulation/MomentumWaveTest", { + Capital: this.trendForm, + kLineDataList: this.kLineDataList + }) + .then(res => { + if (res.Code == 200) { + this.sMessage("success", "回测完成"); + } + this.logData = res.Data.ExecutionLogList; + res.Data.OrderList.sort( + (a, b) => b.PurchaseKLineId - a.PurchaseKLineId + ); + this.tradeData = res.Data.OrderList; + }); + } + }, + // 封装showNotification + sMessage(type, message) { + this.$notify({ + type: type, + message, + timeout: 1800 + }); + }, timepIkcer() { console.log(this.startTime, this.endTime); } diff --git a/src/pages/Robot/index.vue b/src/pages/Robot/index.vue index e767bd6..ed2033a 100644 --- a/src/pages/Robot/index.vue +++ b/src/pages/Robot/index.vue @@ -79,6 +79,9 @@ 添加机器人 + 同步所有现货订单 - - + + + + + + + +
@@ -258,26 +277,22 @@ export default { console.log(record, isOn); if (isOn) { record.Robot.Status = 1; - this.$http - .put("/Api/Robot/Start?robotId=" + record.Robot.Id) - .then(res => { - if (res.Code == 200) { - this.sMessage("success", "已启用"); - } else { - this.sMessage("danger", res.Message); - } - }); + this.$http.put("/Api/Robot/Start/" + record.Robot.Id).then(res => { + if (res.Code == 200) { + this.sMessage("success", "已启用"); + } else { + this.sMessage("danger", res.Message); + } + }); } else { record.Robot.Status = 0; - this.$http - .put("/Api/Robot/Stop?robotId=" + record.Robot.Id) - .then(res => { - if (res.Code == 200) { - this.sMessage("success", "已停用"); - } else { - this.sMessage("danger", res.Message); - } - }); + this.$http.put("/Api/Robot/Stop/" + record.Robot.Id).then(res => { + if (res.Code == 200) { + this.sMessage("success", "已停用"); + } else { + this.sMessage("danger", res.Message); + } + }); } }, @@ -317,6 +332,42 @@ export default { }); }, + //删除机器人 + removeRobot(record) { + this.$http.delete(`/Api/Robot/Remove/${record.Robot.Id}`).then(res => { + if (res.Code == 200) { + this.sMessage("success", "删除成功"); + this.getRobotList(); + } else { + this.sMessage("danger", res.Message); + } + }); + }, + + //同步机器人订单 + syncRobotOrder(record) { + this.$http + .post(`/Api/Order/SyncSpotOrderByRobotId/${record.Robot.Id}`) + .then(res => { + if (res.Code == 200) { + this.sMessage("success", "同步成功"); + } else { + this.sMessage("danger", res.Message); + } + }); + }, + + //同步所有订单 + syncAllOrder() { + this.$http.post(`/Api/Order/SyncSpotOrder`).then(res => { + if (res.Code == 200) { + this.sMessage("success", "同步成功"); + } else { + this.sMessage("danger", res.Message); + } + }); + }, + goEdit(record) { this.$router.push(`/edit/${record.Robot.Id}`); }, diff --git a/src/pages/prePages/js/selectoptions.js b/src/pages/prePages/js/selectoptions.js index fa2d86f..970fe79 100644 --- a/src/pages/prePages/js/selectoptions.js +++ b/src/pages/prePages/js/selectoptions.js @@ -1,6 +1,6 @@ export const lowestTradeType = [ { title: "投资百分比", value: 0 }, - { title: "策略均分", value: 1 }, + { title: "策略均分", value: 1 } ]; export const tradeCoinType = [{ title: "USDT", value: 0 }]; @@ -8,7 +8,7 @@ export const tradeCoinType = [{ title: "USDT", value: 0 }]; export const strategyType = [ { title: "保守", value: 4, amount: 4 }, { title: "稳健", value: 8, amount: 8 }, - { title: "激进", value: 16, amount: 16 }, + { title: "激进", value: 16, amount: 16 } ]; export const strategyArray = [ @@ -31,14 +31,14 @@ export const strategyArray = [ 4096, 8192, 16384, - 32768, - ], + 32768 + ] }, { title: "斐波那契", value: 1, - content: [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987], - }, + content: [1, 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, 144, 233, 377, 610, 987] + } ]; export const fallTime = [ @@ -51,7 +51,7 @@ export const fallTime = [ { title: "7次", value: 7 }, { title: "8次", value: 8 }, { title: "9次", value: 9 }, - { title: "10次", value: 10 }, + { title: "10次", value: 10 } ]; export const periodSignal = [ @@ -64,17 +64,17 @@ export const periodSignal = [ { title: "1day", value: 6 }, { title: "1week", value: 7 }, { title: "1mon", value: 8 }, - { title: "1year", value: 9 }, + { title: "1year", value: 9 } ]; export const orderModes = [ { title: "市价", value: 0 }, - { title: "限价", value: 1 }, + { title: "限价", value: 1 } ]; export const signals = [ { title: "看多", value: 4 }, - { title: "看空", value: 5 }, + { title: "看空", value: 5 } ]; export const accountTypes = [ @@ -87,12 +87,13 @@ export const accountTypes = [ { title: "borrowC2C杠杆借入账户", value: 6 }, { title: "minepool矿池账户", value: 7 }, { title: "etf账户", value: 8 }, - { title: "cryptoloans抵押借贷账户", value: 9 }, + { title: "cryptoloans抵押借贷账户", value: 9 } ]; export const RobotPolicyType = [ { title: "动量现货", value: 0 }, { title: "顶底策略", value: 1 }, + { title: "动量趋势", value: 2 } ]; export const ResetMomentumWaveTest = { @@ -118,7 +119,7 @@ export const ResetMomentumWaveTest = { StopBuyFloatingPLRatio: 15.0, //停止下单的浮动盈亏百分比 StopBuyTotalPurchasePriceRatio: 15.0, //停止下单的持仓占比百分比 IsEnabledTrendProfitSale: false, - TrendProfitRatio: 4, + TrendProfitRatio: 4 }; export const LogTypes = [ @@ -130,5 +131,5 @@ export const LogTypes = [ { title: "大趋势看空", value: 5 }, { title: "自动卖出", value: 10 }, { title: "自动卖出(趋势收益)", value: 11 }, - { title: "订单回调", value: 12 }, + { title: "订单回调", value: 12 } ];