Skip to content

Feat/crypto#20

Merged
MayueCif merged 44 commits into
mainfrom
feat/crypto
Jun 25, 2026
Merged

Feat/crypto#20
MayueCif merged 44 commits into
mainfrom
feat/crypto

Conversation

@MayueCif

Copy link
Copy Markdown
Member

多市场支持,支持虚拟币市场

- Updated .gitignore to include .idea directory for IDE configurations.
- Added a new refactoring progress report for multi-market support.
- Integrated SkeletonStyles into App.axaml for improved UI consistency.
- Updated project dependencies, including WebViewControl-Avalonia to version 3.120.11.
- Refactored various analyst agents to use new data tools interfaces, enhancing modularity.
- Introduced new investment selection executors and models for crypto and stock analysis.
- Removed obsolete stock selection components to streamline the codebase.
- Enhanced navigation and view models to support asset-focused features.
- Updated UI elements across multiple views to reflect asset terminology and improve user experience.
…a handling

- Renamed 'Stocks' to 'Symbols' in AShareTelegramService and CryptoTelegramService for consistency.
- Improved error handling and logging in CryptoTelegramService, including detailed warnings for empty API responses.
- Updated data extraction logic to handle new API response structure in CryptoTelegramService.
- Adjusted the Telegram model to reflect the change from 'Stocks' to 'Symbols' for better clarity.
- Enhanced UI binding in HomePageView to align with updated model properties.
…ty and functionality

- Introduced new documentation files for BinanceAuthIntegration and ReAct, providing comprehensive guides for integration and usage.
- Refactored financial tools interfaces to improve naming consistency, changing IFinancialDataTools to IFinancialTools and IShareFinancialTools for better clarity.
- Added new abstractions for crypto tools, including ICryptoBasicTools, ICryptoMetricsTools, and ICryptoSentimentTools, to support expanded functionality.
- Updated various models and services to align with the new abstractions, enhancing modularity and maintainability.
- Removed obsolete sentiment data tools to streamline the codebase.
引入策略接口 ICriteriaGenerationStrategy 和 IAssetDataFormatter 替代硬编码的市场特定逻辑
删除旧的 GenerateStockCriteriaExecutor 和 GenerateCryptoCriteriaExecutor 等实现
添加 StockCriteriaGenerationStrategy 和 CryptoCriteriaGenerationStrategy 实现
新增 StockDataFormatter 和 CryptoDataFormatter 处理市场特定数据格式化
更新 ServiceCollectionExtensions 注册新的策略服务
移除 REFACTORING_PROGRESS.md 文件
本次提交主要内容如下:

- 依赖包升级:包括 Avalonia、Microsoft.Agents.AI、DocumentFormat.OpenXml、SmartReader、Svg.Skia、ModelContextProtocol、Microsoft.SemanticKernel 等,提升兼容性和功能性。
- Keyed Service 注册与获取方式统一:由字符串 Key 改为使用 MarketType 枚举,涉及 ITelegramService、INewsUpdateService、IAssetScreenerService、IAssetDataFormatter 等,提升类型安全性和可维护性。
- 适配 Microsoft.Agents.AI 新版 API,将 AnalystAgentBase 的 RunAsync 重命名为 RunCoreAsync。
- 优化 using 语句和命名空间,清理无用引用。
- 相关业务逻辑和 ViewModel 获取服务方式同步调整,保证一致性和简洁性。
- 新增 Binance/CoinGecko/CoinDesk 服务层,所有加密货币行情、K线、深度、新闻等数据统一通过服务获取,移除各工具类直连API和手动解析逻辑
- 工具层(CryptoBasicTools/MetricsTools 等)全部依赖服务层,异常统一抛出 FriendlyException,便于前端友好提示
- K线周期参数统一为 MarketInterval 枚举,提升类型安全
- 虚拟币资产与筛选服务重构,支持多条件本地筛选,CoinGecko API 适配,补充完整单元测试
- A股服务优化,HttpClientFactory 注入,股票代码格式转换工具增强
- HotAsset 模型与首页热门资产卡片字段统一,指标显示更直观
- 投资策略文案优化,区分高股息/高波动币
- 文档与测试同步更新,依赖注入注册完善
- 显著提升多市场资产服务的可维护性、扩展性和健壮性
- Updated AGENTS.md to include core technology stack and multi-market architecture details, supporting both A-share and cryptocurrency markets.
- Refactored asset screening services to unify asset info models, transitioning from ScreenerStockInfo to ScreenerAssetInfo for better abstraction.
- Introduced new models for cryptocurrency screening, including ScreenerCryptoInfo, and updated related services to accommodate these changes.
- Improved error handling in crypto tools, replacing exceptions with FriendlyException for better user feedback.
- Updated various data formatting strategies to align with new asset models, enhancing modularity and maintainability.
- Removed obsolete models and streamlined the codebase for improved clarity and functionality.
…management

