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
This commit is contained in:
tinkle-community
2025-12-06 07:20:11 +08:00
committed by GitHub
parent afb2d158ac
commit 5cff32e4f2
37 changed files with 4965 additions and 1051 deletions

View File

@@ -2,18 +2,12 @@ import { create } from 'zustand'
import type { AIModel, Exchange } from '../types'
import { api } from '../lib/api'
interface SignalSource {
coinPoolUrl: string
oiTopUrl: string
}
interface TradersConfigState {
// 数据
allModels: AIModel[]
allExchanges: Exchange[]
supportedModels: AIModel[]
supportedExchanges: Exchange[]
userSignalSource: SignalSource
// 计算属性
configuredModels: AIModel[]
@@ -24,7 +18,6 @@ interface TradersConfigState {
setAllExchanges: (exchanges: Exchange[]) => void
setSupportedModels: (models: AIModel[]) => void
setSupportedExchanges: (exchanges: Exchange[]) => void
setUserSignalSource: (source: SignalSource) => void
// 异步加载
loadConfigs: (user: any, token: string | null) => Promise<void>
@@ -38,7 +31,6 @@ const initialState = {
allExchanges: [],
supportedModels: [],
supportedExchanges: [],
userSignalSource: { coinPoolUrl: '', oiTopUrl: '' },
configuredModels: [],
configuredExchanges: [],
}
@@ -73,7 +65,6 @@ export const useTradersConfigStore = create<TradersConfigState>((set, get) => ({
setSupportedModels: (models) => set({ supportedModels: models }),
setSupportedExchanges: (exchanges) => set({ supportedExchanges: exchanges }),
setUserSignalSource: (source) => set({ userSignalSource: source }),
loadConfigs: async (user, token) => {
if (!user || !token) {
@@ -108,17 +99,6 @@ export const useTradersConfigStore = create<TradersConfigState>((set, get) => ({
get().setAllExchanges(exchangeConfigs)
get().setSupportedModels(supportedModels)
get().setSupportedExchanges(supportedExchanges)
// 加载用户信号源配置
try {
const signalSource = await api.getUserSignalSource()
get().setUserSignalSource({
coinPoolUrl: signalSource.coin_pool_url || '',
oiTopUrl: signalSource.oi_top_url || '',
})
} catch (error) {
console.log('📡 用户信号源配置暂未设置')
}
} catch (error) {
console.error('Failed to load configs:', error)
}

View File

@@ -7,7 +7,6 @@ interface TradersModalState {
showEditModal: boolean
showModelModal: boolean
showExchangeModal: boolean
showSignalSourceModal: boolean
// 编辑状态
editingModel: string | null
@@ -19,7 +18,6 @@ interface TradersModalState {
setShowEditModal: (show: boolean) => void
setShowModelModal: (show: boolean) => void
setShowExchangeModal: (show: boolean) => void
setShowSignalSourceModal: (show: boolean) => void
setEditingModel: (modelId: string | null) => void
setEditingExchange: (exchangeId: string | null) => void
@@ -40,7 +38,6 @@ const initialState = {
showEditModal: false,
showModelModal: false,
showExchangeModal: false,
showSignalSourceModal: false,
editingModel: null,
editingExchange: null,
editingTrader: null,
@@ -53,7 +50,6 @@ export const useTradersModalStore = create<TradersModalState>((set) => ({
setShowEditModal: (show) => set({ showEditModal: show }),
setShowModelModal: (show) => set({ showModelModal: show }),
setShowExchangeModal: (show) => set({ showExchangeModal: show }),
setShowSignalSourceModal: (show) => set({ showSignalSourceModal: show }),
setEditingModel: (modelId) => set({ editingModel: modelId }),
setEditingExchange: (exchangeId) => set({ editingExchange: exchangeId }),