Browse Source

动量趋势/总资金管理/机器人同步订单

master
lizhixin 4 years ago
parent
commit
8c0580fffb
  1. 40
      src/pages/ReCheck/MoveTrend.vue
  2. 75
      src/pages/ReCheck/index.vue
  3. 67
      src/pages/Robot/index.vue
  4. 27
      src/pages/prePages/js/selectoptions.js

40
src/pages/ReCheck/MoveTrend.vue

@ -0,0 +1,40 @@
<template>
<div>
<base-input
label="现有资金"
placeholder="现有资金"
v-model="form.NowCapital"
></base-input>
<base-input
label="原始资金"
placeholder="原始资金"
v-model="form.OriginalCapital"
></base-input>
<base-input
label="冻结利润比(%)"
placeholder="冻结利润比"
v-model="form.FrozenProfit"
></base-input>
<base-input
label="下单金额比(%)"
placeholder="下单金额比(%)"
v-model="form.TradeAmountRatio"
></base-input>
</div>
</template>
<script>
export default {
model: { prop: "form", event: "formChange" },
props: {
form: { type: Object, default: () => {} }
},
watch: {
form() {
this.$emit("formChange", this.form);
}
},
data() {
return {};
}
};
</script>

75
src/pages/ReCheck/index.vue

@ -46,42 +46,10 @@
> >
</el-option> </el-option>
</el-select> </el-select>
<base-button @click="executeTest" class="ml-2">执行回测</base-button> <base-button @click="test" class="ml-2">执行回测</base-button>
<base-button class="ml-2">重置回测</base-button> <base-button class="ml-2">重置回测</base-button>
</div> </div>
</div> </div>
<!-- <a-row type="flex">
<a-col :span="16">
<a-row type="flex"
><a-col><a-button @click="excelImport">导入数据源</a-button></a-col
><a-col :offset="1"
><a-date-picker v-model="startTime"></a-date-picker></a-col
><a-col :offset="1"
><a-date-picker v-model="endTime"></a-date-picker></a-col
><a-col :offset="1"
><a-select
v-model="policyMode"
placeholder="选择策略"
style="width:160px"
>
<a-select-option
v-for="i in RobotPolicyType"
:key="i.value"
:value="i.value"
>
{{ i.title }}</a-select-option
>
</a-select></a-col
>
</a-row></a-col
>
<a-col :span="4">
<a-row type="flex">
<a-col><a-button @click="executeTest">执行回测</a-button></a-col>
<a-col :offset="1"> <a-button>重置回测</a-button></a-col>
</a-row>
</a-col>
</a-row> -->
<div> <div>
<el-tabs value="1"> <el-tabs value="1">
@ -155,6 +123,10 @@
v-if="policyMode == 0" v-if="policyMode == 0"
v-model="policyFormData" v-model="policyFormData"
/> />
<move-trend
v-else-if="policyMode == 2"
v-model="trendForm"
></move-trend>
<!-- <top-end-policy v-else v-model="policyFormData" /> --> <!-- <top-end-policy v-else v-model="policyFormData" /> -->
</el-tab-pane> </el-tab-pane>
</el-tabs> </el-tabs>
@ -221,6 +193,7 @@ import MovementPolicyForm from "../../components/MovementPolicyForm";
import moment from "moment"; import moment from "moment";
import OrderTable from "./OrderTable"; import OrderTable from "./OrderTable";
import CustomBaseTable from "../../components/CustomBaseTable.vue"; import CustomBaseTable from "../../components/CustomBaseTable.vue";
import MoveTrend from "./MoveTrend";
// import TopEndPolicy from "../components/TopEndPolicy.vue"; // import TopEndPolicy from "../components/TopEndPolicy.vue";
export default { export default {
components: { components: {
@ -228,7 +201,8 @@ export default {
AccountInfo, AccountInfo,
MovementPolicyForm, MovementPolicyForm,
OrderTable, OrderTable,
CustomBaseTable CustomBaseTable,
MoveTrend
// HQKline // HQKline
// TopEndPolicy // TopEndPolicy
@ -247,6 +221,7 @@ export default {
RobotPolicyType, RobotPolicyType,
policyMode: 0, policyMode: 0,
tradeData: [], tradeData: [],
trendForm: {},
startTime: null, startTime: null,
endTime: null, endTime: null,
kLineData: {}, kLineData: {},
@ -665,6 +640,11 @@ export default {
return { kLineData: result, postData: postResult }; return { kLineData: result, postData: postResult };
}, },
test() {
if (this.policyMode == 0) this.executeTest();
else if (this.policyMode == 2) this.executeTrendTest();
},
executeTest() { executeTest() {
if (this.policyFormData && this.kLineDataList.length > 0) { if (this.policyFormData && this.kLineDataList.length > 0) {
this.spinning = true; 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() { timepIkcer() {
console.log(this.startTime, this.endTime); console.log(this.startTime, this.endTime);
} }

67
src/pages/Robot/index.vue

@ -79,6 +79,9 @@
</modal> </modal>
<base-button @click="modal.visible = true">添加机器人</base-button> <base-button @click="modal.visible = true">添加机器人</base-button>
<base-button @click="syncAllOrder" class="ml-4"
>同步所有现货订单</base-button
>
<custom-base-table <custom-base-table
:data="tableData" :data="tableData"
@ -147,11 +150,27 @@
</base-button> </base-button>
</el-tooltip> </el-tooltip>
<el-tooltip content="删除" :open-delay="300" placement="top"> <el-tooltip
<base-button type="danger" size="sm" icon> content="删除"
:open-delay="300"
placement="top"
style="marginRight:5px"
>
<base-button
type="danger"
size="sm"
icon
@click="removeRobot(item.row.item)"
>
<i class="tim-icons icon-simple-remove"></i> <i class="tim-icons icon-simple-remove"></i>
</base-button> </base-button>
</el-tooltip> </el-tooltip>
<el-tooltip content="同步订单" :open-delay="300" placement="top">
<base-button size="sm" icon @click="syncRobotOrder(item.row.item)">
<i class="tim-icons icon-paper"></i>
</base-button>
</el-tooltip>
</template> </template>
</custom-base-table> </custom-base-table>
</div> </div>
@ -258,9 +277,7 @@ export default {
console.log(record, isOn); console.log(record, isOn);
if (isOn) { if (isOn) {
record.Robot.Status = 1; record.Robot.Status = 1;
this.$http this.$http.put("/Api/Robot/Start/" + record.Robot.Id).then(res => {
.put("/Api/Robot/Start?robotId=" + record.Robot.Id)
.then(res => {
if (res.Code == 200) { if (res.Code == 200) {
this.sMessage("success", "已启用"); this.sMessage("success", "已启用");
} else { } else {
@ -269,9 +286,7 @@ export default {
}); });
} else { } else {
record.Robot.Status = 0; record.Robot.Status = 0;
this.$http this.$http.put("/Api/Robot/Stop/" + record.Robot.Id).then(res => {
.put("/Api/Robot/Stop?robotId=" + record.Robot.Id)
.then(res => {
if (res.Code == 200) { if (res.Code == 200) {
this.sMessage("success", "已停用"); this.sMessage("success", "已停用");
} else { } else {
@ -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) { goEdit(record) {
this.$router.push(`/edit/${record.Robot.Id}`); this.$router.push(`/edit/${record.Robot.Id}`);
}, },

27
src/pages/prePages/js/selectoptions.js

@ -1,6 +1,6 @@
export const lowestTradeType = [ export const lowestTradeType = [
{ title: "投资百分比", value: 0 }, { title: "投资百分比", value: 0 },
{ title: "策略均分", value: 1 }, { title: "策略均分", value: 1 }
]; ];
export const tradeCoinType = [{ title: "USDT", value: 0 }]; export const tradeCoinType = [{ title: "USDT", value: 0 }];
@ -8,7 +8,7 @@ export const tradeCoinType = [{ title: "USDT", value: 0 }];
export const strategyType = [ export const strategyType = [
{ title: "保守", value: 4, amount: 4 }, { title: "保守", value: 4, amount: 4 },
{ title: "稳健", value: 8, amount: 8 }, { title: "稳健", value: 8, amount: 8 },
{ title: "激进", value: 16, amount: 16 }, { title: "激进", value: 16, amount: 16 }
]; ];
export const strategyArray = [ export const strategyArray = [
@ -31,14 +31,14 @@ export const strategyArray = [
4096, 4096,
8192, 8192,
16384, 16384,
32768, 32768
], ]
}, },
{ {
title: "斐波那契", title: "斐波那契",
value: 1, 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 = [ export const fallTime = [
@ -51,7 +51,7 @@ export const fallTime = [
{ title: "7次", value: 7 }, { title: "7次", value: 7 },
{ title: "8次", value: 8 }, { title: "8次", value: 8 },
{ title: "9次", value: 9 }, { title: "9次", value: 9 },
{ title: "10次", value: 10 }, { title: "10次", value: 10 }
]; ];
export const periodSignal = [ export const periodSignal = [
@ -64,17 +64,17 @@ export const periodSignal = [
{ title: "1day", value: 6 }, { title: "1day", value: 6 },
{ title: "1week", value: 7 }, { title: "1week", value: 7 },
{ title: "1mon", value: 8 }, { title: "1mon", value: 8 },
{ title: "1year", value: 9 }, { title: "1year", value: 9 }
]; ];
export const orderModes = [ export const orderModes = [
{ title: "市价", value: 0 }, { title: "市价", value: 0 },
{ title: "限价", value: 1 }, { title: "限价", value: 1 }
]; ];
export const signals = [ export const signals = [
{ title: "看多", value: 4 }, { title: "看多", value: 4 },
{ title: "看空", value: 5 }, { title: "看空", value: 5 }
]; ];
export const accountTypes = [ export const accountTypes = [
@ -87,12 +87,13 @@ export const accountTypes = [
{ title: "borrowC2C杠杆借入账户", value: 6 }, { title: "borrowC2C杠杆借入账户", value: 6 },
{ title: "minepool矿池账户", value: 7 }, { title: "minepool矿池账户", value: 7 },
{ title: "etf账户", value: 8 }, { title: "etf账户", value: 8 },
{ title: "cryptoloans抵押借贷账户", value: 9 }, { title: "cryptoloans抵押借贷账户", value: 9 }
]; ];
export const RobotPolicyType = [ export const RobotPolicyType = [
{ title: "动量现货", value: 0 }, { title: "动量现货", value: 0 },
{ title: "顶底策略", value: 1 }, { title: "顶底策略", value: 1 },
{ title: "动量趋势", value: 2 }
]; ];
export const ResetMomentumWaveTest = { export const ResetMomentumWaveTest = {
@ -118,7 +119,7 @@ export const ResetMomentumWaveTest = {
StopBuyFloatingPLRatio: 15.0, //停止下单的浮动盈亏百分比 StopBuyFloatingPLRatio: 15.0, //停止下单的浮动盈亏百分比
StopBuyTotalPurchasePriceRatio: 15.0, //停止下单的持仓占比百分比 StopBuyTotalPurchasePriceRatio: 15.0, //停止下单的持仓占比百分比
IsEnabledTrendProfitSale: false, IsEnabledTrendProfitSale: false,
TrendProfitRatio: 4, TrendProfitRatio: 4
}; };
export const LogTypes = [ export const LogTypes = [
@ -130,5 +131,5 @@ export const LogTypes = [
{ title: "大趋势看空", value: 5 }, { title: "大趋势看空", value: 5 },
{ title: "自动卖出", value: 10 }, { title: "自动卖出", value: 10 },
{ title: "自动卖出(趋势收益)", value: 11 }, { title: "自动卖出(趋势收益)", value: 11 },
{ title: "订单回调", value: 12 }, { title: "订单回调", value: 12 }
]; ];

Loading…
Cancel
Save