How sngyai/sequoia works
Project Type and Purpose
• This is a Python-based stock selection system that uses the AKShare API to fetch financial data (specifically from 东方财富). It implements multiple stock selection strategies that users can combine to generate investment ideas.
• The README also shows that the system can run locally or in a scheduled (server) environment, and it includes capabilities like WeChat push notifications via WxPusher. Therefore, the project is essentially an open-source tool for stock screening and strategy analysis.
File Structure
• Key top-level files:
• main.py – The main execution entry point.
• data_fetcher.py – Handles fetching market/stock data from third-party APIs.
• push.py – Implements notification logic (e.g., WxPusher integration).
• settings.py and config.yaml.example – Configuration management for parameters such as strategy end dates and push settings.
• work_flow.py – Likely orchestrates or combines the execution of one or more strategies.
• utils.py – Contains helper functions.
• The “strategy” directory: Contains various Python modules (e.g., backtrace_ma250.py, turtle_trade.py, etc.) where each file implements a different stock selection strategy. This represents the core business logic of selecting stocks based on different criteria.
• The “tests” directory: Provides unit tests for various components, ensuring the functionality is maintained.
a. Main Components:
• Entry Point Layer:
• main.py: Initializes the system.
• Configuration Layer:
• Config file (config.yaml) and settings.py: Load and manage system configurations.
• Data Layer:
• data_fetcher.py: Fetches financial data using the AKShare interface.
• Strategy Layer:
• The “strategy” directory: Houses individual strategy modules that handle various algorithmic approaches (e.g., turtle_trade, keep_increasing, etc.).
• Workflow/Orchestration Layer:
• work_flow.py: Manages the combination and ordering of different strategies.
• Notification Layer:
• push.py: Handles sending push notifications (e.g., to WeChat using WxPusher).
• Utility and Test Layers:
• utils.py: Contains helper utility functions.
• tests folder: Contains unit tests for validating different components.
b. Relationships and Interactions:
• The main entry (main.py) first loads the configuration (using settings.py and the YAML config file) to determine parameters such as the selected strategies, end dates for backtesting, and push notification settings.
• It then calls data_fetcher.py to retrieve the latest market data from the external AKShare API.
• The system proceeds to execute one or more strategy modules from the “strategy” folder; work_flow.py likely coordinates these executions and orchestrates the order or combination of strategies.
• Once the strategies produce output (e.g., selected stocks, analysis results), the notification module push.py acts based on the configuration to send messages (via WxPusher) or log results.
• Utilities in utils.py support various common tasks throughout these steps.
• The tests directory validates the functionality of the above components.
c. Architectural Patterns and Technologies:
• Modularity: The clear separation between fetching data, strategy analysis, workflow orchestration, and notifications indicates a modular design.
• Configuration-Driven Behavior: Use of a YAML config file for environment-specific parameters and scheduling options (local or crontab).
• Extensibility: The “strategy” directory’s structure makes it easy to add new stock selection strategies.
• External Integration: Integration with AKShare for data fetching and WxPusher for notifications.
• Environment Management: Recommendations for Miniconda and TA-Lib installation indicate careful dependency and environment management.
Specific Elements
• Clear labels for each component:
• Distinct Visual Cues:
• Annotations:
• How environment and dependency management are set up (reference to requirements.txt, TA-Lib), as well as mention test coverage via the tests directory.