- Updated Microsoft.Agents.AI and Microsoft.Agents.AI.Workflows package versions to 1.0.0-rc2.
- Refactored MarketChatSession to replace AgentThread with AgentSession for improved session management.
- Simplified GetConversationHistoryAsync method to utilize InMemoryChatHistoryProvider.
- Adjusted session handling in ClearHistory and other methods to ensure proper session lifecycle management.
- Updated various comments and logging for clarity and consistency.
- Introduced a new trading module for cryptocurrency, including core components like MarketMonitor, TradingAgent, and StrategyEngine.
- Implemented ITradingExecutionTools and IStrategyTools interfaces for better abstraction and modularity in trading operations.
- Enhanced MarketChatSession to support analysis context injection and improved session management.
- Updated AGENTS.md to include guidelines for agent and tool coding conventions.
- Refactored existing services to integrate with the new trading module, ensuring seamless operation and improved error handling.
- Added comprehensive documentation for the new trading features and updated existing documentation for clarity.
- Updated CryptoTradingExecutionTools to delegate order execution to TradeExecutor, streamlining the trading process.
- Improved MarketMonitor to utilize a Channel for price updates, ensuring no tick is dropped and enhancing performance.
- Enhanced RiskManager to calculate total asset value in USDT asynchronously, improving accuracy in risk assessments.
- Introduced a new method in TradingDataService to compute the average entry price for better PnL estimation.
- Updated various models and services to support new features and improve overall code clarity and maintainability.
- Updated AGENTS.md to reflect the new project structure and multi-market capabilities, including A-share and cryptocurrency markets.
- Introduced independent AGENTS.md files for each subproject, emphasizing localized documentation.
- Restructured the solution file to include separate projects for core, agents, trading, and data providers, enhancing modularity.
- Removed obsolete documentation files and streamlined the content for clarity and relevance.
- Enhanced the overall organization of the project to support future scalability and maintainability.
…y and functionality

