lizhixin 4 years ago
parent
commit
50af4a2e8e
  1. 61
      src/components/Modal.vue
  2. 16
      src/layout/dashboard/DashboardLayout.vue
  3. 8
      src/pages/ReCheck/AccountInfo.vue
  4. 4
      src/pages/ReCheck/MoveTrend.vue
  5. 61
      src/pages/ReCheck/index.vue
  6. 53
      src/pages/RobotSec/Modal/OrderPlan.vue
  7. 35
      src/pages/RobotSec/Modal/RobotCreate.vue
  8. 74
      src/pages/RobotSec/Modal/RobotSetting.vue
  9. 171
      src/pages/RobotSec/index.vue
  10. 3
      src/pages/prePages/js/selectoptions.js
  11. 7
      src/router/routes.js

61
src/components/Modal.vue

@ -1,26 +1,48 @@
<template>
<SlideYUpTransition :duration="animationDuration">
<div class="modal fade"
@click.self="closeModal"
:class="[{'show d-block': show}, {'d-none': !show}, {'modal-mini': type === 'mini'}]"
v-show="show"
tabindex="-1"
role="dialog"
:aria-hidden="!show">
<div class="modal-dialog"
:class="[{'modal-notice': type === 'notice'}, {'modal-dialog-centered': centered}, modalClasses]">
<div class="modal-content" :class="[gradient ? `bg-gradient-${gradient}` : '',modalContentClasses]">
<div class="modal-header" :class="[headerClasses]" v-if="$slots.header">
<div
class="modal fade"
@click.self="closeModal"
:class="[
{ 'show d-block': show },
{ 'd-none': !show },
{ 'modal-mini': type === 'mini' }
]"
v-show="show"
tabindex="-1"
role="dialog"
:aria-hidden="!show"
>
<div
class="modal-dialog"
:class="[
{ 'modal-notice': type === 'notice' },
{ 'modal-dialog-centered': centered },
modalClasses
]"
>
<div
class="modal-content"
:class="[
gradient ? `bg-gradient-${gradient}` : '',
modalContentClasses
]"
>
<div
class="modal-header"
:class="[headerClasses]"
v-if="$slots.header"
>
<slot name="header"></slot>
<slot name="close-button">
<button type="button"
class="close"
v-if="showClose"
@click="closeModal"
data-dismiss="modal"
aria-label="Close">
<button
type="button"
class="close"
v-if="showClose"
@click="closeModal"
data-dismiss="modal"
aria-label="Close"
>
<i class="tim-icons icon-simple-remove"></i>
</button>
</slot>
@ -35,7 +57,6 @@
</div>
</div>
</div>
</div>
</SlideYUpTransition>
</template>

16
src/layout/dashboard/DashboardLayout.vue

@ -3,7 +3,7 @@
<side-bar :backgroundColor="'#333D54'">
<el-menu
class="el-menu-vertical-demo"
:default-openeds="['1', '2']"
:default-openeds="['1', '2', '3']"
background-color="#333E54"
text-color="#fff"
active-text-color="#ffd04b"
@ -37,6 +37,20 @@
总资金管理</el-menu-item
>
</el-submenu>
<el-submenu index="3">
<template slot="title">
<i class="el-icon-medal"></i>
<span>动量趋势2.0</span>
</template>
<!-- <el-menu-item index="2-1" @click="to('/')">概况</el-menu-item> -->
<el-menu-item index="3-2" @click="to('/account/2')">
账号管理</el-menu-item
>
<el-menu-item index="3-3" @click="to('/robotsec')"
>机器人管理</el-menu-item
>
</el-submenu>
<el-menu-item index="4" @click="to('/winRate')">
<i class="el-icon-aim"></i>
<span slot="title">短线胜率测试</span>

8
src/pages/ReCheck/AccountInfo.vue

@ -78,6 +78,14 @@
accountInfo.MinOrderProfitRatio.toFixed(2)
}}%)
</p>
<p>实际运营成本 {{ accountInfo.RealCost }}</p>
<p>持仓成本 {{ accountInfo.TotalPurchasePrice }}</p>
<p>波段盈亏 {{ accountInfo.HistoryProfit }}</p>
<p>币本位盈亏 {{ accountInfo.BBWProfit }}</p>
<p>持币盈亏 {{ accountInfo.TotalPriceGap }}</p>
<p>浮动盈亏金额 {{ accountInfo.TotalPurchasePriceProfit }}</p>
<p>总盈亏 {{ accountInfo.ZYK }}</p>
</div>
</template>
<script>

