Merge the single and multi strategy panels into one
The single "Strategy" panel and "Strategies (multi)" were redundant: the multi panel with one row is exactly the single-strategy behaviour. Remove StrategyPanel and make "Strategies" the one trading panel. Presets move into it (load adds a row, per-row Save), and the header now reports "N strategies" when several run instead of only the first. Deletes the obsolete component and its test; adds preset tests to the multi-strategy suite.
This commit is contained in:
1 parent
d4d864dc5c
commit
50b22df948
6 files changed
+119
-176
No files matched your search
+26
-59
@@ -9,7 +9,6 @@ import MultiStrategyPanel from './components/MultiStrategyPanel.vue'
|
||||
import OrdersTable from './components/OrdersTable.vue'
|
||||
import PositionsTable from './components/PositionsTable.vue'
|
||||
import StatusCards from './components/StatusCards.vue'
|
||||
import StrategyPanel from './components/StrategyPanel.vue'
|
||||
import SweepPanel from './components/SweepPanel.vue'
|
||||
|
||||
const status = ref({
|
||||
@@ -35,6 +34,27 @@ const strategiesLoading = ref(true)
|
||||
const presets = ref([])
|
||||
const multiStatus = ref({ running: false, strategies: [], total_pnl: 0, equity: 0 })
|
||||
const liveCheck = ref({ ok: true, mode: 'paper', blockers: [] })
|
||||
|
||||
const runningLabel = computed(() => {
|
||||
const list = multiStatus.value.strategies || []
|
||||
if (!list.length) return 'Idle'
|
||||
if (list.length === 1) {
|
||||
return `Running: ${list[0].strategy_name || list[0].strategy_key}`
|
||||
}
|
||||
return `Running: ${list.length} strategies`
|
||||
})
|
||||
|
||||
const scopeLabel = computed(() => {
|
||||
const list = multiStatus.value.strategies || []
|
||||
if (!list.length) {
|
||||
return status.value.symbol ? `${status.value.symbol} ${status.value.timeframe}` : ''
|
||||
}
|
||||
const first = list[0]
|
||||
const sameScope = list.every(
|
||||
(s) => s.symbol === first.symbol && s.timeframe === first.timeframe,
|
||||
)
|
||||
return sameScope ? `${first.symbol} ${first.timeframe}` : `${list.length} pairs`
|
||||
})
|
||||
const positions = ref([])
|
||||
const orders = ref([])
|
||||
const events = ref([])
|
||||
@@ -98,25 +118,6 @@ async function handleDeletePreset(id) {
|
||||
await loadPresets()
|
||||
}
|
||||
|
||||
async function handleStart(payload) {
|
||||
if (liveCheck.value.mode === 'live' && !liveCheck.value.ok) {
|
||||
status.value = {
|
||||
...status.value,
|
||||
error: 'Live trading blocked: ' + liveCheck.value.blockers.join('; '),
|
||||
}
|
||||
return
|
||||
}
|
||||
busy.value = true
|
||||
try {
|
||||
status.value = await api.startBot(payload)
|
||||
await refreshAll()
|
||||
} catch (error) {
|
||||
status.value = { ...status.value, error: error.response?.data?.detail || error.message }
|
||||
} finally {
|
||||
busy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function refreshMulti() {
|
||||
multiStatus.value = await api.getMultiStatus()
|
||||
}
|
||||
@@ -168,29 +169,6 @@ async function handleKillMany() {
|
||||
}
|
||||
}
|
||||
|
||||
async function handleStop() {
|
||||
busy.value = true
|
||||
try {
|
||||
status.value = await api.stopBot()
|
||||
await refreshMulti()
|
||||
await refreshAll()
|
||||
} finally {
|
||||
busy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleKill() {
|
||||
busy.value = true
|
||||
try {
|
||||
status.value = await api.killBot('manual kill switch')
|
||||
await refreshAll()
|
||||
} catch (error) {
|
||||
status.value = { ...status.value, error: error.response?.data?.detail || error.message }
|
||||
} finally {
|
||||
busy.value = false
|
||||
}
|
||||
}
|
||||
|
||||
async function handleClose(id) {
|
||||
try {
|
||||
status.value = await api.closePosition(id)
|
||||
@@ -314,9 +292,8 @@ onUnmounted(() => {
|
||||
</span>
|
||||
</div>
|
||||
<div class="text-xs text-slate-400">
|
||||
<span v-if="status.strategy_name">Running: {{ status.strategy_name }}</span>
|
||||
<span v-else>Idle</span>
|
||||
<span v-if="status.symbol"> · {{ status.symbol }} {{ status.timeframe }}</span>
|
||||
<span>{{ runningLabel }}</span>
|
||||
<span v-if="scopeLabel"> · {{ scopeLabel }}</span>
|
||||
</div>
|
||||
</header>
|
||||
|
||||
@@ -344,27 +321,17 @@ onUnmounted(() => {
|
||||
|
||||
<StatusCards :status="status" />
|
||||
|
||||
<StrategyPanel
|
||||
:strategies="strategies"
|
||||
:status="status"
|
||||
:busy="busy"
|
||||
:presets="presets"
|
||||
:loading="strategiesLoading"
|
||||
@start="handleStart"
|
||||
@stop="handleStop"
|
||||
@kill="handleKill"
|
||||
@save-preset="handleSavePreset"
|
||||
@delete-preset="handleDeletePreset"
|
||||
/>
|
||||
|
||||
<MultiStrategyPanel
|
||||
:strategies="strategies"
|
||||
:multi-status="multiStatus"
|
||||
:presets="presets"
|
||||
:busy="busy"
|
||||
:loading="strategiesLoading"
|
||||
@start-many="handleStartMany"
|
||||
@stop="handleStopMany"
|
||||
@kill="handleKillMany"
|
||||
@save-preset="handleSavePreset"
|
||||
@delete-preset="handleDeletePreset"
|
||||
/>
|
||||
|
||||
<BacktestPanel :strategies="strategies" :status="status" :loading="strategiesLoading" />
|
||||
|
||||
Reference in new issue
Block a user