- Updated AGENTS.md to include guidelines for avoiding redundant implementations and prioritizing the reuse of existing abstractions and libraries.
- Enhanced README.md with details on the unified trading execution chain via `IExchangeClient` for Binance spot trading.
- Refactored trading module design to emphasize the use of `IExchangeClient`, reducing direct dependencies on Binance services.
- Improved modularization in the trading module, consolidating various components and enhancing the overall architecture for better maintainability.
- Updated TODO.md to reflect ongoing tasks and improvements in agent and prompt management, MCP tool constraints, and multi-agent collaboration strategies.
- Refined technical indicators implementation in CryptoTechnicalTools, leveraging Skender.Stock.Indicators for enhanced calculations.
- Streamlined GitHubReleaseService to utilize memory caching for version information, improving performance and reducing API calls.
- Added FavoriteServiceBase to manage favorite assets with local storage and market data retrieval.
- Introduced AssetHistoryServiceBase for handling asset history with capacity control.
- Refactored CryptoHistoryService to inherit from AssetHistoryServiceBase, simplifying history management.
- Created HomeAssetServiceBase to encapsulate common functionalities for asset services, including favorites and history.
- Updated various services and view models to use assetSymbol instead of stockSymbol for consistency.
- Enhanced logging messages to reflect the change from stock to asset terminology.
- Modified tests to align with the new assetSymbol naming convention.
- Introduced a new market analysis report template (ANALYSIS_TEMPLATE.md) for structured reporting.
- Added scoring standards for various analysis dimensions (SCORING_STANDARDS.md) to standardize evaluation criteria.
- Implemented technical analysis guidelines (SKILL.md) covering core principles, common candlestick patterns, and indicator usage.
- Created detailed indicator usage guide (INDICATOR_GUIDE.md) for MACD, RSI, KDJ, Bollinger Bands, and moving averages.
- Developed Binance API response models for funding rates, long/short ratios, open interest, and premium index.
- Refactored CoinDesk API service and response models for metadata and news articles.
- Added CoinGecko API response models for search results and tickers.
- Established trading models including strategies, trade records, risk configurations, and daily statistics.
- Updated tests to reflect changes in data models and services.
…ith query rewriting, vector search, deduplication, and reranking

feat: Add Text Chunking Service for semantic text chunking with token limits and overlap handling

feat: Introduce Text Cleaning Service for comprehensive text sanitization with multiple cleaning rules

feat: Create TextParagraph model for structured text data storage and retrieval with vector embeddings
本次提交升级了各项目主要依赖包(如 Avalonia、CommunityToolkit.Mvvm、Svg.Skia、Markdig、DocumentFormat.OpenXml、Microsoft.Data.Sqlite、Microsoft.Extensions.*、Microsoft.SemanticKernel.*、ModelContextProtocol、Microsoft.ML.OnnxRuntime、SkiaSharp 等),并将 Avalonia 相关包升级至 12.0.0-preview2。同时,移除了 App.axaml.cs 中 DEBUG 下的 AttachDeveloperTools 调用,并简化了全局异常处理器的初始化命名空间。
更新所有分析员代理类,将FileAgentSkillsProvider参数替换为更通用的AgentSkillsProvider。同时升级Microsoft.Agents.AI相关包到1.0.0-rc5版本,并移除Avalonia数据注解验证的冗余代码。
将项目中所有 Microsoft.Agents.AI 相关依赖从 rc5 版本升级到稳定版 1.0.0,包括核心库、工作流和工作流生成器
…ion and update PnL calculations

feat(trading): add GetAverageSellPriceAsync method to TradingDataService for short position PnL estimation

fix(app): improve global exception handling by injecting required services directly

feat(viewmodels): implement session history management in ChatSidebarViewModel

feat(viewmodels): add DCA and Grid Trading parameters to StrategyConfigViewModel

feat(viewmodels): integrate TradeExecutor into TradeMonitorViewModel for confirmation handling

feat(rag): introduce RagConstants for shared constants across RAG module

refactor(rag): update embedding services to use RagConstants for embedding dimensions

test: update MarketChatSessionTest to reflect changes in constructor parameters
…h Tools

- Add KnowledgeGraphTools for managing entity relationships in a knowledge graph.
- Introduce MemoryManagementTools for saving, querying, and deleting user memories.
- Create SessionSearchTools for searching historical chat sessions using FTS5.
- Enhance ChatSessionPersistenceService to support FTS5 indexing for chat messages.
- Implement MemoryExtractionService to automatically extract and save structured memories from chat history.
- Update UserMemoryService to manage memory entries with limits on count and character length.
- Modify ServiceCollectionExtensions to register new services.
- Update ChatSidebarViewModel and its demo counterpart to integrate new tools and services.
- ChatClientFactory 缓存逻辑修复(死代码分支 + 失败后缓存不一致)
- ChatSidebarView 事件订阅泄漏修复(正确管理 CollectionChanged 生命周期)
- 引入 IMarketChatSessionFactory 通过 DI 管理 MarketChatSession 创建
- AdaptiveCardView 硬编码颜色改为 DynamicResource 适配暗色主题
- 测试 HttpClient 注册改为复用生产代码,消除重复配置
- ViewLocator 移除反射死代码,简化为 switch 表达式
- 侧边栏布局改为可拖拽 GridSplitter + Min/MaxWidth

