Files
nofx/web/src/stores/tradersModalStore.ts
tinkle-community 5cff32e4f2 Feature/custom strategy (#1172)
* feat: add Strategy Studio with multi-timeframe support
- Add Strategy Studio page with three-column layout for strategy management
- Support multi-timeframe K-line data selection (5m, 15m, 1h, 4h, etc.)
- Add GetWithTimeframes() function in market package for fetching multiple timeframes
- Add TimeframeSeriesData struct for storing per-timeframe technical indicators
- Update formatMarketData() to display all selected timeframes in AI prompt
- Add strategy API endpoints for CRUD operations and test run
- Integrate real AI test runs with configured AI models
- Support custom AI500 and OI Top API URLs from strategy config
* docs: add Strategy Studio screenshot to README files
* fix: correct strategy-studio.png filename case in README
* refactor: remove legacy signal source config and simplify trader creation
- Remove signal source configuration from traders page (now handled by strategy)
- Remove advanced options (legacy config) from TraderConfigModal
- Rename default strategy to "默认山寨策略" with AI500 coin pool URL
- Delete SignalSourceModal and SignalSourceWarning components
- Clean up related stores, hooks, and page components
2025-12-06 07:20:11 +08:00

76 lines
2.1 KiB
TypeScript

import { create } from 'zustand'
import type { TraderConfigData } from '../types'
interface TradersModalState {
// Modal 显示状态
showCreateModal: boolean
showEditModal: boolean
showModelModal: boolean
showExchangeModal: boolean
// 编辑状态
editingModel: string | null
editingExchange: string | null
editingTrader: TraderConfigData | null
// Actions
setShowCreateModal: (show: boolean) => void
setShowEditModal: (show: boolean) => void
setShowModelModal: (show: boolean) => void
setShowExchangeModal: (show: boolean) => void
setEditingModel: (modelId: string | null) => void
setEditingExchange: (exchangeId: string | null) => void
setEditingTrader: (trader: TraderConfigData | null) => void
// 便捷方法
openModelModal: (modelId?: string) => void
closeModelModal: () => void
openExchangeModal: (exchangeId?: string) => void
closeExchangeModal: () => void
// 重置
reset: () => void
}
const initialState = {
showCreateModal: false,
showEditModal: false,
showModelModal: false,
showExchangeModal: false,
editingModel: null,
editingExchange: null,
editingTrader: null,
}
export const useTradersModalStore = create<TradersModalState>((set) => ({
...initialState,
setShowCreateModal: (show) => set({ showCreateModal: show }),
setShowEditModal: (show) => set({ showEditModal: show }),
setShowModelModal: (show) => set({ showModelModal: show }),
setShowExchangeModal: (show) => set({ showExchangeModal: show }),
setEditingModel: (modelId) => set({ editingModel: modelId }),
setEditingExchange: (exchangeId) => set({ editingExchange: exchangeId }),
setEditingTrader: (trader) => set({ editingTrader: trader }),
openModelModal: (modelId) => {
set({ editingModel: modelId || null, showModelModal: true })
},
closeModelModal: () => {
set({ showModelModal: false, editingModel: null })
},
openExchangeModal: (exchangeId) => {
set({ editingExchange: exchangeId || null, showExchangeModal: true })
},
closeExchangeModal: () => {
set({ showExchangeModal: false, editingExchange: null })
},
reset: () => set(initialState),
}))