修复CTA策略创建策略时,策略文件未更新bug
This commit is contained in:
@@ -1,8 +1,8 @@
|
|||||||
<template>
|
<template>
|
||||||
<div class="demo-collapse">
|
<div class="demo-collapse">
|
||||||
<el-collapse v-model="activeNames">
|
<el-collapse v-model="activeNames">
|
||||||
<el-collapse-item title="Account Info" name="1">
|
<el-collapse-item title="Accounts list" name="1">
|
||||||
<el-row>
|
<el-row v-for="account_data in account_datas">
|
||||||
<el-col :span="1">
|
<el-col :span="1">
|
||||||
<div class="cell-item">
|
<div class="cell-item">
|
||||||
<el-icon style="iconStyle">
|
<el-icon style="iconStyle">
|
||||||
@@ -184,12 +184,7 @@ const activeName = ref(1)
|
|||||||
const volume = ref(1)
|
const volume = ref(1)
|
||||||
const price = ref(3000)
|
const price = ref(3000)
|
||||||
const timer = ref(0)
|
const timer = ref(0)
|
||||||
const account_data = reactive<AccountData>({
|
const account_datas = reactive<AccountData[]>([])
|
||||||
gateway_name: '',
|
|
||||||
account_id: '',
|
|
||||||
balance: 0.0,
|
|
||||||
frozen: 0.0
|
|
||||||
})
|
|
||||||
const positions_data = reactive<PositionData[]>([])
|
const positions_data = reactive<PositionData[]>([])
|
||||||
const trades_data = reactive<TradeData[]>([])
|
const trades_data = reactive<TradeData[]>([])
|
||||||
const orders_data = reactive<OrderData[]>([])
|
const orders_data = reactive<OrderData[]>([])
|
||||||
@@ -197,13 +192,10 @@ const activeNames = ref(['1'])
|
|||||||
|
|
||||||
const on_query_accounts = () => {
|
const on_query_accounts = () => {
|
||||||
get_accounts().then(res => {
|
get_accounts().then(res => {
|
||||||
let accounts: [] = res.data.accounts
|
account_datas.length = 0
|
||||||
let account: any = accounts.pop()
|
res.data.accounts.forEach((account: AccountData) => {
|
||||||
account_data.account_id = account.account_id
|
account_datas.push(account)
|
||||||
account_data.balance = account.balance
|
})
|
||||||
account_data.gateway_name = account.gateway_name
|
|
||||||
account_data.frozen = account.frozen
|
|
||||||
|
|
||||||
positions_data.length = 0
|
positions_data.length = 0
|
||||||
res.data.positions.forEach((element: PositionData) => {
|
res.data.positions.forEach((element: PositionData) => {
|
||||||
positions_data.push(element)
|
positions_data.push(element)
|
||||||
|
|||||||
@@ -21,16 +21,6 @@ onMounted(() => {
|
|||||||
|
|
||||||
const init = () => {
|
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 => {
|
get_vt_symbols().then(res => {
|
||||||
console.log(res)
|
console.log(res)
|
||||||
let map = new Map()
|
let map = new Map()
|
||||||
|
|||||||
@@ -61,7 +61,7 @@
|
|||||||
</template>
|
</template>
|
||||||
|
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { reactive, ref } from 'vue'
|
import { onMounted, reactive, ref } from 'vue'
|
||||||
import create_strategy_dialog from './dialog.vue'
|
import create_strategy_dialog from './dialog.vue'
|
||||||
import {
|
import {
|
||||||
get_strategies,
|
get_strategies,
|
||||||
@@ -71,17 +71,11 @@ import {
|
|||||||
remove_strategy,
|
remove_strategy,
|
||||||
get_strategy_status,
|
get_strategy_status,
|
||||||
get_strategy_load_files,
|
get_strategy_load_files,
|
||||||
get_vt_symbols
|
|
||||||
} from '../../api/cta_strategy'
|
} from '../../api/cta_strategy'
|
||||||
import { h } from 'vue'
|
import { h } from 'vue'
|
||||||
import { ElMessage } from 'element-plus'
|
import { ElMessage } from 'element-plus'
|
||||||
import { strategyStore } from '../../store/strategy'
|
import { strategyStore } from '../../store/strategy'
|
||||||
|
|
||||||
const store = strategyStore()
|
|
||||||
|
|
||||||
let createStrategyDialogVisible = ref(false)
|
|
||||||
|
|
||||||
|
|
||||||
type Strategy = {
|
type Strategy = {
|
||||||
strategy_name: string,
|
strategy_name: string,
|
||||||
class_name: string,
|
class_name: string,
|
||||||
@@ -90,7 +84,10 @@ type Strategy = {
|
|||||||
status: number,
|
status: number,
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const store = strategyStore()
|
||||||
|
let createStrategyDialogVisible = ref(false)
|
||||||
const strategy_list = reactive<Strategy[]>([])
|
const strategy_list = reactive<Strategy[]>([])
|
||||||
|
const dialogRef = ref()
|
||||||
|
|
||||||
const on_list = () => {
|
const on_list = () => {
|
||||||
createStrategyDialogVisible.value = false
|
createStrategyDialogVisible.value = false
|
||||||
@@ -101,7 +98,7 @@ const on_list = () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
const dialogRef = ref()
|
|
||||||
const handle_create = () => {
|
const handle_create = () => {
|
||||||
createStrategyDialogVisible.value = true
|
createStrategyDialogVisible.value = true
|
||||||
dialogRef.value.clear_form()
|
dialogRef.value.clear_form()
|
||||||
@@ -114,8 +111,6 @@ const on_start = (row: any) => {
|
|||||||
row.status = 2
|
row.status = 2
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const on_stop = (row: any) => {
|
const on_stop = (row: any) => {
|
||||||
@@ -135,12 +130,18 @@ const on_status = (row: any) => {
|
|||||||
row.status = res.data.status
|
row.status = res.data.status
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
onMounted(() => {
|
||||||
const init = () => {
|
|
||||||
on_list()
|
on_list()
|
||||||
}
|
get_strategy_load_files().then(res => {
|
||||||
// init process
|
store.$patch({ class_names: res.data.class_names })
|
||||||
init()
|
}).catch(error => {
|
||||||
|
ElMessage({
|
||||||
|
message: h('p', null, [
|
||||||
|
h('i', { style: 'color: teal' }, "读取策略文件失败"),
|
||||||
|
]),
|
||||||
|
})
|
||||||
|
})
|
||||||
|
})
|
||||||
|
|
||||||
</script>
|
</script>
|
||||||
|
|
||||||
|
|||||||
@@ -37,7 +37,7 @@
|
|||||||
<el-table-column prop="url" label="加载" width="60">
|
<el-table-column prop="url" label="加载" width="60">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<span v-if="scope.row.status == 0" style="cursor: pointer">
|
<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 />
|
<CirclePlusFilled />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
</span>
|
</span>
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
<el-table-column prop="url" label="卸载" width="60">
|
<el-table-column prop="url" label="卸载" width="60">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<span v-if="scope.row.status == 1" style="cursor: pointer">
|
<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 />
|
<RemoveFilled />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
</span>
|
</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user