complete strategy develop
This commit is contained in:
+11
-2
@@ -66,14 +66,22 @@ const get_strategies = () => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
"create a strategy"
|
"create a strategy"
|
||||||
const create_strategy = (ruleForm: object) => {
|
const create_strategy = (ruleForm: any) => {
|
||||||
return trader_service({
|
return trader_service({
|
||||||
url: '/trader/api/v1/strategy',
|
url: '/trader/api/v1/strategy/' + ruleForm.strategy_name,
|
||||||
method: 'POST',
|
method: 'POST',
|
||||||
data: ruleForm
|
data: ruleForm
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|
||||||
|
"init a strategy"
|
||||||
|
const init_strategy = (strategy_name: string) => {
|
||||||
|
return trader_service({
|
||||||
|
url: '/trader/api/v1/strategy/init/' + strategy_name,
|
||||||
|
method: 'PUT',
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
"start a strategy"
|
"start a strategy"
|
||||||
const start_strategy = (strategy_name: string) => {
|
const start_strategy = (strategy_name: string) => {
|
||||||
return trader_service({
|
return trader_service({
|
||||||
@@ -123,6 +131,7 @@ export {
|
|||||||
remove_strategy_file,
|
remove_strategy_file,
|
||||||
get_strategies,
|
get_strategies,
|
||||||
create_strategy,
|
create_strategy,
|
||||||
|
init_strategy,
|
||||||
start_strategy,
|
start_strategy,
|
||||||
stop_strategy,
|
stop_strategy,
|
||||||
remove_strategy,
|
remove_strategy,
|
||||||
|
|||||||
@@ -9,7 +9,7 @@
|
|||||||
<el-table-column type="index" label="index" width="80" />
|
<el-table-column type="index" label="index" width="80" />
|
||||||
<el-table-column prop="strategy_name" label="策略名" width="200" />
|
<el-table-column prop="strategy_name" label="策略名" width="200" />
|
||||||
<el-table-column prop="class_name" label="策略类名" width="200" />
|
<el-table-column prop="class_name" label="策略类名" width="200" />
|
||||||
<el-table-column prop="vt_symbol" label="合约" width="100" />
|
<el-table-column prop="vt_symbol" label="合约" width="140" />
|
||||||
<el-table-column prop="status" label="状态" width="60">
|
<el-table-column prop="status" label="状态" width="60">
|
||||||
<template #default="scope">
|
<template #default="scope">
|
||||||
<el-icon v-if="scope.row.status == 0" :size="20">
|
<el-icon v-if="scope.row.status == 0" :size="20">
|
||||||
@@ -28,7 +28,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<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" @click="on_remove(scope.row)">
|
<span v-if="scope.row.status == 0 || scope.row.status == 3" style="cursor: pointer">
|
||||||
<el-icon :size="20" @click="on_start(scope.row)">
|
<el-icon :size="20" @click="on_start(scope.row)">
|
||||||
<VideoPlay />
|
<VideoPlay />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
@@ -37,7 +37,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<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 == 2" style="cursor: pointer" @click="on_remove(scope.row)">
|
<span v-if="scope.row.status == 2" style="cursor: pointer">
|
||||||
<el-icon :size="20" @click="on_stop(scope.row)">
|
<el-icon :size="20" @click="on_stop(scope.row)">
|
||||||
<VideoPause />
|
<VideoPause />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
@@ -46,7 +46,7 @@
|
|||||||
</el-table-column>
|
</el-table-column>
|
||||||
<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" @click="on_remove(scope.row)">
|
<span v-if="scope.row.status == 0 || scope.row.status == 3" style="cursor: pointer">
|
||||||
<el-icon :size="20" @click="on_remove(scope.row)">
|
<el-icon :size="20" @click="on_remove(scope.row)">
|
||||||
<Delete />
|
<Delete />
|
||||||
</el-icon>
|
</el-icon>
|
||||||
@@ -65,8 +65,10 @@ import { reactive, ref } from 'vue'
|
|||||||
import create_strategy_dialog from './dialog.vue'
|
import create_strategy_dialog from './dialog.vue'
|
||||||
import {
|
import {
|
||||||
get_strategies,
|
get_strategies,
|
||||||
|
init_strategy,
|
||||||
start_strategy,
|
start_strategy,
|
||||||
stop_strategy,
|
stop_strategy,
|
||||||
|
remove_strategy,
|
||||||
get_strategy_status,
|
get_strategy_status,
|
||||||
get_strategy_load_files,
|
get_strategy_load_files,
|
||||||
get_vt_symbols
|
get_vt_symbols
|
||||||
@@ -91,6 +93,7 @@ type Strategy = {
|
|||||||
const strategy_list = reactive<Strategy[]>([])
|
const strategy_list = reactive<Strategy[]>([])
|
||||||
|
|
||||||
const on_list = () => {
|
const on_list = () => {
|
||||||
|
createStrategyDialogVisible.value = false
|
||||||
get_strategies().then(res => {
|
get_strategies().then(res => {
|
||||||
strategy_list.length = 0
|
strategy_list.length = 0
|
||||||
res.data.forEach((item: Strategy, index: number) => {
|
res.data.forEach((item: Strategy, index: number) => {
|
||||||
@@ -104,11 +107,15 @@ const handle_create = () => {
|
|||||||
dialogRef.value.clear_form()
|
dialogRef.value.clear_form()
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
const on_start = (row: any) => {
|
const on_start = (row: any) => {
|
||||||
|
init_strategy(row.strategy_name).then(res => {
|
||||||
|
row.status = 1
|
||||||
start_strategy(row.strategy_name).then(res => {
|
start_strategy(row.strategy_name).then(res => {
|
||||||
row.status = 2
|
row.status = 2
|
||||||
})
|
})
|
||||||
|
})
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
const on_stop = (row: any) => {
|
const on_stop = (row: any) => {
|
||||||
@@ -118,7 +125,7 @@ const on_stop = (row: any) => {
|
|||||||
}
|
}
|
||||||
|
|
||||||
const on_remove = (row: any) => {
|
const on_remove = (row: any) => {
|
||||||
stop_strategy(row.strategy_name).then(res => {
|
remove_strategy(row.strategy_name).then(res => {
|
||||||
on_list()
|
on_list()
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
@@ -142,15 +149,15 @@ const init = () => {
|
|||||||
})
|
})
|
||||||
})
|
})
|
||||||
|
|
||||||
// get_vt_symbols().then(res => {
|
get_vt_symbols().then(res => {
|
||||||
// console.log(res)
|
store.$patch({ vt_symbols: res.data.vt_symbols })
|
||||||
// }).catch(error => {
|
}).catch(error => {
|
||||||
// ElMessage({
|
ElMessage({
|
||||||
// message: h('p', null, [
|
message: h('p', null, [
|
||||||
// h('i', { style: 'color: teal' }, "读取vt_symbols失败"),
|
h('i', { style: 'color: teal' }, "读取vt_symbols失败"),
|
||||||
// ]),
|
]),
|
||||||
// })
|
})
|
||||||
// })
|
})
|
||||||
}
|
}
|
||||||
// init process
|
// init process
|
||||||
init()
|
init()
|
||||||
|
|||||||
Reference in New Issue
Block a user