Configuration Files for Stock Analysis: A Complete Guide to daily_stock_analysis Setup

The daily_stock_analysis repository uses environment files, YAML configurations, and Python configuration classes to manage stock lists, API credentials, LLM endpoints, and trading strategies without modifying source code.

The ZhuLinsen/daily_stock_analysis project separates runtime behavior from code through a layered configuration system. Understanding these configuration files for stock analysis is essential for customizing data sources, enabling agent modes, and connecting to external LLM providers. All settings are centralized through environment variables, structured YAML files, and typed Python wrappers.

Environment Configuration Files

The primary entry point for all settings is the .env.example file located at the repository root. This template contains human-readable key-value pairs defining stock lists, API keys, feature toggles, and agent settings.

When the application boots, src/config.py calls dotenv.load_dotenv() to ingest the actual .env file (which users create by copying .env.example). The Config class defined in [src/config.py](https://github.com/ZhuLinsen/daily_stock_analysis/blob/main/src/config.py) validates and normalizes these variables, converting string inputs to typed Python objects such as List[str] for stock symbols or bool for feature flags.

from src.config import Config

# Load and validate all environment variables at once

cfg: Config = Config.load()

# Access typed configuration attributes

print("Running in agent mode:", cfg.AGENT_MODE)
print("Stocks to analyze:", cfg.STOCK_LIST)
print("LLM temperature:", cfg.LLM_TEMPERATURE)

The resulting Config instance is injected throughout the application via src/services/system_config_service.py, ensuring consistent access to runtime parameters without global state pollution.

LLM and Service Configuration

For LLM provider management, the repository uses litellm_config.example.yaml stored at the repository root. This file defines model mappings, API base URLs, timeout values, and temperature settings for various providers.

The [litellm_config.example.yaml](https://github.com/ZhuLinsen/daily_stock_analysis/blob/main/litellm_config.example.yaml) is referenced by the LITELLM_CONFIG variable in .env.example. The LLMService class in src/services/llm_service.py reads this file using yaml.safe_load at startup to initialize available model endpoints.


# litellm_config.example.yaml

model_list:
  - model_name: "ollama/qwen3:8b"
    api_base: "http://localhost:11434"
    temperature: 0.7
from src.services.llm_service import LLMService
from src.config import Config

cfg = Config.load()
llm = LLMService(config=cfg)
print(llm.available_models())

Strategy Configuration Files

Trading strategies are defined declaratively in YAML files stored under the /strategies/ directory. Each file parameterizes technical analysis rules, specifying window sizes, thresholds, and strategy names.

For example, ma_golden_cross.yaml defines moving average crossover parameters. The Agent subsystem in src/services/agent_service.py loads these files based on the AGENT_SKILLS environment variable, which contains a comma-separated list of strategy filenames to activate.


# .env.example fragment

# AGENT_SKILLS=bull_trend,ma_golden_cross,volume_breakout

from src.services.agent_service import AgentService

agent = AgentService(config=cfg)
agent.load_strategies()

Programmatic Configuration Management

For runtime modifications that persist to disk, the repository includes ConfigManager in [src/core/config_manager.py](https://github.com/ZhuLinsen/daily_stock_analysis/blob/main/src/core/config_manager.py). This utility handles structured .env parsing while preserving comments, line ordering, and formatting during updates.

The ConfigManager class prevents configuration corruption by maintaining file integrity during writes, making it safe to programmatically toggle features without destroying human-readable comments in the environment file.

from src.core.config_manager import ConfigManager

manager = ConfigManager(env_path=".env")
manager.set("AGENT_MODE", "true")
manager.save()

Summary

  • .env.example stores the template for all environment variables including stock lists and API credentials.
  • src/config.py contains the Config class that provides typed access to environment variables via Config.load().
  • src/core/config_manager.py provides the ConfigManager class for safe, line-preserving updates to .env files.
  • litellm_config.example.yaml configures LLM provider endpoints, model mappings, and inference parameters.
  • strategies/*.yaml define parameterized technical analysis rules loaded by the Agent service.
  • src/services/system_config_service.py exposes the configuration singleton to the rest of the application.

Frequently Asked Questions

How do I add new stocks to analyze without editing Python code?

Set the STOCK_LIST variable in your .env file (copied from .env.example) to a comma-separated list of ticker symbols. The Config class in src/config.py automatically parses this string into a Python list during Config.load().

Where do I configure which LLM provider the stock analysis uses?

Update the LITELLM_CONFIG path in .env to point to your YAML configuration file, then define your provider details in litellm_config.example.yaml (or your copied version). The LLMService reads this file at startup to determine available models and API endpoints.

Can I enable or disable specific trading strategies?

Yes. Modify the AGENT_SKILLS environment variable to include a comma-separated list of strategy names (e.g., ma_golden_cross,volume_breakout). The Agent service loads corresponding YAML files from the /strategies/ directory based on this configuration.

How does the application preserve comments when updating configuration files?

The ConfigManager class in src/core/config_manager.py implements line-preserving parsing that maintains original comments and ordering. When calling manager.save(), it writes updates while keeping the file structure intact, ensuring the .env remains human-readable after programmatic modifications.

Have a question about this repo?

These articles cover the highlights, but your codebase questions are specific. Give your agent direct access to the source. Share this with your agent to get started:

Share the following with your agent to get started:
curl -s "https://instagit.com/install.md"

Works with
Claude Codex Cursor VS Code OpenClaw Any MCP Client

Maintain an open-source project? Get it listed too →