Made-with: Cursor
- Updated Microsoft.Extensions.Logging.Abstractions package reference to remove version specification.
- Added .lscache files for project and test projects to improve performance in C# Dev Kit.
- Modified AnalystAgentFactoryTest to enhance error handling by excluding AssertFailedException from catch blocks.
- Changed test HTTP client service collection extension to use named market HTTP clients.
- Removed specific versioning for test project dependencies (Microsoft.NET.Test.Sdk, Moq, MSTest) for flexibility.
升级多项依赖包以提升兼容性和功能。对 Microsoft.Agents.AI.Workflows.Generators 包增加 PrivateAssets 和 IncludeAssets 配置,优化包传播范围。微调 csproj 文件格式和注释,无功能影响。
- 将 Microsoft.Agents.AI 及相关工作流包版本升级至 1.10.0,增加 MAF Evaluation 相关包。
- 新增设计原型和设计系统文档,提供 UI 设计指导。
- 添加表单样式和按钮样式,优化用户界面元素的视觉一致性。
- 更新应用程序样式以包含新样式文件,提升整体用户体验。
MayueCif and others added 14 commits June 17, 2026 13:18
- 统一将 Microsoft.Extensions.AI 系列库版本更新至 10.7.0
- 更新 Microsoft.Extensions.Caching.Memory/Http 等到 10.0.9 版本
- 升级数据库与文档处理库,如 Microsoft.Data.Sqlite、Markdig
- 提升 Semantic Kernel 和模型协议包版本
- 更新 UI 相关库如 Avalonia、Markdown.Avalonia、Svg.Skia 等至最新版本
- 细化测试依赖库版本,保证测试环境一致

refactor(agents): 优化 TokenTrackingMiddleware 以支持精确 Token 用量

- 从响应优先提取 LLM 提供的精确 Token 计数
- 流式调用增加对精确使用量的跟踪和日志记录
- 增强日志输出,区分估算值与提供商精确值

refactor(agents): 移除 ConversationCompressor,转为中间件方式压缩

- 完全移除 ConversationCompressor 类文件及相关调用
- 压缩会话历史逻辑由 MarketAssistant.App.Services 的 ConversationCompressionMiddleware 处理

fix(agents): 修正 MarketChatSession 流式回复处理及自动持久化逻辑

- 修复流式异步枚举处理,确保完整回复缓存至会话历史
- 处理中断回复时添加“回复被中断”标记
- 优化取消令牌生命周期管理

refactor(app): 优化 ChatSidebarViewModel 适配可选持久化支持

- ChatSessionPersistenceService 参数改为可空
- 根据持久化服务存在与否决定是否加载会话历史
- 更新相关测试示例兼容改动

refactor(app): 调整 Trading 相关依赖注入标记以支持多市场类型

- 在 TradeMonitorViewModel 构造函数中为 IExchangeClient 添加特性指定 Crypto 类型

style(app): 统一 AdaptiveCard 组件 UI 样式及资源引用

- 主题颜色改为使用项目内实际资源,替代系统默认画刷
- 统一容器内边距及圆角样式,增强排版一致性
- 优化 FactSet 布局与标题样式,调整间距与字体权重
- 修改文本颜色统一采用项目颜色资源

feat(app): 新增 AdaptiveCard 解析器通用策略和风险提示组件

- 添加 AddStrategyBox 用于策略和操作建议展示
- 添加 AddRiskBox 统一风险提示容器样式与内容布局
- 新增 AddFactSection 保障各种报告中 FactSet 展示一致性

