### Install Frontend Dependencies and Start Dev Server Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/guides/INSTALLATION_GUIDE_V1.md Navigates to the frontend directory, installs necessary Node.js dependencies using npm, and starts the frontend development server. ```bash # 进入前端目录 cd frontend # 安装依赖 npm install # 启动开发服务器 npm run dev ``` -------------------------------- ### Install Dependencies and Start Services Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/architecture/API_ARCHITECTURE_UPGRADE.md Installs necessary Python packages and starts Redis and MongoDB using Docker. It also shows how to start the FastAPI service, worker processes, and the Streamlit interface. ```bash pip install fastapi uvicorn motor redis docker run -d --name redis -p 6379:6379 redis:alpine docker run -d --name mongodb -p 27017:27017 mongo:latest ``` ```bash cd webapi python main.py ``` ```bash python scripts/start_worker.py ``` ```bash cd .. cd web streamlit run app.py ``` -------------------------------- ### Get Help and Examples Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/usage/investment_analysis_guide.md Use these bash commands to view help information and explore available example programs for TradingAgents-CN. ```bash # 查看帮助信息 python -m cli.main help ``` ```bash # 查看示例程序 python -m cli.main examples ``` -------------------------------- ### Install Project Dependencies Source: https://github.com/hsliuping/tradingagents-cn/blob/main/frontend/README.md Run this command to install all necessary project dependencies before starting development or building the application. ```bash npm install ``` -------------------------------- ### Automated Installation for TradingAgents-CN Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/QUICK_START.md The simplest installation method. This script automates the download and setup process. ```bash # 下载并运行自动安装脚本 python scripts/setup/quick_install.py ``` -------------------------------- ### Start the Application Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/releases/v0.1.11-release-notes.md Commands to install dependencies using pip and launch the Streamlit web interface. ```bash # 安装依赖 pip install -r requirements.txt # 启动Web界面 streamlit run web/app.py ``` -------------------------------- ### Clone Project and Start Locally Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/guides/INSTALLATION_GUIDE.md This sequence of commands clones the project and sets up a local Python environment. It includes creating a virtual environment, installing dependencies, and starting the application. ```bash git clone https://github.com/hsliuping/TradingAgents-CN.git cd TradingAgents-CN python -m venv env # Windows: env\Scripts\activate # macOS/Linux: source env/bin/activate python -m pip install --upgrade pip pip install -e . cp .env.example .env # Windows: notepad .env # macOS/Linux: nano .env python start_web.py ``` -------------------------------- ### Run Simple Analysis Demo Source: https://github.com/hsliuping/tradingagents-cn/blob/main/examples/README.md Execute a simple analysis demonstration script. This is recommended for beginners to get started with the framework. ```bash python examples/simple_analysis_demo.py ``` -------------------------------- ### Clone Project and Start with Docker Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/guides/INSTALLATION_GUIDE.md Use this command to quickly clone the project and start the services using Docker Compose. Ensure Docker and Docker Compose are installed. ```bash git clone https://github.com/hsliuping/TradingAgents-CN.git cd TradingAgents-CN cp .env.example .env # Windows: notepad .env # macOS/Linux: nano .env docker-compose up -d ``` -------------------------------- ### Install TradingAgents-CN with Docker Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/QUICK_START.md Recommended for all users, especially beginners. This method provides a one-click start, environment isolation, and stability. ```bash # 1. 克隆项目 git clone https://github.com/hsliuping/TradingAgents-CN.git cd TradingAgents-CN # 2. 配置API密钥 cp .env.example .env # 编辑.env文件,添加您的API密钥 # 3. 启动服务 docker-compose up -d # 4. 访问应用 # 浏览器打开: http://localhost:8501 ``` -------------------------------- ### Build and Start Docker Services Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/deployment/database/DATABASE_SETUP_GUIDE.md Use Docker to automatically handle all dependency relationships, recommended for avoiding installation issues. ```bash # 构建Docker镜像 docker-compose build # 启动服务 docker-compose up -d ``` -------------------------------- ### Add Configuration Guide Link to .env.example Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/configuration/CONFIGURATION_VALIDATOR.md Shows how to add a comment at the beginning of the `.env.example` file to explain the configuration levels and provide a link to a detailed configuration guide. This enhances user understanding and onboarding. ```bash # 📋 配置级别说明: # [REQUIRED] - 必需配置,缺少则无法启动系统 # [RECOMMENDED] - 推荐配置,缺少会影响功能但不影响启动 # [OPTIONAL] - 可选配置,用于高级功能或性能优化 # # 📖 详细配置指南: docs/configuration_guide.md ``` -------------------------------- ### Quick Start: Clone, Build, Test, and Access Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/deployment/QUICK_REFERENCE.md A step-by-step guide for new users to clone the repository, build a portable version, test it, and access the application. Assumes necessary prerequisites are met. ```powershell # 1. 克隆项目 git clone cd TradingAgentsCN # 2. 一键创建绿色版 powershell -ExecutionPolicy Bypass -File scripts\deployment\build_portable_package.ps1 # 3. 测试 cd release\TradingAgentsCN-portable .\start_all.ps1 # 4. 访问 # 浏览器打开: http://localhost # 默认账号: admin/admin123 ``` -------------------------------- ### Install and Start MongoDB Service Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/blog/green-version-backup-restore-upgrade.md Commands to install MongoDB on Linux and start the service. Ensure MongoDB is running before proceeding with data operations. ```bash # 1. 安装 MongoDB # Windows: 下载 MongoDB Community Server # Linux: sudo apt-get install mongodb-org # 2. 启动 MongoDB 服务 # Windows: net start MongoDB # Linux: sudo systemctl start mongod # 3. 确保 MongoDB 正常运行 mongo --eval "db.version()" ``` -------------------------------- ### Create providers/examples/__init__.py Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/integration/adapters/ADAPTER_PROVIDER_REORGANIZATION.md Python code for the __init__.py file in the new providers/examples directory, exporting the ExampleSDKProvider and a factory function. ```python """ 示例数据提供器 展示如何创建新的数据源提供器 """ from .example_sdk import ExampleSDKProvider __all__ = [ 'ExampleSDKProvider', ] def get_example_sdk_provider(**kwargs): """获取示例SDK提供器实例""" return ExampleSDKProvider(**kwargs) ``` -------------------------------- ### Install and Run with One-Click Script Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/troubleshooting/web-startup-issues.md Use a provided script to automate the installation and startup process. Ensure the virtual environment is activated first. ```bash # 1. Activate virtual environment .\env\Scripts\activate # Windows # 2. Run the one-click install and run script python scripts/install_and_run.py ``` -------------------------------- ### Install and Start Redis on macOS Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/guides/installation-guide.md Use Homebrew to install and manage the Redis service on macOS. ```bash brew install redis brew services start redis redis-cli ping ``` -------------------------------- ### Full Deployment Scenario (Test Server) Source: https://github.com/hsliuping/tradingagents-cn/blob/main/scripts/README_import_config.md A step-by-step guide for initial deployment on a test server, including entering the container, running the import script, exiting, and restarting the backend service. ```bash # 1. 进入后端容器 docker exec -it tradingagents-backend bash # 2. 导入配置并创建用户 python scripts/import_config_and_create_user.py # 3. 退出容器 exit # 4. 重启后端服务 docker restart tradingagents-backend # 5. 访问前端并登录 # 用户名: admin # 密码: admin123 ``` -------------------------------- ### Full Initialization with Advanced Options Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/guides/tushare_unified/data_initialization_guide.md An example demonstrating a full initialization with custom historical days, multi-period synchronization, batch size, and force update. ```bash python cli/tushare_init.py \ --full \ --historical-days 365 \ --multi-period \ --batch-size 100 \ --force ``` -------------------------------- ### Install MongoDB Community Server on Windows Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/guides/INSTALLATION_GUIDE_V1.md Instructions for downloading and installing MongoDB Community Server on Windows. After installation, the MongoDB service needs to be started. ```powershell # 下载 MongoDB Community Server # https://www.mongodb.com/try/download/community # 安装后启动服务 net start MongoDB ``` -------------------------------- ### Configure .env File Example Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/fixes/2025-10-21-config-validation-placeholder-detection.md This example shows how to correctly configure the .env file by replacing placeholder values with actual API keys. Ensure the backend service is restarted after saving changes. ```bash # 项目根目录 notepad .env # ❌ 错误:使用占位符 OPENAI_API_KEY=your_openai_api_key_here # ✅ 正确:使用真实 API Key OPENAI_API_KEY=sk-proj-abc123def456... ``` -------------------------------- ### Linux/Mac: One-Click Installation Script Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/deployment/SIMPLE_DEPLOYMENT_GUIDE.md Execute this bash script for a simplified installation on Linux and macOS systems. It handles environment setup and dependency installation. ```bash # 1. Download project git clone https://github.com/hsliuping/TradingAgents-CN.git cd TradingAgents-CN # 2. Run one-click installation script chmod +x scripts/easy_install.sh ./scripts/easy_install.sh # 3. Follow prompts to complete configuration # 4. Browser will automatically open http://localhost:8501 ``` -------------------------------- ### API Request Example Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/fixes/reports-market-filter-fix.md Example of an API GET request to the reports list endpoint with a market filter. ```http GET /api/reports/list?page=1&page_size=20&market_filter=A股 Authorization: Bearer ``` -------------------------------- ### Recommended Development Startup Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/improvements/BACKEND_OPTIMIZATION.md The recommended command for starting the backend during daily development, utilizing the optimized module startup. ```bash # 推荐的开发启动方式 python -m app ``` -------------------------------- ### Example: Full Configuration Validation Output Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/configuration/CONFIGURATION_VALIDATOR.md Displays the expected output when all required and recommended configurations are present and valid. This indicates a successful system startup. ```text ====================================================================== 📋 TradingAgents-CN 配置验证结果 ====================================================================== ✅ 所有必需配置已完成 ====================================================================== ✅ 配置验证通过,系统可以启动 ====================================================================== ``` -------------------------------- ### Start Backend Service Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/guides/v1.0.1-user-manual.md Use this command to start the backend service for TradingAgents-CN. Ensure Python is installed and accessible in your PATH. ```bash python -m app.main ``` -------------------------------- ### Recommended Startup Command Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/troubleshooting/web-startup-issues.md The recommended command to start the web application. This method is simple and handles pathing automatically. ```bash # Recommended startup command python start_web.py ``` -------------------------------- ### Verify Windows Installation Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/blog/2025-11-01-to-11-04-windows-installer-and-fundamental-analysis-enhancements.md Checks for the presence of desktop shortcuts, start menu entries, and program list entries after installation. ```bash # 3. 检查安装 # - 桌面快捷方式 # - 开始菜单 # - 程序列表 ``` -------------------------------- ### Install Dependencies Step-by-Step Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/guides/installation-guide.md A phased approach to installing dependencies, recommended for resolving potential conflicts. Covers basic, LLM, data source, and database packages before the main project installation. ```bash # 1. Install basic dependencies pip install streamlit pandas numpy requests plotly # 2. Install LLM related dependencies pip install openai langchain langgraph dashscope # 3. Install data source dependencies pip install yfinance tushare akshare # 4. Install database dependencies (optional) pip install redis pymongo # 5. Install the project pip install -e . ``` -------------------------------- ### Setup Embedded Python with Specific Version Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/deployment/EMBEDDED_PYTHON_GUIDE.md Installs or updates the embedded Python environment to a specified version using a setup script. This is used for initial setup or upgrading to newer Python versions. ```powershell powershell -ExecutionPolicy Bypass -File scripts\\deployment\\setup_embedded_python.ps1 -PythonVersion "3.10.13" ``` ```powershell powershell -ExecutionPolicy Bypass -File scripts\\deployment\\setup_embedded_python.ps1 -PythonVersion "3.11.7" ``` -------------------------------- ### Example .env.example Structure Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/configuration/configuration_optimization_plan.md Illustrates the structure for an example .env file, categorizing configuration items into REQUIRED, RECOMMENDED, and OPTIONAL sections with clear comments and annotations. ```bash # ===== 必需配置(系统启动必需) ===== # [REQUIRED] 数据库连接 MONGODB_HOST=localhost MONGODB_PORT=27017 ... # ===== 推荐配置(功能正常运行推荐) ===== # [RECOMMENDED] 大模型API密钥(至少配置一个) DEEPSEEK_API_KEY=sk-xxx ... # ===== 可选配置(高级功能) ===== # [OPTIONAL] 数据同步配置 TUSHARE_UNIFIED_ENABLED=true ... ``` -------------------------------- ### Start New Vite Frontend Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/releases/v0.1.16-preview-release-notes.md Installs Node.js dependencies and starts the development server for the new Vite-based frontend. The default port is 5173. ```bash cd frontend && npm install npm run dev ``` -------------------------------- ### Recommended Production Startup Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/improvements/BACKEND_OPTIMIZATION.md The recommended command for deploying the backend in a production environment, using the optimized production startup script. ```bash # 推荐的生产启动方式 python start_production.py ``` -------------------------------- ### Start Services with Docker Compose Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/configuration/migration/CONFIG_MIGRATION.md Use this command to start the MongoDB service using Docker Compose. Ensure Docker is installed and running. ```bash docker-compose up -d mongodb ``` -------------------------------- ### Run Configuration Management Demo Source: https://github.com/hsliuping/tradingagents-cn/blob/main/examples/README.md Execute the configuration management demonstration script. This example illustrates how to manage configuration files within the TradingAgents framework. ```bash python examples/config_management_demo.py ``` -------------------------------- ### Install Redis on macOS Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/guides/INSTALLATION_GUIDE_V1.md Installs Redis using Homebrew on macOS and starts the Redis service. This ensures Redis is running and accessible for the application. ```bash # 使用 Homebrew 安装 brew install redis # 启动服务 brew services start redis ``` -------------------------------- ### Start Web Service (Professional Mode) Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/deployment/SIMPLE_DEPLOYMENT_GUIDE.md Run the web service for the professional deployment mode. ```bash # Web python start_web.py ``` -------------------------------- ### Install and Configure MongoDB on Linux (Ubuntu/Debian) Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/deployment/v1.0.0-source-installation.md Install MongoDB on Linux (Ubuntu/Debian) by adding the official repository, updating package lists, and installing the package. Start and enable the service, then create an administrator user. ```bash # 导入公钥 wget -qO - https://www.mongodb.org/static/pgp/server-5.0.asc | sudo apt-key add - # 创建列表文件 echo "deb [ arch=amd64,arm64 ] https://repo.mongodb.org/apt/ubuntu focal/mongodb-org/5.0 multiverse" | sudo tee /etc/apt/sources.list.d/mongodb-org-5.0.list # 更新并安装 sudo apt-get update sudo apt-get install -y mongodb-org sudo systemctl start mongod sudo systemctl enable mongod # 创建管理员用户(参考docker-compose.hub.nginx.yml配置) mongosh > use admin > db.createUser({ user: "admin", pwd: "tradingagents123", roles: ["userAdminAnyDatabase", "dbAdminAnyDatabase", "readWriteAnyDatabase"] }) ``` -------------------------------- ### Install MongoDB Community on macOS Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/guides/INSTALLATION_GUIDE_V1.md Installs MongoDB Community using Homebrew on macOS and starts the MongoDB service. This ensures MongoDB is running and accessible. ```bash # 使用 Homebrew 安装 brew tap mongodb/brew brew install mongodb-community # 启动服务 brew services start mongodb-community ``` -------------------------------- ### Install and Configure Redis on macOS Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/deployment/v1.0.0-source-installation.md Install Redis on macOS using Homebrew. Start the service and then configure it to require a password by editing the configuration file. ```bash # 使用 Homebrew brew install redis brew services start redis # 设置密码(参考docker-compose.hub.nginx.yml配置) # 编辑配置文件: /usr/local/etc/redis.conf # 添加: requirepass tradingagents123 brew services restart redis ``` -------------------------------- ### Update .env.example with Configuration Levels Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/configuration/CONFIGURATION_VALIDATOR.md Demonstrates how to update the `.env.example` file by adding configuration level annotations like `[REQUIRED]`, `[RECOMMENDED]`, and `[OPTIONAL]` before each configuration item. This provides users with clear guidance on the importance of each setting. ```bash # [REQUIRED] MongoDB 数据库连接 MONGODB_HOST=localhost MONGODB_PORT=27017 # [RECOMMENDED] DeepSeek API 密钥 DEEPSEEK_API_KEY=your_deepseek_api_key_here # [OPTIONAL] 其他大模型 API 密钥 OPENAI_API_KEY=your_openai_api_key_here ``` -------------------------------- ### Configure Environment Variables Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/overview/quick-start.md Create a .env file by copying the example and populate it with your API keys and database configurations. ```bash # 复制配置模板 cp .env.example .env # 编辑 .env 文件,配置以下API密钥: # 🇨🇳 阿里百炼 (推荐) DASHSCOPE_API_KEY=your_dashscope_api_key_here # FinnHub (必需) FINNHUB_API_KEY=your_finnhub_api_key_here # Google AI (可选) GOOGLE_API_KEY=your_google_api_key_here # 数据库配置 (可选,默认禁用) MONGODB_ENABLED=false REDIS_ENABLED=false ``` -------------------------------- ### A股 Data Acquisition Log Example Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/integration/data-sources/DATA_SOURCE_LOGGING.md Example log entries showing the start and successful completion of A-share data acquisition using AKShare. ```log 2025-09-30 17:30:12,310 | dataflows | INFO | 📊 [数据来源: akshare] 开始获取股票数据: 002475 2025-09-30 17:30:12,524 | dataflows | INFO | ✅ [数据来源: akshare] 成功获取股票数据: 002475 (455字符, 耗时0.19秒) ``` -------------------------------- ### Install pdfkit and wkhtmltopdf on macOS Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/guides/installation/pdf_tools.md Install pdfkit using pip and wkhtmltopdf using Homebrew on macOS. This setup is required for pdfkit to function correctly. ```bash pip install pdfkit ``` ```bash brew install wkhtmltopdf ``` -------------------------------- ### Windows: One-Click Installation Script Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/deployment/SIMPLE_DEPLOYMENT_GUIDE.md Use this PowerShell script for a streamlined installation on Windows. It automates dependency checks, environment setup, and application configuration. ```powershell # 1. Download project git clone https://github.com/hsliuping/TradingAgents-CN.git cd TradingAgents-CN # 2. Run one-click installation script powershell -ExecutionPolicy Bypass -File scripts/easy_install.ps1 # 3. Follow prompts to complete configuration # The script will automatically: # - Check Python version # - Create virtual environment # - Install dependencies # - Guide API key configuration # - Start the application # 4. Browser will automatically open http://localhost:8501 ``` -------------------------------- ### Download and Rename Environment Example File Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/guides/INSTALLATION_GUIDE_V1.md Downloads the .env.example file and renames it to .env. This file will store your local environment configurations, including API keys. ```bash curl -O https://raw.githubusercontent.com/hsliuping/TradingAgents-CN/main/.env.example mv .env.example .env ``` -------------------------------- ### Start Backend and Frontend Services (Bash) Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/configuration/configuration_guide.md Commands to launch the backend API and the frontend development server. Ensure you are in the correct directories and have the necessary virtual environment activated. ```bash # 启动后端 .\.venv\Scripts\python -m uvicorn app.main:app --host 0.0.0.0 --port 8000 --reload # 启动前端(新终端) cd frontend npm run dev ``` -------------------------------- ### Get HK Stock Data Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/design/stock_data_methods_analysis.md Convenience function to get Hong Kong stock data as a string. Supports optional start and end dates. ```python def get_hk_stock_data(symbol: str, start_date: str = None, end_date: str = None) -> str ``` -------------------------------- ### Start Web Application Locally Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/releases/v0.1.10-release-notes.md Command to start the TradingAgents-CN web application locally using Python. Ensure Python is installed and the project dependencies are met. ```bash # 本地用户 python start_web.py ``` -------------------------------- ### JSON: Full System Configuration Example Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/configuration/UNIFIED_CONFIG.md An example of a complete unified system configuration, including LLM configurations, data source settings, and general system parameters. ```json { "config_name": "统一系统配置", "llm_configs": [ { "provider": "openai", "model_name": "gpt-3.5-turbo", "api_key": "sk-xxx", "api_base": "https://api.openai.com/v1", "max_tokens": 4000, "temperature": 0.7, "enabled": true } ], "default_llm": "gpt-3.5-turbo", "data_source_configs": [ { "name": "AKShare", "type": "akshare", "endpoint": "https://akshare.akfamily.xyz", "enabled": true, "priority": 1 } ], "system_settings": { "max_concurrent_tasks": 3, "default_analysis_timeout": 300, "enable_cache": true } } ``` -------------------------------- ### Start TradingAgents-CN (Portable Version) Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/guides/INSTALLATION_GUIDE_V1.md Run this command in PowerShell as an administrator after navigating to the installation directory to start all services. Ensure you are using the correct execution policy. ```powershell powershell -ExecutionPolicy Bypass -File start_all.ps1 ``` -------------------------------- ### Create New Provider Directory and Copy File Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/integration/adapters/ADAPTER_PROVIDER_REORGANIZATION.md Bash commands to create the new directory structure for example providers and copy the example SDK provider file into it. ```bash mkdir -p tradingagents/dataflows/providers/examples cp tradingagents/dataflows/example_sdk_provider.py \ tradingagents/dataflows/providers/examples/example_sdk.py ``` -------------------------------- ### Start Web Application (Minimalist Mode) Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/deployment/SIMPLE_DEPLOYMENT_GUIDE.md Launch the web application using Python for the minimalist deployment mode. ```bash python start_web.py ``` -------------------------------- ### Install and Configure MongoDB on macOS Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/deployment/v1.0.0-source-installation.md Install MongoDB on macOS using Homebrew. Start the service and then connect using mongosh to create an administrator user with specified roles. ```bash # 使用 Homebrew brew tap mongodb/brew brew install mongodb-community brew services start mongodb/brew/mongodb-community # 创建管理员用户(参考docker-compose.hub.nginx.yml配置) mongosh > use admin > db.createUser({ user: "admin", pwd: "tradingagents123", roles: ["userAdminAnyDatabase", "dbAdminAnyDatabase", "readWriteAnyDatabase"] }) ``` -------------------------------- ### Configure Backend Environment Variables Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/deployment/v1.0.0-source-installation.md Copy the example environment file and edit it to configure essential parameters such as database connection URLs, API base URL, CORS origins, and API keys for LLMs. Ensure database credentials match the setup. ```bash cp .env.example .env ``` ```env # 数据库配置(参考docker-compose.hub.nginx.yml中的配置) MONGODB_URL=mongodb://admin:tradingagents123@localhost:27017/tradingagents?authSource=admin REDIS_URL=redis://:tradingagents123@localhost:6379/0 # API 配置 API_BASE_URL=http://localhost:8000 CORS_ORIGINS=["http://localhost:3000"] # LLM 配置(根据需要配置) OPENAI_API_KEY=your_openai_key DEEPSEEK_API_KEY=your_deepseek_key SILICONFLOW_API_KEY=your_siliconflow_key # 其他配置 DEBUG=true LOG_LEVEL=INFO ``` -------------------------------- ### Start Backend Service Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/features/usage-statistics/USAGE_STATISTICS_QUICK_TEST.md Navigate to the project directory, activate the virtual environment, and start the backend Uvicorn server. Ensure the host is set to 0.0.0.0 for accessibility. ```powershell # Enter project directory cd d:\code\TradingAgents-CN # Activate virtual environment .\.venv\Scripts\Activate.ps1 # Start backend .\.venv\Scripts\python -m uvicorn app.main:app --reload --host 0.0.0.0 --port 8000 ``` -------------------------------- ### Start Frontend Service Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/features/usage-statistics/USAGE_STATISTICS_QUICK_TEST.md Open a new terminal, navigate to the frontend directory, and start the frontend development server using npm. This command assumes 'npm' is installed and configured. ```powershell # Open a new terminal cd d:\code\TradingAgents-CN\frontend # Start frontend npm run dev ``` -------------------------------- ### Development Environment Startup Comparison Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/improvements/BACKEND_OPTIMIZATION.md A table comparing different methods for starting the backend in a development environment, highlighting the recommended `python -m app` method. ```markdown | 方式 | 命令 | 特点 | |------|------|------| | **推荐** | `python -m app` | 模块化启动,配置优化 | | 脚本启动 | `python start_backend.py` | 跨平台兼容 | | 批处理 | `start_backend.bat` | Windows快捷启动 | | Shell脚本 | `./start_backend.sh` | Linux/macOS快捷启动 | | 直接启动 | `python app/main.py` | 传统方式 | ``` -------------------------------- ### Install and Configure Redis on Linux (Ubuntu/Debian) Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/deployment/v1.0.0-source-installation.md Install Redis on Linux (Ubuntu/Debian) using apt-get. Start and enable the service, then configure it to require a password by editing the configuration file. ```bash sudo apt-get update sudo apt-get install redis-server sudo systemctl start redis sudo systemctl enable redis # 设置密码(参考docker-compose.hub.nginx.yml配置) # 编辑配置文件: /etc/redis/redis.conf # 添加: requirepass tradingagents123 sudo systemctl restart redis ``` -------------------------------- ### Install Node.js Dependencies for Frontend Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/deployment/v1.0.0-source-installation.md Navigate to the frontend directory and install all necessary Node.js dependencies using yarn. This command should be executed after cloning the project and before starting the frontend development server. ```bash cd frontend # 使用 yarn进行安装 yarn install ``` -------------------------------- ### Example: Missing Configuration Validation Output Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/configuration/CONFIGURATION_VALIDATOR.md Shows the expected output when required and recommended configurations are missing. It lists the missing items with their descriptions and examples, along with a link to the configuration guide. ```text ====================================================================== 📋 TradingAgents-CN 配置验证结果 ====================================================================== ❌ 缺少必需配置: • MONGODB_HOST 说明: MongoDB主机地址 示例: localhost • MONGODB_PORT 说明: MongoDB端口 示例: 27017 • JWT_SECRET 说明: JWT密钥(用于生成认证令牌) 示例: your-super-secret-jwt-key-change-in-production ⚠️ 缺少推荐配置(不影响启动,但会影响功能): • DEEPSEEK_API_KEY 说明: DeepSeek API密钥(推荐,性价比高) 获取: https://platform.deepseek.com/ ====================================================================== ❌ 配置验证失败,请检查上述配置项 📖 配置指南: docs/configuration_guide.md ====================================================================== ``` -------------------------------- ### Production Environment Startup Comparison Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/improvements/BACKEND_OPTIMIZATION.md A table comparing different methods for starting the backend in a production environment, highlighting the recommended `python start_production.py` method. ```markdown | 方式 | 命令 | 特点 | |------|------|------| | **推荐** | `python start_production.py` | 多进程,性能优化 | | Uvicorn | `uvicorn app.main:app --workers 4` | 手动配置 | | Docker | `docker-compose up -d` | 容器化部署 | ``` -------------------------------- ### Cache Configuration Guide - Code Specification Source: https://github.com/hsliuping/tradingagents-cn/blob/main/docs/architecture/cache/CACHE_SYSTEM_SOLUTION.md Example of how to directly instantiate and use the IntegratedCacheManager in code. ```python from tradingagents.dataflows.cache import IntegratedCacheManager cache = IntegratedCacheManager() ```