mirror of
https://github.com/laoxong/nofx.git
synced 2026-06-04 09:58:22 +08:00
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:
@@ -27,6 +27,7 @@ type Store struct {
|
||||
backtest *BacktestStore
|
||||
order *OrderStore
|
||||
position *PositionStore
|
||||
strategy *StrategyStore
|
||||
|
||||
// 加密函数
|
||||
encryptFunc func(string) string
|
||||
@@ -151,6 +152,9 @@ func (s *Store) initTables() error {
|
||||
if err := s.Position().InitTables(); err != nil {
|
||||
return fmt.Errorf("初始化仓位表失败: %w", err)
|
||||
}
|
||||
if err := s.Strategy().initTables(); err != nil {
|
||||
return fmt.Errorf("初始化策略表失败: %w", err)
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -165,6 +169,9 @@ func (s *Store) initDefaultData() error {
|
||||
if err := s.SystemConfig().initDefaultData(); err != nil {
|
||||
return err
|
||||
}
|
||||
if err := s.Strategy().initDefaultData(); err != nil {
|
||||
return err
|
||||
}
|
||||
return nil
|
||||
}
|
||||
|
||||
@@ -289,6 +296,16 @@ func (s *Store) Position() *PositionStore {
|
||||
return s.position
|
||||
}
|
||||
|
||||
// Strategy 获取策略存储
|
||||
func (s *Store) Strategy() *StrategyStore {
|
||||
s.mu.Lock()
|
||||
defer s.mu.Unlock()
|
||||
if s.strategy == nil {
|
||||
s.strategy = &StrategyStore{db: s.db}
|
||||
}
|
||||
return s.strategy
|
||||
}
|
||||
|
||||
// Close 关闭数据库连接
|
||||
func (s *Store) Close() error {
|
||||
return s.db.Close()
|
||||
|
||||
Reference in New Issue
Block a user