From 4320f35a527553853994f3b8dc2df4ea2c4c9636 Mon Sep 17 00:00:00 2001 From: simple321vip Date: Wed, 14 Sep 2022 23:11:36 +0800 Subject: [PATCH] =?UTF-8?q?simnow=20=E4=BB=BF=E7=9C=9F=E5=AE=9E=E6=B5=8B?= =?UTF-8?q?=E9=80=9A=E8=BF=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/view/capital/index.vue | 128 +++++++++++++++++++++++++---------- src/view/dashboard/index.vue | 2 +- src/view/recommend/index.vue | 34 +++++++--- 3 files changed, 117 insertions(+), 47 deletions(-) diff --git a/src/view/capital/index.vue b/src/view/capital/index.vue index 80816e0..a1969a9 100644 --- a/src/view/capital/index.vue +++ b/src/view/capital/index.vue @@ -57,28 +57,45 @@ - - - - - + + + + + + + + + - - - - + + + + + + - - - - + + + + + + + + + + + + - - - - - - + + + + + + + + + @@ -87,7 +104,7 @@ import { ElMessage, TabsPaneContext } from 'element-plus' import { reactive, ref, h, onMounted, onUnmounted } from 'vue' -import { get_accounts, send_order, get_contract, subscribe } from '../../api/capital' +import { get_accounts, send_order, get_tick } from '../../api/capital' import { strategyStore } from '../../store/strategy'; type AccountData = { geteway_name: string @@ -97,19 +114,41 @@ type AccountData = { } type PositionData = { symbol: string + exchange: string direction: string - open_price: number - gain_loss: number -} -type DealData = { - symbol: string - direction: string - price: number volume: number + price: number + frozen: number + pnl: number + yd_volume: number +} +type OrderData = { + symbol: string + exchange: string + direction: string + volume: number + price: number + orderid: string + type: string + offset: string + traded: number + status: string + // datetime :datetime + reference: string +} +type TradeData = { + symbol: string + exchange: string + direction: string + volume: number + price: number + orderid: string + tradeid: string + offset: string + // datetime: datetime } const store = strategyStore() const vt_symbol = ref("") -const contracts = reactive([]) const direction = ref('多') const offset = ref('开') const activeName = ref(1) @@ -122,20 +161,39 @@ const account_data = reactive({ balance: 0.0, frozen: 0.0 }) -const position_data = reactive([]) -const deal_data = reactive([]) +const positions_data = reactive([]) +const trades_data = reactive([]) +const orders_data = reactive([]) const on_query_accounts = () => { get_accounts().then(res => { - account_data.account_id = res.data.account_id - account_data.balance = res.data.balance - account_data.geteway_name = res.data.geteway_name - account_data.frozen = res.data.frozen + let accounts: [] = res.data.accounts + let account: any = accounts.pop() + account_data.account_id = account.account_id + account_data.balance = account.balance + account_data.geteway_name = account.geteway_name + account_data.frozen = account.frozen + + positions_data.length = 0 + res.data.positions.forEach((element: PositionData) => { + positions_data.push(element) + }) + + trades_data.length = 0 + res.data.trades.forEach((element: TradeData) => { + trades_data.push(element) + }) + + orders_data.length = 0 + res.data.orders.forEach((element: OrderData) => { + orders_data.push(element) + }) + }) } const select_contract = () => { - subscribe(vt_symbol.value).then(res => { + get_tick(vt_symbol.value).then(res => { price.value = res.data.tick.last_price }) } diff --git a/src/view/dashboard/index.vue b/src/view/dashboard/index.vue index 365a75f..96667fc 100644 --- a/src/view/dashboard/index.vue +++ b/src/view/dashboard/index.vue @@ -48,7 +48,7 @@ const init = () => { }) get_subscribe_vt_symbols().then(res => { - store.$patch({ vt_symbols: res.data.vt_symbols }) + store.$patch({ subscribe_vt_symbols: res.data.vt_symbols }) }).catch(error => { ElMessage({ message: h('p', null, [ diff --git a/src/view/recommend/index.vue b/src/view/recommend/index.vue index 01686ea..bcb9cfe 100644 --- a/src/view/recommend/index.vue +++ b/src/view/recommend/index.vue @@ -1,22 +1,22 @@