Skip to content

Commit 7b690f2

Browse files
author
dministrator
committed
feat: add custom module with loader, crypto, MiniMax patch, ensemble reports, bot extensions
1 parent 9c2ad66 commit 7b690f2

23 files changed

Lines changed: 648 additions & 431 deletions

.env.example

Lines changed: 0 additions & 121 deletions
Original file line numberDiff line numberDiff line change
@@ -783,15 +783,6 @@ ADMIN_AUTH_ENABLED=false
783783
# YFINANCE_PRIORITY=0
784784
# EFINANCE_PRIORITY=99
785785

786-
# ===========================================
787-
# Crypto Data Source (CCXT)
788-
# ===========================================
789-
# CCXTCryptoFetcher 仅在分析加密货币标的(如 BTC-USD、ETH-USD)时启用。
790-
# 需要 `pip install ccxt`;未安装时该数据源自动跳过,不影响现有股票分析。
791-
# 默认优先级为 0,crypto 代码首选 CCXT 直连交易所,失败时回退 YFinance。
792-
# CCXT_EXCHANGE=kraken # CCXT 交易所 ID(支持 100+ 交易所,见 https://github.com/ccxt/ccxt)
793-
# CCXT_PRIORITY=0 # CCXTCryptoFetcher 优先级,默认 0
794-
795786
# ===========================================
796787
# 实时行情数据源优先级配置
797788
# ===========================================
@@ -840,115 +831,3 @@ ADMIN_AUTH_ENABLED=false
840831
# 东财接口补丁:东财/Efinance/Akshare 东方财富接口频繁失败(RemoteDisconnected、连接被关闭)时建议开启
841832
# 开启后会注入 NID 令牌与随机 User-Agent,降低被东财限流概率
842833
# ENABLE_EASTMONEY_PATCH=false
843-
844-
# 专家战绩数据库路径(默认:workspace/analyst_performance.db,只读容器可指向 /tmp 等可写路径)
845-
# ANALYST_PERF_DB=workspace/analyst_performance.db
846-
847-
# ===========================================
848-
# TQQQ 自动交易机器人配置(可选)
849-
# ===========================================
850-
# 以下环境变量可覆盖 config/trading.yaml 中的同名配置
851-
# 详细配置请参考 config/trading.yaml.example
852-
#
853-
# Tiger Brokers 环境:PAPER(模拟盘)/ LIVE(实盘)
854-
# TRADING_TIGER_ENV=PAPER
855-
# Tiger OpenAPI 配置文件路径
856-
# TRADING_TIGER_CONFIG_PATH=tiger_openapi_config.properties
857-
#
858-
# 交易标的
859-
# TRADING_SYMBOL=TQQQ
860-
# 是否开启自动交易(false = 仅发送通知不下单)
861-
# TRADING_AUTO_TRADE=false
862-
# 交易模式(SANDBOX/PAPER/PROD)
863-
# TRADING_MODE=SANDBOX
864-
# 是否启用交易模块
865-
# ENABLE_TRADING=false
866-
# 是否启用 MCP Server(Model Context Protocol)
867-
# ENABLE_MCP_SERVER=false
868-
869-
# 决策信号桥接轮询间隔(秒)
870-
# BRIDGE_POLL_INTERVAL_SEC=300
871-
872-
# 买入触发价
873-
# TRADING_ENTRY_PRICE=74.61
874-
# 买入数量(股)
875-
# TRADING_ENTRY_QTY=35
876-
# 止盈百分比(0.04 = 4%)
877-
# TRADING_TP_PCT=0.04
878-
# 止损百分比(0.032 = 3.2%)
879-
# TRADING_SL_PCT=0.032
880-
#
881-
# 交易通知 Webhook URL(飞书/钉钉/企业微信)
882-
# TRADING_WEBHOOK_URL=
883-
# Webhook 签名密钥(可选)
884-
# TRADING_WEBHOOK_SECRET=
885-
# 日志级别
886-
# TRADING_LOG_LEVEL=INFO
887-
888-
# ===================================
889-
# QuantWeasel - AI 量化交易系统配置
890-
# ===================================
891-
# 复制此部分到 .env 并填入真实配置
892-
# !!!禁止将 .env 提交到 git !!!
893-
894-
# ── Tiger Brokers OpenAPI 凭据 ──────────────────────────────
895-
# 从 tiger_openapi_config.properties 迁移而来
896-
TIGER_PRIVATE_KEY=
897-
# RSA 私钥内容(PKCS#1 格式,对应 private_key_pk1 字段)
898-
# 注意:如果包含多行,请用引号包裹并用 \n 替换换行符
899-
900-
TIGER_TIGER_ID=
901-
# 老虎证券开发者 ID
902-
903-
TIGER_ACCOUNT=
904-
# 交易账户号
905-
906-
TIGER_TOKEN=
907-
# API Token(base64 编码的认证字符串)
908-
909-
TIGER_LICENSE=
910-
# License
911-
912-
TIGER_ENV=SANDBOX
913-
# 环境: SANDBOX(模拟盘)/ PROD(实盘)
914-
# Phase 1 强制使用 SANDBOX
915-
916-
# ── 交易策略默认参数 ────────────────────────────────────────
917-
TRADING_SYMBOL=TQQQ
918-
# 默认交易标的
919-
920-
TRADING_AUTO_TRADE=false
921-
# 是否自动交易(Phase 1 始终为 false)
922-
923-
# ── 飞书通知 ────────────────────────────────────────────────
924-
LARK_WEBHOOK_URL=
925-
# 飞书机器人 Webhook URL
926-
927-
LARK_WEBHOOK_SECRET=
928-
# 飞书 Webhook 签名密钥
929-
930-
LARK_APP_ID=
931-
# 飞书应用 ID(Stream Bot 模式)
932-
933-
LARK_APP_SECRET=
934-
# 飞书应用 Secret(Stream Bot 模式)
935-
936-
LARK_DEFAULT_CHAT_ID=
937-
# 飞书 Stream Bot 默认推送会话 ID(未指定 chat_id 时使用)
938-
939-
# ── 风控参数 ────────────────────────────────────────────────
940-
RISK_MAX_POSITION_PCT=5.0
941-
# 单标的最大仓位占比(%)
942-
943-
RISK_MAX_DAILY_LOSS_PCT=8.0
944-
# 每日最大亏损占比(%)
945-
946-
RISK_SIGNAL_TTL_MINUTES=30
947-
# 信号有效期(分钟),过期自动失效
948-
949-
# ── 运行模式 ────────────────────────────────────────────────
950-
QUANT_DRY_RUN=true
951-
# 是否为 dry-run 模式(不下真实订单)
952-
953-
LOG_LEVEL=INFO
954-
# 日志级别: DEBUG / INFO / WARNING / ERROR

