Split strategy config by strategy type

This commit is contained in:
lky-spec
2026-04-28 20:19:24 +08:00
parent 2d45e7ab15
commit 25d0b30ea9
11 changed files with 502 additions and 148 deletions

View File

@@ -271,92 +271,99 @@ func strategyConfigSchema() map[string]any {
"type": "object",
"description": "Full or partial strategy config. Only include the fields you want to create or update.",
"properties": map[string]any{
"strategy_type": map[string]any{"type": "string", "enum": []string{"ai_trading", "grid_trading"}, "description": "ai_trading uses coin source, indicators, risk_control, and prompts. grid_trading uses grid_config and publish settings."},
"strategy_type": map[string]any{"type": "string", "enum": []string{"ai_trading", "grid_trading"}, "description": "Top-level discriminator. ai_trading must use ai_config only. grid_trading must use grid_config only."},
"language": map[string]any{"type": "string", "enum": []string{"zh", "en"}},
"coin_source": map[string]any{
"type": "object",
"ai_config": map[string]any{
"type": "object",
"description": "AI trading only. Do not include this for grid_trading.",
"properties": map[string]any{
"source_type": map[string]any{"type": "string", "enum": []string{"static", "ai500", "oi_top", "oi_low", "mixed"}, "description": "Manual page coin source: static, ai500, oi_top, oi_low; mixed can be displayed when already configured."},
"static_coins": stringArraySchema("Static coin symbols such as BTCUSDT or ETHUSDT. Manual page allows at most 10. xyz: assets such as xyz:TSLA, xyz:GOLD, xyz:XYZ100 are also supported."),
"excluded_coins": stringArraySchema("Coin symbols to exclude from all sources."),
"use_ai500": map[string]any{"type": "boolean"},
"ai500_limit": map[string]any{"type": "number", "minimum": 1, "maximum": 10, "description": "Manual page range 1-10."},
"use_oi_top": map[string]any{"type": "boolean"},
"oi_top_limit": map[string]any{"type": "number", "minimum": 1, "maximum": 10, "description": "Manual page range 1-10."},
"use_oi_low": map[string]any{"type": "boolean"},
"oi_low_limit": map[string]any{"type": "number", "minimum": 1, "maximum": 10, "description": "Manual page range 1-10."},
"use_hyper_all": map[string]any{"type": "boolean"},
"use_hyper_main": map[string]any{"type": "boolean"},
"hyper_main_limit": map[string]any{"type": "number"},
},
},
"indicators": map[string]any{
"type": "object",
"properties": map[string]any{
"klines": map[string]any{
"coin_source": map[string]any{
"type": "object",
"properties": map[string]any{
"primary_timeframe": map[string]any{"type": "string", "enum": []string{"1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "8h", "12h", "1d", "3d", "1w"}},
"primary_count": map[string]any{"type": "number", "minimum": 10, "maximum": 30, "description": "Manual page range 10-30."},
"longer_timeframe": map[string]any{"type": "string"},
"longer_count": map[string]any{"type": "number"},
"enable_multi_timeframe": map[string]any{"type": "boolean"},
"selected_timeframes": stringArraySchema("Selected analysis timeframes. Allowed values: 1m,3m,5m,15m,30m,1h,2h,4h,6h,8h,12h,1d,3d,1w. Manual page allows at most 4."),
"source_type": map[string]any{"type": "string", "enum": []string{"static", "ai500", "oi_top", "oi_low", "mixed"}, "description": "Manual page coin source: static, ai500, oi_top, oi_low; mixed can be displayed when already configured."},
"static_coins": stringArraySchema("Static coin symbols such as BTCUSDT or ETHUSDT. Manual page allows at most 10. xyz: assets such as xyz:TSLA, xyz:GOLD, xyz:XYZ100 are also supported."),
"excluded_coins": stringArraySchema("Coin symbols to exclude from all sources."),
"use_ai500": map[string]any{"type": "boolean"},
"ai500_limit": map[string]any{"type": "number", "minimum": 1, "maximum": 10, "description": "Manual page range 1-10."},
"use_oi_top": map[string]any{"type": "boolean"},
"oi_top_limit": map[string]any{"type": "number", "minimum": 1, "maximum": 10, "description": "Manual page range 1-10."},
"use_oi_low": map[string]any{"type": "boolean"},
"oi_low_limit": map[string]any{"type": "number", "minimum": 1, "maximum": 10, "description": "Manual page range 1-10."},
"use_hyper_all": map[string]any{"type": "boolean"},
"use_hyper_main": map[string]any{"type": "boolean"},
"hyper_main_limit": map[string]any{"type": "number"},
},
},
"indicators": map[string]any{
"type": "object",
"properties": map[string]any{
"klines": map[string]any{
"type": "object",
"properties": map[string]any{
"primary_timeframe": map[string]any{"type": "string", "enum": []string{"1m", "3m", "5m", "15m", "30m", "1h", "2h", "4h", "6h", "8h", "12h", "1d", "3d", "1w"}},
"primary_count": map[string]any{"type": "number", "minimum": 10, "maximum": 30, "description": "Manual page range 10-30."},
"longer_timeframe": map[string]any{"type": "string"},
"longer_count": map[string]any{"type": "number"},
"enable_multi_timeframe": map[string]any{"type": "boolean"},
"selected_timeframes": stringArraySchema("Selected analysis timeframes. Allowed values: 1m,3m,5m,15m,30m,1h,2h,4h,6h,8h,12h,1d,3d,1w. Manual page allows at most 4."),
},
},
"enable_raw_klines": map[string]any{"type": "boolean"},
"enable_ema": map[string]any{"type": "boolean"},
"enable_macd": map[string]any{"type": "boolean"},
"enable_rsi": map[string]any{"type": "boolean"},
"enable_atr": map[string]any{"type": "boolean"},
"enable_boll": map[string]any{"type": "boolean"},
"enable_volume": map[string]any{"type": "boolean"},
"enable_oi": map[string]any{"type": "boolean"},
"enable_funding_rate": map[string]any{"type": "boolean"},
"ema_periods": intArraySchema("EMA periods such as [20,50]."),
"rsi_periods": intArraySchema("RSI periods such as [7,14]."),
"atr_periods": intArraySchema("ATR periods such as [14]."),
"boll_periods": intArraySchema("BOLL periods such as [20]."),
"nofxos_api_key": map[string]any{"type": "string"},
"enable_quant_data": map[string]any{"type": "boolean"},
"enable_quant_oi": map[string]any{"type": "boolean"},
"enable_quant_netflow": map[string]any{"type": "boolean"},
"enable_oi_ranking": map[string]any{"type": "boolean"},
"oi_ranking_duration": map[string]any{"type": "string", "enum": []string{"1h", "4h", "24h"}},
"oi_ranking_limit": map[string]any{"type": "number", "enum": []int{5, 10, 15, 20}},
"enable_netflow_ranking": map[string]any{"type": "boolean"},
"netflow_ranking_duration": map[string]any{"type": "string", "enum": []string{"1h", "4h", "24h"}},
"netflow_ranking_limit": map[string]any{"type": "number", "enum": []int{5, 10, 15, 20}},
"enable_price_ranking": map[string]any{"type": "boolean"},
"price_ranking_duration": map[string]any{"type": "string", "enum": []string{"1h", "4h", "24h", "1h,4h,24h"}},
"price_ranking_limit": map[string]any{"type": "number", "enum": []int{5, 10, 15, 20}},
},
},
"custom_prompt": map[string]any{"type": "string"},
"risk_control": map[string]any{
"type": "object",
"properties": map[string]any{
"max_positions": map[string]any{"type": "number", "description": "Displayed as System enforced on the manual strategy page; do not change unless the user explicitly asks for advanced configuration."},
"btc_eth_max_leverage": map[string]any{"type": "number", "minimum": 1, "maximum": 20},
"altcoin_max_leverage": map[string]any{"type": "number", "minimum": 1, "maximum": 20},
"btc_eth_max_position_value_ratio": map[string]any{"type": "number", "description": "Displayed as System enforced on the manual strategy page; do not change unless explicitly requested."},
"altcoin_max_position_value_ratio": map[string]any{"type": "number", "description": "Displayed as System enforced on the manual strategy page; do not change unless explicitly requested."},
"max_margin_usage": map[string]any{"type": "number", "description": "Displayed as System enforced on the manual strategy page; do not change unless explicitly requested."},
"min_risk_reward_ratio": map[string]any{"type": "number", "minimum": 1, "maximum": 10, "description": "Manual page range 1-10, step 0.5."},
"min_confidence": map[string]any{"type": "number", "minimum": 50, "maximum": 100, "description": "Manual page range 50-100."},
},
},
"prompt_sections": map[string]any{
"type": "object",
"properties": map[string]any{
"role_definition": map[string]any{"type": "string"},
"trading_frequency": map[string]any{"type": "string"},
"entry_standards": map[string]any{"type": "string"},
"decision_process": map[string]any{"type": "string"},
},
},
"enable_raw_klines": map[string]any{"type": "boolean"},
"enable_ema": map[string]any{"type": "boolean"},
"enable_macd": map[string]any{"type": "boolean"},
"enable_rsi": map[string]any{"type": "boolean"},
"enable_atr": map[string]any{"type": "boolean"},
"enable_boll": map[string]any{"type": "boolean"},
"enable_volume": map[string]any{"type": "boolean"},
"enable_oi": map[string]any{"type": "boolean"},
"enable_funding_rate": map[string]any{"type": "boolean"},
"ema_periods": intArraySchema("EMA periods such as [20,50]."),
"rsi_periods": intArraySchema("RSI periods such as [7,14]."),
"atr_periods": intArraySchema("ATR periods such as [14]."),
"boll_periods": intArraySchema("BOLL periods such as [20]."),
"nofxos_api_key": map[string]any{"type": "string"},
"enable_quant_data": map[string]any{"type": "boolean"},
"enable_quant_oi": map[string]any{"type": "boolean"},
"enable_quant_netflow": map[string]any{"type": "boolean"},
"enable_oi_ranking": map[string]any{"type": "boolean"},
"oi_ranking_duration": map[string]any{"type": "string", "enum": []string{"1h", "4h", "24h"}},
"oi_ranking_limit": map[string]any{"type": "number", "enum": []int{5, 10, 15, 20}},
"enable_netflow_ranking": map[string]any{"type": "boolean"},
"netflow_ranking_duration": map[string]any{"type": "string", "enum": []string{"1h", "4h", "24h"}},
"netflow_ranking_limit": map[string]any{"type": "number", "enum": []int{5, 10, 15, 20}},
"enable_price_ranking": map[string]any{"type": "boolean"},
"price_ranking_duration": map[string]any{"type": "string", "enum": []string{"1h", "4h", "24h", "1h,4h,24h"}},
"price_ranking_limit": map[string]any{"type": "number", "enum": []int{5, 10, 15, 20}},
},
},
"custom_prompt": map[string]any{"type": "string"},
"risk_control": map[string]any{
"type": "object",
"properties": map[string]any{
"max_positions": map[string]any{"type": "number", "description": "Displayed as System enforced on the manual strategy page; do not change unless the user explicitly asks for advanced configuration."},
"btc_eth_max_leverage": map[string]any{"type": "number", "minimum": 1, "maximum": 20},
"altcoin_max_leverage": map[string]any{"type": "number", "minimum": 1, "maximum": 20},
"btc_eth_max_position_value_ratio": map[string]any{"type": "number", "description": "Displayed as System enforced on the manual strategy page; do not change unless explicitly requested."},
"altcoin_max_position_value_ratio": map[string]any{"type": "number", "description": "Displayed as System enforced on the manual strategy page; do not change unless explicitly requested."},
"max_margin_usage": map[string]any{"type": "number", "description": "Displayed as System enforced on the manual strategy page; do not change unless explicitly requested."},
"min_risk_reward_ratio": map[string]any{"type": "number", "minimum": 1, "maximum": 10, "description": "Manual page range 1-10, step 0.5."},
"min_confidence": map[string]any{"type": "number", "minimum": 50, "maximum": 100, "description": "Manual page range 50-100."},
},
},
"prompt_sections": map[string]any{
"type": "object",
"properties": map[string]any{
"role_definition": map[string]any{"type": "string"},
"trading_frequency": map[string]any{"type": "string"},
"entry_standards": map[string]any{"type": "string"},
"decision_process": map[string]any{"type": "string"},
},
},
"grid_config": map[string]any{
"type": "object",
"description": "Grid trading only. Do not include this for ai_trading.",
"type": "object",
"properties": map[string]any{
"symbol": map[string]any{"type": "string", "enum": []string{"BTCUSDT", "ETHUSDT", "SOLUSDT", "BNBUSDT", "XRPUSDT", "DOGEUSDT"}, "description": "Manual page dropdown options for grid trading symbols."},
"grid_count": map[string]any{"type": "number", "minimum": 5, "maximum": 50, "description": "Manual page range 5-50."},
@@ -375,6 +382,14 @@ func strategyConfigSchema() map[string]any {
"direction_bias_ratio": map[string]any{"type": "number", "minimum": 0.55, "maximum": 0.9, "description": "Manual page range 0.55-0.90 (shown as 55%-90%)."},
},
},
"publish_config": map[string]any{
"type": "object",
"description": "Shared publish settings for both AI and grid strategies.",
"properties": map[string]any{
"is_public": map[string]any{"type": "boolean"},
"config_visible": map[string]any{"type": "boolean"},
},
},
},
}
}