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. 91
      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-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>
</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>
<el-tabs value="1">
@ -155,6 +123,10 @@
v-if="policyMode == 0"
v-model="policyFormData"
/>
<move-trend
v-else-if="policyMode == 2"
v-model="trendForm"
></move-trend>
<!-- <top-end-policy v-else v-model="policyFormData" /> -->
</el-tab-pane>
</el-tabs>
@ -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);
}

91
src/pages/Robot/index.vue

@ -79,6 +79,9 @@
</modal>
<base-button @click="modal.visible = true">添加机器人</base-button>
<base-button @click="syncAllOrder" class="ml-4"
>同步所有现货订单</base-button
>
<custom-base-table
:data="tableData"
@ -147,11 +150,27 @@
</base-button>
</el-tooltip>
<el-tooltip content="删除" :open-delay="300" placement="top">
<base-button type="danger" size="sm" icon>
<el-tooltip
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>
</base-button>
</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>
</custom-base-table>
</div>
@ -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}`);
},

27
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 }
];

Loading…
Cancel
Save