修复CTA策略创建策略时,策略文件未更新bug

This commit is contained in:
simple321vip
2022-09-18 11:23:25 +08:00
parent c7aae62f43
commit 75f6a06e38
4 changed files with 25 additions and 42 deletions
+7 -15
View File
@@ -1,8 +1,8 @@
<template>
<div class="demo-collapse">
<el-collapse v-model="activeNames">
<el-collapse-item title="Account Info" name="1">
<el-row>
<el-collapse-item title="Accounts list" name="1">
<el-row v-for="account_data in account_datas">
<el-col :span="1">
<div class="cell-item">
<el-icon style="iconStyle">
@@ -184,12 +184,7 @@ const activeName = ref(1)
const volume = ref(1)
const price = ref(3000)
const timer = ref(0)
const account_data = reactive<AccountData>({
gateway_name: '',
account_id: '',
balance: 0.0,
frozen: 0.0
})
const account_datas = reactive<AccountData[]>([])
const positions_data = reactive<PositionData[]>([])
const trades_data = reactive<TradeData[]>([])
const orders_data = reactive<OrderData[]>([])
@@ -197,13 +192,10 @@ const activeNames = ref(['1'])
const on_query_accounts = () => {
get_accounts().then(res => {
let accounts: [] = res.data.accounts
let account: any = accounts.pop()
account_data.account_id = account.account_id
account_data.balance = account.balance
account_data.gateway_name = account.gateway_name
account_data.frozen = account.frozen
account_datas.length = 0
res.data.accounts.forEach((account: AccountData) => {
account_datas.push(account)
})
positions_data.length = 0
res.data.positions.forEach((element: PositionData) => {
positions_data.push(element)
-10
View File
@@ -21,16 +21,6 @@ onMounted(() => {
const init = () => {
get_strategy_load_files().then(res => {
store.$patch({ class_names: res.data.class_names })
}).catch(error => {
ElMessage({
message: h('p', null, [
h('i', { style: 'color: teal' }, "读取策略文件失败"),
]),
})
})
get_vt_symbols().then(res => {
console.log(res)
let map = new Map()
+16 -15
View File
@@ -61,7 +61,7 @@
</template>
<script setup lang="ts">
import { reactive, ref } from 'vue'
import { onMounted, reactive, ref } from 'vue'
import create_strategy_dialog from './dialog.vue'
import {
get_strategies,
@@ -71,17 +71,11 @@ import {
remove_strategy,
get_strategy_status,
get_strategy_load_files,
get_vt_symbols
} from '../../api/cta_strategy'
import { h } from 'vue'
import { ElMessage } from 'element-plus'
import { strategyStore } from '../../store/strategy'
const store = strategyStore()
let createStrategyDialogVisible = ref(false)
type Strategy = {
strategy_name: string,
class_name: string,
@@ -90,7 +84,10 @@ type Strategy = {
status: number,
}
const store = strategyStore()
let createStrategyDialogVisible = ref(false)
const strategy_list = reactive<Strategy[]>([])
const dialogRef = ref()
const on_list = () => {
createStrategyDialogVisible.value = false
@@ -101,7 +98,7 @@ const on_list = () => {
})
})
}
const dialogRef = ref()
const handle_create = () => {
createStrategyDialogVisible.value = true
dialogRef.value.clear_form()
@@ -114,8 +111,6 @@ const on_start = (row: any) => {
row.status = 2
})
})
}
const on_stop = (row: any) => {
@@ -135,12 +130,18 @@ const on_status = (row: any) => {
row.status = res.data.status
})
}
const init = () => {
onMounted(() => {
on_list()
}
// init process
init()
get_strategy_load_files().then(res => {
store.$patch({ class_names: res.data.class_names })
}).catch(error => {
ElMessage({
message: h('p', null, [
h('i', { style: 'color: teal' }, "读取策略文件失败"),
]),
})
})
})
</script>
+2 -2
View File
@@ -37,7 +37,7 @@
<el-table-column prop="url" label="加载" width="60">
<template #default="scope">
<span v-if="scope.row.status == 0" style="cursor: pointer">
<el-icon :size="20" @click="on_remove(scope.row)" color="blue">
<el-icon :size="20" @click="on_load(scope.row)" color="blue">
<CirclePlusFilled />
</el-icon>
</span>
@@ -46,7 +46,7 @@
<el-table-column prop="url" label="卸载" width="60">
<template #default="scope">
<span v-if="scope.row.status == 1" style="cursor: pointer">
<el-icon :size="20" @click="on_remove(scope.row)" color="red">
<el-icon :size="20" @click="on_unload(scope.row)" color="red">
<RemoveFilled />
</el-icon>
</span>