feat: add daily log rotation, llama health wait, factor auto-fixer, and README updates

- Add rdagent/log/daily_log.py: daily-rotating structured logs per command
  (fin_quant, strategies, evaluate, parallel) with loguru; all.log combined sink
- predix.py: route TeeWriter output to logs/YYYY-MM-DD/ instead of root dir;
  wrap quant() and evaluate() in daily_log.session() for start/stop/duration tracking
- rdagent/app/cli.py: fin_quant_cli waits for llama.cpp /health endpoint before
  starting pipeline (up to 300 s); daily_log integration for fin_quant,
  generate_strategies, eval_all, parallel commands
- scripts/predix_gen_strategies_real_bt.py: daily_log integration with
  per-strategy ACCEPTED/REJECTED entries and summary on completion
- rdagent/components/coder/factor_coder/auto_fixer.py: new module that patches
  common LLM-generated factor issues (min_periods, inf/NaN, groupby.transform,
  MultiIndex corrections)
- rdagent/components/coder/factor_coder/prompts.yaml: add critical rules for
  EURUSD 1-min intraday factors (min_periods, inf handling, groupby, date range)
- README.md: document --reasoning off and --n-gpu-layers 28 for llama-server;
  explain VRAM constraints when Ollama is running alongside llama.cpp
- .bandit.yml: suppress B615 (HuggingFace unsafe download) for RL benchmark files

Co-Authored-By: Claude Sonnet 4.6 <noreply@anthropic.com>
This commit is contained in:
TPTBusiness
2026-04-16 07:20:08 +02:00
parent bc20f41c23
commit 1493ca890b
11 changed files with 748 additions and 37 deletions
@@ -14,6 +14,7 @@ from rdagent.components.coder.CoSTEER.knowledge_management import (
)
from rdagent.components.coder.factor_coder.config import FACTOR_COSTEER_SETTINGS
from rdagent.components.coder.factor_coder.factor import FactorFBWorkspace, FactorTask
from rdagent.components.coder.factor_coder.auto_fixer import auto_fix_factor_code
from rdagent.core.experiment import FBWorkspace
from rdagent.oai.llm_conf import LLM_SETTINGS
from rdagent.oai.llm_utils import APIBackend
@@ -156,6 +157,9 @@ class FactorMultiProcessEvolvingStrategy(MultiProcessEvolvingStrategy):
else:
raise # continue to retry
# === AUTO-FIX: Apply known fixes before returning code ===
code = auto_fix_factor_code(code, target_factor_task_information)
return code
except (json.decoder.JSONDecodeError, KeyError):
@@ -172,7 +176,17 @@ class FactorMultiProcessEvolvingStrategy(MultiProcessEvolvingStrategy):
# Since the `implement_one_task` method is not standardized and the `code_list` has both `str` and `dict` data types,
# we ended up getting an `TypeError` here, so we chose to fix the problem temporarily with this dirty method.
if isinstance(code_list[index], dict):
evo.sub_workspace_list[index].inject_files(**code_list[index])
# Auto-fix each file in the dict
fixed_dict = {}
for filename, file_code in code_list[index].items():
if filename.endswith('.py'):
task_info = evo.sub_tasks[index].get_task_information()
fixed_dict[filename] = auto_fix_factor_code(file_code, task_info)
else:
fixed_dict[filename] = file_code
evo.sub_workspace_list[index].inject_files(**fixed_dict)
else:
evo.sub_workspace_list[index].inject_files(**{"factor.py": code_list[index]})
task_info = evo.sub_tasks[index].get_task_information()
fixed_code = auto_fix_factor_code(code_list[index], task_info)
evo.sub_workspace_list[index].inject_files(**{"factor.py": fixed_code})
return evo