Skip to content

Daily Audit 2026-04-24: Fix CatBoost optimizer bug, print() violation, hardcoded capital - #205

Draft
ch55secake with Copilot wants to merge 3 commits into
mainfrom
copilot/audit-hyperion-codebase-again
Draft

Daily Audit 2026-04-24: Fix CatBoost optimizer bug, print() violation, hardcoded capital#205
ch55secake with Copilot wants to merge 3 commits into
mainfrom
copilot/audit-hyperion-codebase-again

Conversation

Copilot AI commented Apr 24, 2026

Copy link
Copy Markdown
Contributor

Description

Three new bugs identified during the 2026-04-24 codebase audit: a logic error that feeds LightGBM hyperparameters into CatBoost, a print() call violating the Logger singleton convention, and a hardcoded initial capital value that diverges from the actual simulation config.

Changes in this pull request

  • src/pipeline/single_pipeline.py — CatBoost gets wrong hyperparameters when optimisation is enabled
    The original else branch ran LightGBM Optuna optimisation for any non-XGBoost model type, passing LightGBM params (num_leaves, bagging_fraction, …) into CatBoostStockPredictor which expects depth/iterations/l2_leaf_reg. Now uses explicit elif "lightgbm" branch; "catboost" (and any future type) logs a warning and falls back to model defaults. optimizer.save_results() deduplicated to one call.

    # before
    if self.model_type == "xgboost":
        optimizer.optimize_xgboost()
        self._model_params = optimizer.best_xgb_params
    else:                              # catboost silently lands here
        optimizer.optimize_lightgbm()
        self._model_params = optimizer.best_lgb_params  # wrong params for CatBoost
    
    # after
    if self.model_type == "xgboost":
        optimizer.optimize_xgboost()
        self._model_params = optimizer.best_xgb_params
    elif self.model_type == "lightgbm":
        optimizer.optimize_lightgbm()
        self._model_params = optimizer.best_lgb_params
    else:
        logger.warning("No Optuna optimizer available for '%s'. Using defaults.", self.model_type)
        self._model_params = None
        return
    optimizer.save_results(...)
  • src/ranking/ranker.pyprint() instead of logger.warning()
    print("⚠️ No stocks meet the confidence threshold…") replaced with logger.warning(…); added missing from src.util import logger import.

  • src/writer/result_writer.py — hardcoded $10,000.00 ignores actual simulation capital
    persist_results now accepts initial_capital: float = 10_000.0 (default preserves backward compatibility) and writes f" Initial Capital: ${initial_capital:,.2f}\n\n".

Copilot AI linked an issue Apr 24, 2026 that may be closed by this pull request
Copilot AI and others added 2 commits April 24, 2026 08:46
…on, hardcoded capital

Agent-Logs-Url: https://github.com/ch55secake/hyperion/sessions/7d1f2f6b-77fa-4c72-80e7-e4bf44ca5fc1

Co-authored-by: ch55secake <87881861+ch55secake@users.noreply.github.com>
Copilot AI changed the title [WIP] Audit Hyperion codebase and report new findings Daily Audit 2026-04-24: Fix CatBoost optimizer bug, print() violation, hardcoded capital Apr 24, 2026
Copilot AI requested a review from ch55secake April 24, 2026 08:49
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Daily Audit: 2026-04-24

2 participants