fix(agents): TradingFunctionGuardMiddleware 优化传参记录与删减无用代码

- 改为序列化实际调用参数,便于审计追踪
- 移除无用的调用计数重置方法和额外空行

refactor(appservices): InvestmentSelection 与 MarketAnalysis 工作流执行改进

- 取消检查点传递,改为 null 以避免不必要状态管理
- 精简工作流事件日志,移除冗余检查点保存代码
- 优化进度百分比计算逻辑,更贴合实际分析状态

fix(appservices): CoordinatorExecutor 增强 JSON 解析错误日志与异常处理

- 包装 JsonSerializer 解析增加异常捕获并记录错误预览
- 抛出更具描述性的异常,便于定位结构化数据解析问题

refactor(agents): AShare 财务与技术工具支持字符串转 decimal 自动转换

- 利用自定义 JsonSerializerOptions 增加 StringToDecimalConverter
- 确保接口返回字符串数字能正确反序列化为 decimal 类型
- 统一异常处理和返回数据有效性校验

style(appservices): 清理多余 using 指令提升代码整洁度

- 移除未使用的 MarketAssistant.Infrastructure.Core namespace 引用

fix(app): 修正配置文件 models.yaml 支持最新 deepseek-ai 模型版本

- 移除旧模型配置,替换为 DeepSeek-V4-Flash 最新版本
- RiskManager: 风控校验通过后写入账户快照,修复回撤熔断因无快照数据而失效的问题
- MarketMonitor: 移除剩余交易次数硬编码 15,改读 RiskConfig.MaxDailyTrades
- CryptoPortfolioService: 改用 GetOpenPositionAvgEntryPriceAsync 按 FIFO 未平仓计算均价,修复浮盈被已平仓记录污染
- StrategyEngine: EvaluateDCA 改为异步并在低价加倍后立即持久化 CustomParams,修复重启后加倍上限失效
- BinanceExchangeClient: 解析订单响应 fills 数组汇总手续费,对齐币安 POST /api/v3/order 结构
- TradeExecutor: 修正确认回调参数顺序、补全 60s 超时与重试策略
- 扩展 ExchangeOrderResult/TradingModels 支持手续费、FIFO 持仓、追踪止损峰值持久化

详见 docs/trade-monitor-fix-plan.md
- 顶部汇总栏:总资产/今日盈亏(带涨跌色)/手续费/监控控制,盈亏色复用 PriceChangeColorConverter
- 双栏布局:左栏风控指标+当前持仓,右栏活跃策略+未完成订单
- 风控进度条绑定 RiskConfig 阈值,等宽数字字体对齐
- 底部账户余额紧凑列表
- 交易确认改为模态遮罩对话框(Grid+ZIndex+DarkOverlayBrush),结构化展示交易对/方向/价格/数量/理由
- ViewModel 新增 TodayPnlPercent/IsDailyLossHigh/IsPositionHigh 等派生属性支撑 UI 展示
- AShareBasicTools.GetAssetInfoAsync: 用 ClsStockQuoteData 模型 + StringToDecimalConverter 替代 30 处裸 GetDecimal(),消除字符串/null/--占位导致的转换异常
- AShareBasicTools.GetCompanyInfoAsync: 挂载 ClsJsonOptions 统一规范
- CoinDeskApiService/CoinGeckoApiService: 为含 decimal? 字段的反序列化挂载 StringToDecimalConverter,避免偶发字符串数值崩溃
- TextBox/AutoCompleteBox.Watermark -> PlaceholderText (35 处)
- Window.SystemDecorations -> WindowDecorations (1 处)
- 警告数 90 -> 16 (剩余均为 NU1507 包源映射提示,与代码无关)
避免误生成时 git status 反复列出不存在的文件
- 新增基于 YAML 的独立分析师提示词配置文件支持,支持按分析师单独加载与热重载
- 替换原统一 analysts.yaml 配置,避免合并文件带来的加载和管理复杂度
- AnalystAgentBase 添加基于 AnalystPromptConfig 的构造函数,简化代理实例化过程
- 统一各分析师代理构造函数,改用 AnalystPromptLoader 加载配置,简化硬编码指令文本
- 细化异常处理与日志记录,提升配置加载可靠性和故障容忍性
- MarketAssistant.App 项目将 prompts 子目录所有 YAML 文件标记为内容资源并始终复制
- CoordinatorAnalystAgent 使用新的 PromptLoader 加载复杂协调分析师配置,替代原静态指令字符串
- 修改 FundFlow 类属性数据类型,从 float 改为 decimal 以提升资金流精度
- 修复 HomePageView 中资产选择事件处理控件类型错误,改由 Control 处理事件以支持更广泛控件
- 删除已废弃的分析师统一 YAML 配置文件资源,改为按需加载具体分析师配置文件
统一双市场(A股/Crypto)服务抽象,重构缓存/收藏/历史/首页为通用实现,新增 IToolsProvider 统一工具注册、ResilientChatClient 重试装饰器、CryptoAliasRegistry 别名匹配,优化构建脚本与 CI 发布流程。