api/v1/endpoints/agent.py

Lines changed: 0 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -92,18 +92,6 @@ class AgentModelsResponse(BaseModel):
9292
models: List[AgentModelDeployment]
9393

9494

95-
class ExpertPerformanceItem(BaseModel):
96-
id: str
97-
name: str
98-
total_predictions: int
99-
win_rate: float
100-
win_count: int
101-
settled_count: int
102-
103-
class ExpertPerformanceResponse(BaseModel):
104-
performance: List[ExpertPerformanceItem]
105-
106-
10795
@router.get("/models", response_model=AgentModelsResponse)
10896
async def get_agent_models():
10997
"""Get configured Agent model deployments for frontend selection."""
@@ -113,17 +101,6 @@ async def get_agent_models():
113101
)
114102

115103

116-
@router.get("/experts/performance", response_model=ExpertPerformanceResponse)
117-
async def get_expert_performance():
118-
"""
119-
获取专家(大师)的战绩统计和胜率榜单。
120-
"""
121-
from src.services.performance_tracker import PerformanceTracker
122-
tracker = PerformanceTracker()
123-
performance = tracker.get_analyst_performance()
124-
return ExpertPerformanceResponse(performance=performance)
125-
126-
127104
def _build_skills_response(config) -> SkillsResponse:
128105
from src.agent.factory import get_skill_manager
129106
from src.agent.skills.defaults import get_primary_default_skill_id

api/v1/endpoints/history.py

Lines changed: 0 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -464,28 +464,6 @@ def get_history_detail(
464464
fallback_fundamental_payload=fallback_fundamental,
465465
)
466466

