diff --git a/src/api/cta_strategy.ts b/src/api/cta_strategy.ts
index 0979edf..f9dc129 100644
--- a/src/api/cta_strategy.ts
+++ b/src/api/cta_strategy.ts
@@ -66,14 +66,22 @@ const get_strategies = () => {
}
"create a strategy"
-const create_strategy = (ruleForm: object) => {
+const create_strategy = (ruleForm: any) => {
return trader_service({
- url: '/trader/api/v1/strategy',
+ url: '/trader/api/v1/strategy/' + ruleForm.strategy_name,
method: 'POST',
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"
const start_strategy = (strategy_name: string) => {
return trader_service({
@@ -123,6 +131,7 @@ export {
remove_strategy_file,
get_strategies,
create_strategy,
+ init_strategy,
start_strategy,
stop_strategy,
remove_strategy,
diff --git a/src/view/trader/cta_strategy.vue b/src/view/trader/cta_strategy.vue
index ed4f71a..76b94af 100644
--- a/src/view/trader/cta_strategy.vue
+++ b/src/view/trader/cta_strategy.vue
@@ -9,7 +9,7 @@
-
+
@@ -28,7 +28,7 @@
-
+
@@ -37,7 +37,7 @@
-
+
@@ -46,7 +46,7 @@
-
+
@@ -65,8 +65,10 @@ import { reactive, ref } from 'vue'
import create_strategy_dialog from './dialog.vue'
import {
get_strategies,
+ init_strategy,
start_strategy,
stop_strategy,
+ remove_strategy,
get_strategy_status,
get_strategy_load_files,
get_vt_symbols
@@ -91,6 +93,7 @@ type Strategy = {
const strategy_list = reactive([])
const on_list = () => {
+ createStrategyDialogVisible.value = false
get_strategies().then(res => {
strategy_list.length = 0
res.data.forEach((item: Strategy, index: number) => {
@@ -104,11 +107,15 @@ const handle_create = () => {
dialogRef.value.clear_form()
}
-
const on_start = (row: any) => {
- start_strategy(row.strategy_name).then(res => {
- row.status = 2
+ init_strategy(row.strategy_name).then(res => {
+ row.status = 1
+ start_strategy(row.strategy_name).then(res => {
+ row.status = 2
+ })
})
+
+
}
const on_stop = (row: any) => {
@@ -118,7 +125,7 @@ const on_stop = (row: any) => {
}
const on_remove = (row: any) => {
- stop_strategy(row.strategy_name).then(res => {
+ remove_strategy(row.strategy_name).then(res => {
on_list()
})
}
@@ -142,15 +149,15 @@ const init = () => {
})
})
- // get_vt_symbols().then(res => {
- // console.log(res)
- // }).catch(error => {
- // ElMessage({
- // message: h('p', null, [
- // h('i', { style: 'color: teal' }, "读取vt_symbols失败"),
- // ]),
- // })
- // })
+ get_vt_symbols().then(res => {
+ store.$patch({ vt_symbols: res.data.vt_symbols })
+ }).catch(error => {
+ ElMessage({
+ message: h('p', null, [
+ h('i', { style: 'color: teal' }, "读取vt_symbols失败"),
+ ]),
+ })
+ })
}
// init process
init()