4
src/pages/ReCheck/MoveTrend.vue

@ -51,9 +51,9 @@
<base-checkbox inline v-model="form.IsEnabledLimit">
是否启用限价单
</base-checkbox>
<base-checkbox inline v-model="form.IsV2">
<!-- <base-checkbox inline v-model="form.IsV2">
是否启用动量趋势2.0
</base-checkbox>
</base-checkbox> -->
</div>
</template>
<script>

61
src/pages/ReCheck/index.vue

@ -132,6 +132,10 @@
v-else-if="policyMode == 2"
v-model="trendForm"
></move-trend>
<div v-else-if="policyMode == 3">
<base-input v-model="TradeCoinCount" label="币交易数量">
</base-input>
</div>
<!-- <top-end-policy v-else v-model="policyFormData" /> -->
</el-tab-pane>
</el-tabs>
@ -279,6 +283,7 @@ export default {
buyPointCountList: [],
salePointCountList: [],
excelTabsData: [],
TradeCoinCount: 100,
logShowCondition: i => true
};
},
@ -710,6 +715,7 @@ export default {
test() {
if (this.policyMode == 0) this.executeTest();
else if (this.policyMode == 2) this.executeTrendTest();
else if (this.policyMode == 3) this.executeTrendTest();
},
executeTest() {
@ -741,7 +747,7 @@ export default {
}
},
executeTrendTest() {
if (this.trendForm && this.kLineDataList.length > 0) {
if (this.kLineDataList.length > 0) {
this.excuting = true;
let newExcelData = JSON.parse(JSON.stringify(this.excelTabsData));
newExcelData.forEach(element => {
@ -757,32 +763,37 @@ export default {
// var blob = new Blob([content], { type: "text/plain;charset=utf-8" });
// saveAs(blob, "request.txt");
// -end
this.$http
.post("/Api/Simulation/MomentumTrendTest", {
Capital: this.trendForm,
IsEnabledLimit: this.trendForm.IsEnabledLimit,
IsV2: this.trendForm.IsV2,
SymbolList: newExcelData
})
.then(res => {
this.excuting = false;
if (res.Code == 200) {
this.sMessage("success", "回测完成");
let params =
this.policyMode == 3
? { TradeCoinCount: this.TradeCoinCount, SymbolList: newExcelData }
: {
Capital: this.trendForm,
IsEnabledLimit: this.trendForm.IsEnabledLimit,
// IsV2: this.trendForm.IsV2,
SymbolList: newExcelData
};
let requestUrl =
this.policyMode == 3
? "/Api/Simulation/MomentumTrendV2Test"
: "/Api/Simulation/MomentumTrendTest";
this.$http.post(requestUrl, params).then(res => {
this.excuting = false;
if (res.Code == 200) {
this.sMessage("success", "回测完成");
}
res.Data.SimulationResultList.forEach(element => {
let index = this.getIndex(element.Symbol);
if (index != -1) {
this.excelTabsData[index] = {
...this.excelTabsData[index],
tradeData: element.OrderList,
logData: element.ExecutionLogList,
accountInfo: { ...element, ...element.RobotAccount }
};
}
res.Data.SimulationResultList.forEach(element => {
let index = this.getIndex(element.Symbol);
if (index != -1) {
this.excelTabsData[index] = {
...this.excelTabsData[index],
tradeData: element.OrderList,
logData: element.ExecutionLogList,
accountInfo: { ...element }
};
}
});
this.accountInfo = { ...res.Data };
});
this.accountInfo = { ...res.Data, ...res.Data.RobotAccount };
});
}
},

53
src/pages/RobotSec/Modal/OrderPlan.vue

@ -0,0 +1,53 @@
<template>
<modal
:show.sync="visible"
body-classes="p-0"
@close="close"
modal-classes="modal-dialog-centered modal-sm"
>
<card
type="secondary"
header-classes="bg-white pb-5"
body-classes="px-lg-5 py-lg-5"
class="border-0 mb-0"
>
<template>
<div class="text-muted text-center mb-3">
<small>委托单</small>
</div>
</template>
<div class="text-center">
<base-button type="primary" class="my-4" @click="confirm"
>确定</base-button
>
</div>
</card>
</modal>
</template>
<script>
import { Modal } from "@/components";
export default {
model: { prop: "visible", event: "ordervisibleChanger" },
components: { Modal },
props: { robotInfo: { type: Object, defualt: () => {} }, visible: false },
data() {
return {};
},
watch: {
visible(newV, oldV) {
console.log(newV, oldV, "ceck for");
}
},
methods: {
confirm() {
console.log(this.robotInfo);
this.$emit("ordervisibleChanger", false);
},
close() {
this.$emit("ordervisibleChanger", false);
}
}
};
</script>

35
src/pages/RobotSec/Modal/RobotCreate.vue

@ -0,0 +1,35 @@
<template>
<div>
<base-button @click="visible = true">创建机器人</base-button>
<modal
:show.sync="visible"
body-classes="p-0"
modal-classes="modal-dialog-centered modal-sm"
>
<card
type="secondary"
header-classes="bg-white pb-5"
body-classes="px-lg-5 py-lg-5"
class="border-0 mb-0"
>
<template>
<div class="text-muted text-center mb-3">
<small>新建机器人</small>
</div>
</template>
</card>
</modal>
</div>
</template>
<script>
import { Modal } from "@/components";
export default {
components: { Modal },
data() {
return { visible: false };
}
};
</script>

74
src/pages/RobotSec/Modal/RobotSetting.vue

@ -0,0 +1,74 @@
<template>
<div>
<modal
:show.sync="visible"
body-classes="p-0"
@close="close"
modal-classes="modal-dialog-centered modal-sm"
>
<card
type="secondary"
header-classes="bg-white pb-5"
body-classes="px-lg-5 py-lg-5"
class="border-0 mb-0"
>
<template>
<div class="text-muted text-center mb-3">
<small>机器人配置</small>
</div>
</template>
<base-input label="固定交易量" v-model="form.FixedMount"></base-input>
<p class="form-label">多空交叉无状态</p>
<el-select
class="select-danger"
style="width:100%"
placeholder="选择状态"
v-model="form.Status"
>
<el-option
v-for="item in status"
class="select-danger"
:value="item.value"
:label="item.title"
:key="item.value"
>
</el-option>
</el-select>
<div class="text-center">
<base-button type="primary" class="my-4" @click="confirm"
>确定</base-button
>
</div>
</card>
</modal>
</div>
</template>
<script>
import { Modal } from "@/components";
export default {
components: { Modal },
model: { prop: "visible", event: "visibleChanger" },
props: { robotInfo: { type: Object, defualt: () => {} }, visible: false },
data() {
return {
form: {},
status: [
{ value: 0, title: "多交叉" },
{ value: 1, title: "空交叉" }
]
};
},
methods: {
confirm() {
console.log(this.robotInfo);
this.$emit("visibleChanger", false);
},
close() {
this.$emit("visibleChanger", false);
}
}
};
</script>

171
src/pages/RobotSec/index.vue

@ -0,0 +1,171 @@
<template>
<div>
<robot-create />
<custom-base-table
:data="data"
:columns="columns"
thead-classes="text-primary"
>
<!-- 运行状态 -->
<template
slot="FunctionStatus"
slot-scope="item"
v-if="item.row.item.Robot"
>
<el-switch
:value="item.row.item.Robot.Status == 1"
active-color="#54105C"
inactive-color="#201126"
@change="onStatusChange(item.row.item, $event)"
>
</el-switch>
</template>
<!-- 只卖 -->
<template
slot="OnlySale"
slot-scope="item"
v-if="item.row.item.TradePolicy"
>
<el-switch
:value="!(item.row.item.TradePolicy.IsEnabledBuySignal == 1)"
active-color="#54105C"
inactive-color="#201126"
@change="onOnlySaleChange(item.row.item, $event)"
>
</el-switch>
</template>
<!-- 运行时长 -->
<template slot="OnlySale" slot-scope="item">{{ item }}</template>
<!-- 策略配置 -->
<template slot="OnlySale" slot-scope="item">{{ item }}</template>
<!-- 委托单 -->
<template slot="OnlySale" slot-scope="item">{{ item }}</template>
<!-- 操作 -->
<template slot="Action" slot-scope="item">
<base-dropdown title-classes="btn btn-secondary" title="操作">
<li class="nav-link">
<a
class="dropdown-item"
href="#"
@click="visibleModi('settingVisible', item.row.item)"
>编辑</a
>
</li>
<li class="nav-link">
<a
class="dropdown-item"
href="#"
@click="visibleModi('orderVisible', item.row.item)"
>委托下单</a
>
</li>
</base-dropdown>
</template>
</custom-base-table>
<robot-setting :robotInfo="robot" v-model="settingVisible" />
<order-plan :robotInfo="robot" v-model="orderVisible" />
</div>
</template>
<script>
import RobotCreate from "./Modal/RobotCreate";
import RobotSetting from "./Modal/RobotSetting";
import OrderPlan from "./Modal/OrderPlan";
const tableColumns = [
{ name: "货币对", prop: "Robot.Symbol", customSlot: "Symbol" },
{
name: "运行状态",
prop: "WaveBandPolicy.IsEnabledBuySignal",
customSlot: "FunctionStatus"
},
{
name: "只卖",
prop: "RobotAccount.TotalPurchasePrice",
customSlot: "OnlySale"
},
{ name: "持仓成本", prop: "RobotAccount.TotalPurchasePrice" },
{ name: "浮动盈亏", prop: "RobotAccount.TotalPurchasePriceProfit" },
{ name: "波段盈亏", prop: "RobotAccount.HistoryProfit" },
{ name: "币本位盈亏", prop: "RobotAccount.BBWProfit" },
{ name: "持币盈亏", prop: "RobotAccount.TotalProfit" },
{ name: "实际本金", prop: "RealCost" },
{ name: "总盈亏", prop: "RobotAccount.ZYK" },
{
name: "运行时长",
prop: "Robot.IntervalSetting",
customSlot: "WorkTime"
},
{ name: "策略配置", prop: "Robot.SaleSetting", customSlot: "Setting" },
{ name: "委托单", prop: "Robot.SaleSetting", customSlot: "OrderPlan" },
{ name: "操作", prop: "Action", customSlot: "Action" }
];
import CustomBaseTable from "../../../src/components/CustomBaseTable";
import { Modal } from "@/components";
export default {
components: { CustomBaseTable, Modal, RobotCreate, RobotSetting, OrderPlan },
data() {
return {
columns: tableColumns,
data: [{ item: 1 }, { item: 2 }],
robot: {},
settingVisible: false,
orderVisible: false
};
},
methods: {
visibleModi(type, record) {
this[type] = true;
this.robot = record;
console.log(this);
},
//
onStatusChange(record, isOn) {
console.log(record, isOn);
if (isOn) {
record.Robot.Status = 1;
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/" + record.Robot.Id).then(res => {
if (res.Code == 200) {
this.sMessage("success", "已停用");
} else {
this.sMessage("danger", res.Message);
}
});
}
},
//
onOnlySaleChange(record, isOn) {
console.log(record, isOn);
record.TradePolicy.IsEnabledBuySignal = isOn ? 0 : 1;
this.$forceUpdate();
this.$http
.put("/Api/MomentumWavePolicy/EditPurchaseStatus", {
RobotId: record.Robot.Id,
OnlySell: isOn
})
.then(res => {
if (res.Code == 200) {
this.sMessage("success", isOn ? "已开启" : "已关闭");
} else {
this.sMessage("danger", res.Message);
}
});
}
}
};
</script>

3
src/pages/prePages/js/selectoptions.js

@ -93,7 +93,8 @@ export const accountTypes = [
export const RobotPolicyType = [
{ title: "动量现货", value: 0 },
{ title: "顶底策略", value: 1 },
{ title: "动量趋势", value: 2 }
{ title: "动量趋势", value: 2 },
{ title: "动量趋势2.0", value: 3 }
];
export const ResetMomentumWaveTest = {

7
src/router/routes.js

@ -17,6 +17,7 @@ const WinRate = () => import("@/pages/WinRate");
const ReCheck = () => import("@/pages/ReCheck");
const Capital = () => import("@/pages/Profit");
const Prev = () => import("@/pages/Prev");
const RobotSec = () => import("@/pages/RobotSec");
const routes = [
{
path: "/",
@ -64,6 +65,12 @@ const routes = [
name: "capital",
meta: { auth: true },
component: Capital
},
{
path: "robotsec",
name: "robotsec",
meta: { auth: true },
component: RobotSec
}
// {
// path: "profile",

Loading…
Cancel
Save