How zhangks93/quanpass-rs works
Main Components
• Entry Point: The main.rs serves as the application’s entry point.
• Clients & External APIs: The src/client directory (binance_client.rs, binance_domain.rs, db_client.rs) indicates connections to exchange APIs and possibly a database interface.
• Crypto and Market Interfaces: Under src/crypto and src/market you have modules that handle communication with cryptocurrency and stock markets, as well as futures and RSS feeds.
• Notification System: The src/notify module provides different clients (mail_client, wechat_client) for alerting users.
• Trading Robot and Routing: The src/robot (which hosts the trading logic in robot.rs) and src/router modules, which likely manage internal routing of commands or requests between components.
• Trading Strategies: The src/strategy folder contains implementations for various trading strategies (like grid_strategy and future_grid_strategy) that dictate how market data is translated into trade actions.
• Utility Functions: The src/util directory covers common tasks (error handling, JSON operations, time and number utilities) that support the rest of the system.
Relationships and Interactions
• The main application (main.rs) should be illustrated as coordinating the initialization of all modules.
• From the Client layer to Market/Crypto modules (e.g., binance_client interacting with binance_domain).
• From Market and Crypto modules to the Strategy module, which processes incoming market data.
• From the Strategy module to the Robot module that executes trading decisions.
• From the Robot module to the Notify module to send alerts via email or WeChat.
• Lines from the Utility module to all other modules, indicating shared, low-level functionality.
Architectural Patterns and Principles
• Separation of Concerns: Each module (client, market, crypto, notify, robot, strategy, router) has a clear responsibility.
• Modularity: Distinct modules allow you to swap out, modify, or extend capabilities (for example, adding a new notification channel or market client).
• Dependency Injection: Although not explicitly stated, the structure indicates that primary modules are designed to be loosely coupled (e.g., the robot uses strategies and clients without hard-wired implementations).
Relevant Technologies
• Rust and Cargo: Indicated by the Cargo.toml and the Rust file structure.
• External APIs: Binance API, potential stock and cryptocurrency feeds.
• Notification Frameworks: Mail and WeChat integrations.
• Trading Algorithms: Implemented as grid-based strategies.
• Python Script: The existence of src/ticket.py suggests there might be some auxiliary tooling or integration scripts in Python.