|
@@ -19,8 +19,7 @@
|
|
|
{{ expertInfo.expert_title }}
|
|
|
</div>
|
|
|
<div class="level">
|
|
|
- <!-- 高级 -->
|
|
|
- {{ $t('setting.l14') }}
|
|
|
+ {{ expertInfo.expert_level }}
|
|
|
</div>
|
|
|
</div>
|
|
|
<div class="time">
|
|
@@ -80,21 +79,21 @@
|
|
|
<!-- 资产净值(USD) -->
|
|
|
{{ $t('account.l2') }}(USD)
|
|
|
</div>
|
|
|
- <div>319,873.36</div>
|
|
|
+ <div>{{ $numToThousand(equity) }}</div>
|
|
|
</van-col>
|
|
|
<van-col span="8">
|
|
|
<div class="lab">
|
|
|
<!-- 持仓盈亏(USD) -->
|
|
|
{{ $t('account.l19') }}(USD)
|
|
|
</div>
|
|
|
- <div class="up">572.39 (2.37%)</div>
|
|
|
+ <div :class="{up: allProfit >= 0, down: allProfit < 0}">{{ $numToThousand(allProfit) }} ({{ getPercentage(allProfit, equity) }}%)</div>
|
|
|
</van-col>
|
|
|
<van-col span="8">
|
|
|
<div class="lab">
|
|
|
<!-- 持仓市值(USD) -->
|
|
|
{{ $t('account.l21') }}(USD)
|
|
|
</div>
|
|
|
- <div>319,873.36</div>
|
|
|
+ <div>{{ $numToThousand(allMarket) }}</div>
|
|
|
</van-col>
|
|
|
</van-row>
|
|
|
<van-row gutter="6">
|
|
@@ -103,21 +102,21 @@
|
|
|
<!-- 可用现金(USD) -->
|
|
|
{{ $t('account.l23') }}(USD)
|
|
|
</div>
|
|
|
- <div>319,873.36</div>
|
|
|
+ <div>{{ $numToThousand(marginFree) }}</div>
|
|
|
</van-col>
|
|
|
<van-col span="8">
|
|
|
<div class="lab">
|
|
|
<!-- 占用保证金(USD) -->
|
|
|
{{ $t('account.l22') }}(USD)
|
|
|
</div>
|
|
|
- <div class="up">572.39 (2.37%)</div>
|
|
|
+ <div class="up">{{ $numToThousand(followAccount.margin) }}</div>
|
|
|
</van-col>
|
|
|
<van-col span="8">
|
|
|
<div class="lab">
|
|
|
<!-- 保证金比例 -->
|
|
|
{{ $t('account.l84') }}
|
|
|
</div>
|
|
|
- <div>319,873.36</div>
|
|
|
+ <div>{{ getPercentage(equity, followAccount.margin) }}%</div>
|
|
|
</van-col>
|
|
|
</van-row>
|
|
|
</div>
|
|
@@ -143,7 +142,7 @@
|
|
|
</div>
|
|
|
</div>
|
|
|
</div>
|
|
|
- <openList v-if="type == 1" />
|
|
|
+ <openList :list="positionList" v-if="type == 1" />
|
|
|
<historyList v-if="type == 2" />
|
|
|
<van-popup v-model="cancelPop" round position="bottom">
|
|
|
<cancelCopy :info="expertInfo" @success="cancelBack"/>
|
|
@@ -157,6 +156,7 @@ import historyList from "./components/historyList.vue";
|
|
|
import cancelCopy from "./components/cancelCopy.vue";
|
|
|
import { getFollowList, getFollowPositionTradeList, getFollowHistoryTradeList } from "@/api/copy";
|
|
|
import { getProductList } from "@/api/product";
|
|
|
+import { mapGetters } from "vuex";
|
|
|
import bus from '@/utils/bus'
|
|
|
export default {
|
|
|
components: {
|
|
@@ -165,6 +165,7 @@ export default {
|
|
|
historyList,
|
|
|
cancelCopy,
|
|
|
},
|
|
|
+ inject: ['getproductDataObj'],
|
|
|
data () {
|
|
|
return {
|
|
|
type: '1',
|
|
@@ -172,14 +173,55 @@ export default {
|
|
|
positionList: [],
|
|
|
historyTotal: 0,
|
|
|
cancelPop: false,
|
|
|
- id: ''
|
|
|
+ id: '',
|
|
|
+ positionSign: false,
|
|
|
+ updateSign: false,
|
|
|
+ allProfit: 0,
|
|
|
}
|
|
|
},
|
|
|
+ computed: {
|
|
|
+ ...mapGetters(['followAccount']),
|
|
|
+ productDataObj() {
|
|
|
+ return this.getproductDataObj()
|
|
|
+ },
|
|
|
+ equity() {
|
|
|
+ if(!this.positionSign || !this.updateSign) {
|
|
|
+ return this.followAccount.equity
|
|
|
+ }
|
|
|
+ var equity = Number(this.$bigDecimal.add(this.followAccount.balance, Number(this.allProfit)))
|
|
|
+ return equity
|
|
|
+ },
|
|
|
+ marginFree() {
|
|
|
+ if(!this.positionSign || !this.updateSign) {
|
|
|
+ return this.followAccount.margin_free
|
|
|
+ }
|
|
|
+ return this.$bigDecimal.add(this.$bigDecimal.subtract(this.followAccount.balance, Number(this.followAccount.margin)), Number(this.allProfit))
|
|
|
+ },
|
|
|
+ allMarket() {
|
|
|
+ var positionList = this.positionList
|
|
|
+ var allProfit = 0
|
|
|
+ var allMarket = 0
|
|
|
+ positionList.forEach((item, index) => {
|
|
|
+ var v = item
|
|
|
+ allProfit = this.$bigDecimal.add(allProfit, v.profit)
|
|
|
+ allProfit = this.$bigDecimal.add(allProfit, v.commission)
|
|
|
+ allProfit = this.$bigDecimal.add(allProfit, v.swaps)
|
|
|
+ allMarket = this.$bigDecimal.add(allMarket, this.formatMarket(item))
|
|
|
+ })
|
|
|
+ this.allProfit = allProfit
|
|
|
+ return allMarket
|
|
|
+ }
|
|
|
+ },
|
|
|
+ beforeDestroy() {
|
|
|
+ bus.$off('updateSymbol', this.updateSymbol)
|
|
|
+ },
|
|
|
created () {
|
|
|
this.id = this.$route.params.id
|
|
|
this.getFollowList()
|
|
|
this.getFollowPositionTradeList()
|
|
|
this.getFollowHistoryTradeList()
|
|
|
+ this.$store.dispatch('getFollowAccount')
|
|
|
+ bus.$on('updateSymbol', this.updateSymbol)
|
|
|
},
|
|
|
methods: {
|
|
|
getFollowPositionTradeList() {
|
|
@@ -201,6 +243,7 @@ export default {
|
|
|
}).then(res => {
|
|
|
var list = res.list || []
|
|
|
var list1 = []
|
|
|
+ this.positionSign = true
|
|
|
list.forEach(item => {
|
|
|
if (item.profit_mode == 0) {
|
|
|
var symbol = item.symbol.slice(3, 6)
|
|
@@ -220,15 +263,159 @@ export default {
|
|
|
}
|
|
|
})
|
|
|
bus.$emit("alterProductData", {
|
|
|
- getData: list1
|
|
|
- });
|
|
|
- bus.$emit("alterProductData", {
|
|
|
+ getData: list1,
|
|
|
setData: list,
|
|
|
subscribeList: [...symbolList]
|
|
|
});
|
|
|
+ this.updateSymbol()
|
|
|
})
|
|
|
}).catch(() => {})
|
|
|
},
|
|
|
+ updateSymbol() {
|
|
|
+ var positionList = this.positionList
|
|
|
+ positionList.forEach((item, index) => {
|
|
|
+ var v = item
|
|
|
+ this.updateSign = true
|
|
|
+ if (this.productDataObj[item.symbol]) {
|
|
|
+ if (item.cmd == 0) {
|
|
|
+ v.close_price = this.productDataObj[item.symbol].bid
|
|
|
+ }
|
|
|
+ if (item.cmd == 1) {
|
|
|
+ v.close_price = this.productDataObj[item.symbol].ask
|
|
|
+ }
|
|
|
+ }
|
|
|
+ v.profit = this.formatProfit(v) || v.profit
|
|
|
+ this.$set(this.positionList, index, v)
|
|
|
+ })
|
|
|
+ },
|
|
|
+ formatMarket(item) {
|
|
|
+ var currencyData = this.productDataObj[item.symbol]
|
|
|
+ if (currencyData) {
|
|
|
+ var market = this.$bigDecimal.multiply(item.close_price, this.$bigDecimal.multiply(item.volume, currencyData.contract_size))
|
|
|
+ var rate;
|
|
|
+ if (currencyData.market == 'CFD') {
|
|
|
+ if (currencyData.profit_mode == '1') {
|
|
|
+ var market1 = ''
|
|
|
+ var market2 = ''
|
|
|
+ if (currencyData.currency != 'USD') {
|
|
|
+ market1 = this.productDataObj[`USD${currencyData.currency}`]
|
|
|
+ market2 = this.productDataObj[`${currencyData.currency}USD`]
|
|
|
+ if (market1) {
|
|
|
+ rate = (market1['ask'] + market1['bid']) / 2
|
|
|
+ }
|
|
|
+ if (market2) {
|
|
|
+ rate = (market2['ask'] + market2['bid']) / 2
|
|
|
+ }
|
|
|
+ if (market2) {
|
|
|
+ market = market * rate
|
|
|
+ } else if (market1) {
|
|
|
+ market = market / rate
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (currencyData.profit_mode == '0') {
|
|
|
+ var symbol = currencyData.symbol.slice(3, 6)
|
|
|
+ var market1 = this.productDataObj[`USD${symbol}`]
|
|
|
+ var market2 = this.productDataObj[`${symbol}USD`]
|
|
|
+ if (market1) {
|
|
|
+ rate = (market1['ask'] + market1['bid']) / 2
|
|
|
+ }
|
|
|
+ if (market2) {
|
|
|
+ rate = (market2['ask'] + market2['bid']) / 2
|
|
|
+ }
|
|
|
+ if (market2) {
|
|
|
+ market = market * rate
|
|
|
+ } else if (market1) {
|
|
|
+ market = market / rate
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ return Number(market).toFixed(2)
|
|
|
+ }
|
|
|
+ return this.$bigDecimal.multiply(item.close_price, this.$bigDecimal.multiply(item.volume, item.productBean.contract_size))
|
|
|
+ },
|
|
|
+ formatProfit(data) {
|
|
|
+ var currencyData = this.productDataObj[data.symbol]
|
|
|
+ if (!currencyData) {
|
|
|
+ return data.profit
|
|
|
+ }
|
|
|
+ var rate, profit;
|
|
|
+ if (currencyData.market == 'CFD') {
|
|
|
+ if (currencyData.profit_mode == '1') {
|
|
|
+ var market1 = ''
|
|
|
+ var market2 = ''
|
|
|
+ if (currencyData.currency != 'USD') {
|
|
|
+ market1 = this.productDataObj[`USD${currencyData.currency}`]
|
|
|
+ market2 = this.productDataObj[`${currencyData.currency}USD`]
|
|
|
+ if (market1) {
|
|
|
+ rate = (market1['ask'] + market1['bid']) / 2
|
|
|
+ }
|
|
|
+ if (market2) {
|
|
|
+ rate = (market2['ask'] + market2['bid']) / 2
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (data.cmd == '1') {
|
|
|
+ if (market2) {
|
|
|
+ profit = (data.open_price - currencyData.ask) * (data.volume) * currencyData.contract_size * rate
|
|
|
+ } else if (market1) {
|
|
|
+ profit = ((data.open_price - currencyData.ask) * (data.volume) * currencyData.contract_size) / rate
|
|
|
+ } else {
|
|
|
+ profit = (data.open_price - currencyData.ask) * (data.volume) * currencyData.contract_size
|
|
|
+ }
|
|
|
+ } else if (data.cmd == '0') {
|
|
|
+ if (market2) {
|
|
|
+ profit = (currencyData.bid - data.open_price) * (data.volume) * currencyData.contract_size * rate
|
|
|
+ } else if (market1) {
|
|
|
+ profit = ((currencyData.bid - data.open_price) * (data.volume) * currencyData.contract_size) / rate
|
|
|
+ } else {
|
|
|
+ profit = (currencyData.bid - data.open_price) * (data.volume) * currencyData.contract_size
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else if (currencyData.profit_mode == '0') {
|
|
|
+ var symbol = currencyData.symbol.slice(3, 6)
|
|
|
+ var market1 = this.productDataObj[`USD${symbol}`]
|
|
|
+ var market2 = this.productDataObj[`${symbol}USD`]
|
|
|
+ if (market1) {
|
|
|
+ rate = (market1['ask'] + market1['bid']) / 2
|
|
|
+ }
|
|
|
+ if (market2) {
|
|
|
+ rate = (market2['ask'] + market2['bid']) / 2
|
|
|
+ }
|
|
|
+ if (data.cmd == '1') {
|
|
|
+ if (market2) {
|
|
|
+ profit = (data.open_price - currencyData.ask) * (data.volume) * currencyData.contract_size * rate
|
|
|
+ } else if (market1) {
|
|
|
+ profit = (( data.open_price - currencyData.ask) * (data.volume) * currencyData.contract_size) / rate
|
|
|
+ } else {
|
|
|
+ profit = ((data.open_price - currencyData.ask) * (data.volume) * currencyData.contract_size)
|
|
|
+ }
|
|
|
+ } else if (data.cmd == '0') {
|
|
|
+ if (market2) {
|
|
|
+ profit = (currencyData.bid - data.open_price) * (data.volume) * currencyData.contract_size * rate
|
|
|
+ } else if (market1) {
|
|
|
+ profit = ((currencyData.bid - data.open_price) * (data.volume) * currencyData.contract_size) / rate
|
|
|
+ } else {
|
|
|
+ profit = ((currencyData.bid - data.open_price) * (data.volume) * currencyData.contract_size)
|
|
|
+ }
|
|
|
+ }
|
|
|
+ }
|
|
|
+ } else {
|
|
|
+ if (data.cmd == '1') {
|
|
|
+ profit = (data.open_price - currencyData.ask) * (data.volume) * currencyData.contract_size
|
|
|
+ } else if (data.cmd == '0') {
|
|
|
+ profit = (currencyData.bid - data.open_price) * (data.volume) * currencyData.contract_size
|
|
|
+ }
|
|
|
+ }
|
|
|
+ if (profit) {
|
|
|
+ return profit.toFixed(2)
|
|
|
+ }
|
|
|
+ return '0.00'
|
|
|
+ },
|
|
|
+ getPercentage(value, equity) {
|
|
|
+ if (!value || !Number(equity)) {
|
|
|
+ return '0.00'
|
|
|
+ }
|
|
|
+ return (value/equity * 100).toFixed(2)
|
|
|
+ },
|
|
|
getFollowHistoryTradeList() {
|
|
|
getFollowHistoryTradeList({
|
|
|
eid: this.id,
|