Browse Source

v2接口对接

master
lizhixin 4 years ago
parent
commit
68f99e0da8
  1. 67
      src/pages/RobotSec/Account.vue
  2. 99
      src/pages/RobotSec/Modal/RobotCreate.vue
  3. 69
      src/pages/RobotSec/Modal/RobotSetting.vue
  4. 99
      src/pages/RobotSec/index.vue
  5. 4
      src/utils/plugin/axios-plugin.js

67
src/pages/RobotSec/Account.vue

@ -1,6 +1,8 @@
<template>
<div>
<base-button @click="modal.accountAddVisible = true"> 添加用户</base-button>
<base-button @click="modal.accountAddVisible = true">
添加ApiKey</base-button
>
<el-table
:data="tableData"
size="mini"
@ -34,14 +36,10 @@
:prop="i.props"
:key="i.props"
>
<template slot-scope="scope">
<span v-if="i.props == 'AccountType'">
{{
accountTypes.filter(a => a.value == scope.row[i.props])[0].title
}}</span
>
<!-- <template slot-scope="scope">
<span v-if="i.props == 'AccountType'"> </span>
<span v-else> {{ scope.row[i.props] }}</span>
</template>
</template> -->
</el-table-column>
<el-table-column>
<template slot-scope="scope">
@ -104,8 +102,30 @@
v-model="apiKeyform.SecretKey"
>
</base-input>
<!-- 账户类型 -->
<!-- 关联交易对 -->
<div>
<p class="form-label" style="color:rgba(255, 255, 255, 0.6)">
交易对
</p>
<el-select
class="select-danger"
placeholder="选择交易对"
style="width:100%"
v-model="apiKeyform.Symbol"
>
<el-option
v-for="item in allSymbol"
class="select-danger"
:value="item.Symbol"
:label="item.Symbol"
:key="item.Symbol"
>
</el-option>
</el-select>
</div>
<!-- 账户类型 -->
<!-- <p class="form-label" style="color:rgba(255, 255, 255, 0.6)">
账号类型
</p>
<el-select
@ -122,7 +142,7 @@
:key="item.value"
>
</el-option>
</el-select>
</el-select> -->
<div class="text-center">
<base-button
@ -296,15 +316,17 @@ const MainColumns = [
{ label: "UID", props: "UID" },
{ label: "账户类型", props: "AccountType" },
{ label: "账户余额", props: "Balance" },
{ label: "可转资金", props: "account5" }
{ label: "保底运营资金", props: "Balance1" },
{ label: "可转资金", props: "account5" },
{ label: "交易所借款金额", props: "account6" }
];
const SubColumns = [
{ label: "API Key", props: "AccessKey" },
{ label: "交易对", props: "Symbol" },
{ label: "账户余额", props: "Balance" },
{ label: "保底运营资金", props: "MinimumWorkingCapital" },
{ label: "机器人ID", props: "RobotId" }
{ label: "可转资金", props: "RobotId" }
];
import { Modal } from "@/components";
@ -325,6 +347,7 @@ export default {
SubColumns,
apiKeyform: {},
accountForm: {},
allSymbol: [],
moneyForm: {},
createLoading: false,
tableData: []
@ -332,11 +355,21 @@ export default {
},
created() {
this.getAccounts();
this.getAllSymbol();
},
methods: {
//
getAllSymbol() {
this.$http.get("/Api/Symbol/GetList").then(res => {
if (res.Code == 200) {
this.allSymbol = res.Data;
}
});
},
getAccounts() {
this.$http
.get("/Api/StockExchangeAccount/GetListByGroup?policyType=2")
.get("/Api/StockExchangeAccount/GetAPIKeyList?policyType=2")
.then(res => {
if (res.Code == 200) {
this.tableData = res.Data;
@ -360,7 +393,7 @@ export default {
if (res.Code == 200) {
this.sMessage("success", "添加成功");
this.getAccounts();
this.accountAddVisible = false;
this.modal.accountAddVisible = false;
} else {
this.sMessage("danger", res.Message);
}
@ -382,6 +415,4 @@ export default {
};
</script>
<style>
</style>
<style></style>

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

@ -17,6 +17,7 @@
<small>新建机器人</small>
</div>
</template>
<base-input label="机器人名称" v-model="form.Name"></base-input>
<!-- 关联账户 -->
<p class="form-label" style="color:rgba(255, 255, 255, 0.6)">
账户
@ -26,23 +27,22 @@
class="select-danger mb-4"
style="width:100%"
placeholder="选择关联账户"
v-model="form.AccessKey"
v-model="form.UID"
>
<el-option
v-for="item in accountList"
class="select-danger"
:value="item.id"
:label="item.account"
:key="item.id"
:value="item.UID"
:label="item.LoginName"
:key="item.UID"
>
</el-option>
</el-select>
<!-- 关联交易对 -->
<div
v-if="
form.AccessKey &&
accountList.filter(item => item.id == form.AccessKey)[0]
.apiKeys[0]
form.UID &&
accountList.filter(item => item.UID == form.UID)[0].APIKeyList[0]
"
>
<p class="form-label" style="color:rgba(255, 255, 255, 0.6)">
@ -52,16 +52,15 @@
class="select-danger"
placeholder="选择交易对"
style="width:100%"
v-model="form.Symbol"
v-model="form.ApiKeyId"
>
<el-option
v-for="item in accountList.filter(
item => item.id == form.AccessKey
)[0].apiKeys"
v-for="item in accountList.filter(item => item.UID == form.UID)[0]
.APIKeyList"
class="select-danger"
:value="item.key"
:label="`${item.symbol}(${item.key})`"
:key="item.key"
:value="item.Id"
:label="`${item.Symbol}(${item.AccessKey})`"
:key="item.Id"
>
</el-option>
</el-select>
@ -83,39 +82,63 @@ export default {
return {
visible: false,
form: {},
accountList: [
{
id: 11,
account: "小一",
apiKeys: [
{ key: "3213123", symbol: "DOTUSTD" },
{ key: "32323223", symbol: "ADAUSTD" }
]
},
{
id: 22,
account: "小二",
apiKeys: [
{ key: "111111", symbol: "SHIBUSTD" },
{ key: "222222", symbol: "DOGEUSTD" }
]
}
]
accountList: []
};
},
created() {
this.getUnUsedAPIKeyList();
},
methods: {
getUnUsedAPIKeyList() {
this.$http
.get("/Api/StockExchangeAccount/GetNotUsedAPIKeyList?policyType=2")
.then(res => {
if (res.Code == 200) {
this.accountList = res.Data;
}
});
},
clearSymbol() {
this.form = {
...this.form,
Symbol: this.accountList.filter(
item => item.id == this.form.AccessKey
)[0].apiKeys[0]
? this.accountList.filter(item => item.id == this.form.AccessKey)[0]
.apiKeys[0].key
Symbol: this.accountList.filter(item => item.UID == this.form.UID)[0]
.APIKeyList[0]
? this.accountList.filter(item => item.UID == this.form.UID)[0]
.APIKeyList[0].AccessKey
: null
};
},
confirm() {}
getRobots() {},
confirm() {
if (this.form.ApiKeyId) {
// let Symbol = this.accountList.filter(
// item => item.UID == this.form.UID
// )[0].APIKeyList[0].Symbol;
this.$http
.post("/Api/Robot/Add", {
...this.form,
PolicyType: 2
// Symbol
})
.then(res => {
if (res.Code == 200) {
this.sMessage("success", "添加成功");
this.$emit("initRobotList");
this.visible = false;
} else {
this.sMessage("danger", res.Message);
}
});
}
},
// showNotification
sMessage(type, message) {
this.$notify({
type: type,
message,
timeout: 1800
});
}
}
};
</script>

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

@ -17,15 +17,21 @@
<small>机器人配置</small>
</div>
</template>
<base-input label="最大借币比例" v-model="form.FixedMount"></base-input>
<base-input label="初始交易量" v-model="form.O"></base-input>
<base-input
label="最大借币比例"
v-model="form.MaxLoanRatio"
></base-input>
<base-input
label="初始交易量"
v-model="form.TradeCoinCount"
></base-input>
<span class="form-label">交易周期</span>
<el-select
class="select-danger"
style="width:100%"
placeholder="选择周期"
v-model="form.Status"
v-model="form.PeriodicSignal"
>
<el-option
v-for="item in periodSignal"
@ -36,6 +42,24 @@
>
</el-option>
</el-select>
<base-checkbox inline v-model="form.IsEnabledBuySignal">
开启购买信号
</base-checkbox>
<base-checkbox
inline
v-model="form.IsEnabledIsEnableAdditionalQuantity"
>
开启增购
</base-checkbox>
<base-checkbox inline v-model="form.IsEnableRemedyForErrorCrossSignal">
启用错误信号补救
</base-checkbox>
<base-checkbox inline v-model="form.IsClearCurrentRoundPurchaseInfo">
是否清空本轮购买信息
</base-checkbox>
<div class="text-center">
<base-button type="primary" class="my-4" @click="confirm"
>确定</base-button
@ -52,7 +76,7 @@ import { periodSignal } from "../../prePages/js/selectoptions";
export default {
components: { Modal },
model: { prop: "visible", event: "visibleChanger" },
props: { robotInfo: { type: Object, defualt: () => {} }, visible: false },
props: { robotSetting: { type: Object, defualt: () => {} }, visible: false },
data() {
return {
periodSignal,
@ -63,13 +87,48 @@ export default {
]
};
},
watch: {
robotSetting(newV, oldV) {
this.form = newV;
}
},
methods: {
//
confirm() {
console.log(this.robotInfo);
let requestParam = {
...this.robotSetting,
...this.form,
MaxLoanRatio: parseFloat(this.form.MaxLoanRatio),
TradeCoinCount: parseFloat(this.form.TradeCoinCount)
};
delete requestParam.ReduceTradeCoinCount;
delete requestParam.ActualTradeCoinCount;
delete requestParam.Id;
this.$http
.put("/Api/MomentumTrendV2Policy/Edit", requestParam)
.then(res => {
if (res.Code == 200) {
this.sMessage("success", "修改成功");
this.$emit("visibleChanger", false);
this.$emit("initRobotList");
} else {
this.sMessage("danger", res.Message);
}
});
this.$emit("visibleChanger", false);
},
close() {
this.$emit("visibleChanger", false);
},
// showNotification
sMessage(type, message) {
this.$notify({
type: type,
message,
timeout: 1800
});
}
}
};

99
src/pages/RobotSec/index.vue

@ -1,6 +1,6 @@
<template>
<div>
<robot-create />
<robot-create @initRobotList="initRobotList" />
<custom-base-table
:data="data"
:columns="columns"
@ -36,12 +36,33 @@
</el-switch>
</template>
<!-- 运行时长 -->
<template slot="OnlySale" slot-scope="item">{{ item }}</template>
<template slot="WorkTime" slot-scope="item" v-if="item.row.item.Time">{{
secToMin(item.row.item.Time)
}}</template>
<!-- 策略配置 -->
<template slot="OnlySale" slot-scope="item">{{ item }}</template>
<template
slot="Setting"
slot-scope="item"
v-if="item.row.item.TradePolicy"
>
<div>
固定交易量{{ item.row.item.TradePolicy.TradeCoinCount }}
交易周期{{
getMatchTitle(
item.row.item.TradePolicy.PeriodicSignal,
periodSignal
)
}}
</div>
<div>
最大借款比例{{ item.row.item.TradePolicy.MaxLoanRatio }}%
止损比例{{ item.row.item.TradePolicy.maxLoanRatio }}
</div>
</template>
<!-- 委托单 -->
<template slot="OnlySale" slot-scope="item">{{ item }}</template>
<template slot="OrderPlan" slot-scope="item">{{}}委托单</template>
<!-- 总盈亏 -->
<!-- <template slot="OrderPlan" slot-scope="item">{{item.row.item.ZYK}}({{item.row.item.Ratio}})</template> -->
<!-- 操作 -->
<template slot="Action" slot-scope="item">
<div class="row">
@ -72,17 +93,22 @@
</div>
</template>
</custom-base-table>
<robot-setting :robotInfo="robot" v-model="settingVisible" />
<robot-setting
:robotSetting="robotSetting"
v-model="settingVisible"
@initRobotList="initRobotList"
/>
<order-plan :robotInfo="robot" v-model="orderVisible" />
</div>
</template>
<script>
import { secToMin } from "../../utils/TimeUtils";
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: "Robot.Symbol" },
{
name: "运行状态",
prop: "WaveBandPolicy.IsEnabledBuySignal",
@ -90,7 +116,7 @@ const tableColumns = [
},
{
name: "只卖",
prop: "RobotAccount.TotalPurchasePrice",
prop: "TradePolicy.isEnabledBuySignal",
customSlot: "OnlySale"
},
{ name: "持仓成本", prop: "RobotAccount.TotalPurchasePrice" },
@ -99,9 +125,7 @@ const tableColumns = [
{ name: "币本位盈亏", prop: "RobotAccount.BBWProfit" },
{ name: "持币盈亏", prop: "RobotAccount.TotalProfit" },
{ name: "实际本金", prop: "RealCost" },
{ name: "总盈亏", prop: "RobotAccount.ZYK" },
{
name: "运行时长",
prop: "Robot.IntervalSetting",
@ -114,26 +138,62 @@ const tableColumns = [
import CustomBaseTable from "../../../src/components/CustomBaseTable";
import { Modal } from "@/components";
import { periodSignal } from "../prePages/js/selectoptions";
export default {
components: { CustomBaseTable, Modal, RobotCreate, RobotSetting, OrderPlan },
data() {
return {
secToMin,
periodSignal,
columns: tableColumns,
data: [
{ item: 1, Id: 0 },
{ item: 2, Id: 2 }
],
data: [],
robot: {},
robotSetting: {},
settingVisible: false,
orderVisible: false
};
},
created() {
this.initRobotList();
},
methods: {
initRobotList() {
this.$http
.get("/Api/Robot/GetMomentumTrendV2TradeRobotList")
.then(res => {
if (res.Code == 200) {
this.data = res.Data;
}
});
},
visibleModi(type, record) {
this[type] = true;
this.robot = record;
if (type == "settingVisible") {
this.robotSetting = { robotId: record.Robot.Id };
this.getEditDetails(record.Robot.Id);
}
},
getMatchTitle(value, sourceArray) {
let title = "";
sourceArray.forEach(element => {
if (element.value == value) title = element.title;
});
return title;
},
//2
getEditDetails(Id) {
this.$http
.get("/Api/MomentumTrendV2Policy/Get?robotId=" + Id)
.then(res => {
if (res.Code == 200) {
this.robotSetting = { ...this.robotSetting, ...res.Data };
}
});
},
//
onStatusChange(record, isOn) {
console.log(record, isOn);
@ -164,7 +224,7 @@ export default {
record.TradePolicy.IsEnabledBuySignal = isOn ? 0 : 1;
this.$forceUpdate();
this.$http
.put("/Api/MomentumWavePolicy/EditPurchaseStatus", {
.put("/Api/MomentumTrendV2Policy/EditPurchaseStatus", {
RobotId: record.Robot.Id,
OnlySell: isOn
})
@ -179,6 +239,13 @@ export default {
goCheck(id) {
this.$router.push(`/editt/${id}`);
}, // showNotification
sMessage(type, message) {
this.$notify({
type: type,
message,
timeout: 1800
});
}
}
};

4
src/utils/plugin/axios-plugin.js

@ -1,9 +1,9 @@
/* eslint-disable */
import axios from "axios";
// const rootUrl = "http://54.249.164.224/"; //formal
// const rootUrl = "http://58.23.153.12:88/"; //test
const rootUrl = "http://58.23.153.12:88/"; //test
const rootUrl = "http://trapi.iheyinet.com"; //latest
const Axios = axios.create({
baseURL: rootUrl,

Loading…
Cancel
Save