Co-authored-by: Cursor <cursoragent@cursor.com>
- CoordinatorExecutor 显式调用 YieldOutputAsync 修复流式路径下 WorkflowOutputEvent 丢失

- ChatClientFactory 设置 NetworkTimeout=3min 并修复重试判定逻辑

- ExecuteWorkflowAsync 追踪活跃 Executor,超时时精确报告卡住的分析师

- ErrorMessageMapper 区分 AI 模型超时与用户取消,改善弹窗提示

- TokenTrackingMiddleware 增加流式调用启动日志便于定位

- 更新构建脚本与 UI 视图调整

Co-authored-by: Cursor <cursoragent@cursor.com>
涵盖交易链路幂等性(clientOrderId)、币安错误解析、Token熔断上限(200k)、FinancialData强类型化、IDisposable补全、并发安全加锁、CLIP标准化修复、RAG批量嵌入及.gitignore敏感文件防护等系统性防御改进。

Co-authored-by: Cursor <cursoragent@cursor.com>
- 升级 AShareSentimentTools 的资金流向接口,切换至智兔 API 保证数据准确性。
- 为 A 股、加密货币、技术指标和交易模型全面补全 [Description] 属性,并彻底修复中文 XML 注释的乱码问题。

Co-authored-by: Cursor <cursoragent@cursor.com>
- 删除了MAF框架升级与架构审查指南文档
- 移除了模块化拆分方案相关文档
- 清理了交易监控页面修复计划文档
- 将价格预警规则持久化从Preferences改为SQLite数据库
- 实现异步初始化方法InitializeAsync替代同步加载
- 添加AddRuleAsync、RemoveRuleAsync、ToggleRuleAsync等异步操作方法
- 移除历史存储迁移逻辑,直接使用新的数据库结构
- 更新价格预警服务激活方式,在App启动时异步加载规则
- 删除不再使用的PreferenceKeys类和相关配置依赖
- 优化错误处理和日志记录机制
- 在工作流中添加 AgentResponseUpdateEvent 事件处理,防止误匹配
- 重构 StockDataFormatter 类,使用配置数组统一管理指标字段映射
- 优化股票筛选服务,将所有数值字段统一存储到 Indicators 字典中
- 添加对 FriendlyException 的特殊处理,避免双重包装丢失原始错误信息
- 改进雪球网 API 调用的错误处理和 Cookie 获取逻辑
- 简化 ScreenerStockInfo 模型,移除具体字段改为通用指标字典
@MayueCif
MayueCif merged commit d2699ce into main Jun 25, 2026
6 checks passed
@MayueCif
MayueCif deleted the feat/crypto branch June 25, 2026 15:15
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant