Skip to content

Commit 6598d57

Browse files
authored
Merge pull request #8 from paperswithbacktest/codex/clean-.env.example-data-defaults
Load defaults from YAML
2 parents 9cec4ba + 8fc6c44 commit 6598d57

File tree

4 files changed

+22
-15
lines changed

4 files changed

+22
-15
lines changed

.env.example

Lines changed: 0 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -24,13 +24,3 @@ MAX_COMPLETION_TOKENS=4096
2424
SQLITE_DB="~/.alphaevolve/programs.db"
2525

2626

27-
# ---------------------------------------------------------------------------
28-
# Data defaults
29-
# ---------------------------------------------------------------------------
30-
31-
DEFAULT_SYMBOLS="SPY,EFA,IEF,VNQ,GSG"
32-
33-
START_DATE="1990-01-01"
34-
35-
# Hall-of-Fame ranking metric: "sharpe" or "calmar" or any KPI key
36-
HOF_METRIC="sharpe"

alphaevolve/config.py

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,9 +10,10 @@
1010
"""
1111

1212
from pathlib import Path
13-
from pydantic_settings import BaseSettings
14-
from pydantic import Field
1513

14+
import yaml
15+
from pydantic import Field
16+
from pydantic_settings import BaseSettings
1617

1718

1819
class Settings(BaseSettings):
@@ -37,10 +38,16 @@ class Settings(BaseSettings):
3738
exploitation_ratio: float = Field(0.7, env="EXPLOITATION_RATIO")
3839
diversity_metric: str = Field("edit_distance", env="DIVERSITY_METRIC")
3940

40-
41-
4241
class Config:
4342
env_file = ".env"
4443

4544

46-
settings = Settings()
45+
DEFAULT_CONFIG_FILE = Path(__file__).with_name("default_config.yaml")
46+
if DEFAULT_CONFIG_FILE.exists():
47+
with DEFAULT_CONFIG_FILE.open("r") as f:
48+
yaml_defaults = yaml.safe_load(f) or {}
49+
else:
50+
yaml_defaults = {}
51+
52+
53+
settings = Settings(**yaml_defaults)

alphaevolve/default_config.yaml

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,9 @@
1+
# Default values for AlphaEvolve configuration. Values here can be overridden
2+
# by environment variables as defined in `alphaevolve/config.py`.
3+
population_size: 1000
4+
archive_size: 100
5+
num_islands: 5
6+
elite_selection_ratio: 0.1
7+
exploration_ratio: 0.2
8+
exploitation_ratio: 0.7
9+
diversity_metric: edit_distance

pyproject.toml

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -37,6 +37,7 @@ dependencies = [
3737
"numpy",
3838
"tqdm",
3939
"pydantic>=2.0",
40+
"pyyaml>=6.0",
4041
]
4142

4243
# leave this exactly as you had it

0 commit comments

Comments
 (0)