467-
raw_result_dict = result.get("raw_result")
468-
ensemble_reports = None
469-
radar_data = None
470-
if isinstance(raw_result_dict, dict):
471-
dashboard = raw_result_dict.get("dashboard") or {}
472-
ensemble_reports = dashboard.get("ensemble_reports") or None
473-
try:
474-
from src.analyzer import AnalysisResult
475-
_partial = AnalysisResult(
476-
code=result.get("stock_code", ""),
477-
name=result.get("stock_name", ""),
478-
sentiment_score=int(raw_result_dict.get("sentiment_score") or 50),
479-
trend_prediction=raw_result_dict.get("trend_prediction", ""),
480-
operation_advice=raw_result_dict.get("operation_advice", ""),
481-
dashboard=raw_result_dict.get("dashboard"),
482-
risk_warning=raw_result_dict.get("risk_warning", ""),
483-
fundamental_analysis=raw_result_dict.get("fundamental_analysis", ""),
484-
)
485-
radar_data = _partial.get_radar_data()
486-
except Exception:
487-
pass
488-
489467
details = ReportDetails(
490468
news_content=result.get("news_content"),
491469
raw_result=result.get("raw_result"),
@@ -495,8 +473,6 @@ def get_history_detail(
495473
dividend_metrics=extracted_fundamental.get("dividend_metrics"),
496474
belong_boards=extracted_boards.get("belong_boards"),
497475
sector_rankings=extracted_boards.get("sector_rankings"),
498-
ensemble_reports=ensemble_reports,
499-
radar_data=radar_data,
500476
)
501477

502478
return AnalysisReport(

api/v1/router.py

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@
2424
portfolio,
2525
stocks,
2626
system_config,
27-
trading,
2827
usage,
2928
)
3029

@@ -108,9 +107,3 @@
108107
health.router,
109108
tags=["Health"]
110109
)
111-
112-
router.include_router(
113-
trading.router,
114-
prefix="/trading",
115-
tags=["Trading"]
116-
)

bot/__init__.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -12,7 +12,6 @@
1212
- dispatcher.py: 命令分发器
1313
- commands/: 命令处理器
1414
- platforms/: 平台适配器
15-
- lark_interactive.py: 飞书互动卡片 Bot(Stream 模式骨架)
1615
- handler.py: Webhook 处理器
1716
1817
使用方式:
@@ -30,10 +29,6 @@
3029
- /batch - 批量分析自选股
3130
- /help - 显示帮助
3231
- /status - 系统状态
33-
34-
飞书互动卡片(platforms/lark_interactive.py):
35-
- LarkCardBuilder: 构建信号确认、执行结果、风控拦截、信号过期卡片
36-
- LarkInteractiveBot: Stream 模式骨架,支持确认/拒绝回调注册
3732
"""
3833

3934
from bot.models import BotMessage, BotResponse, ChatType, WebhookResponse

bot/models.py

Lines changed: 0 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -85,11 +85,6 @@ def get_command_and_args(self, prefix: str = "/") -> tuple:
8585
'批量': 'batch',
8686
'帮助': 'help',
8787
'状态': 'status',
88-
'自选股': 'watchlist',
89-
'股票列表': 'watchlist',
90-
'我的自选': 'watchlist',
91-
'添加': 'watchlist',
92-
'删除': 'watchlist',
9388
}
9489
for cn_cmd, en_cmd in chinese_commands.items():
9590
if text.startswith(cn_cmd):

bot/platforms/__init__.py

Lines changed: 0 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -53,16 +53,6 @@
5353
get_feishu_stream_client = lambda: None
5454
start_feishu_stream_background = lambda: False
5555

56-
# 飞书互动卡片 Bot(无额外依赖,始终可用)
57-
from bot.platforms.lark_interactive import (
58-
LarkCardBuilder,
59-
LarkInteractiveBot,
60-
CARD_SIGNAL_CONFIRM,
61-
CARD_EXECUTION_RESULT,
62-
CARD_RISK_INTERCEPT,
63-
CARD_SIGNAL_EXPIRED,
64-
)
65-
6656
__all__ = [
6757
'BotPlatform',
6858
'DingtalkPlatform',
@@ -80,11 +70,4 @@
8070
'get_feishu_stream_client',
8171
'start_feishu_stream_background',
8272
'FEISHU_SDK_AVAILABLE',
83-
# 飞书互动卡片
84-
'LarkCardBuilder',
85-
'LarkInteractiveBot',
86-
'CARD_SIGNAL_CONFIRM',
87-
'CARD_EXECUTION_RESULT',
88-
'CARD_RISK_INTERCEPT',
89-
'CARD_SIGNAL_EXPIRED',
9073
]

0 commit comments

Comments
 (0)