Refactor code for improved readability and consistency

- Cleaned up whitespace and formatting in various files including http.py, language.py, logger.py, safe_exec.py, and SQL migration scripts.
- Consolidated import statements and removed unnecessary blank lines.
- Updated logging configuration for better clarity.
- Enhanced the safe execution code with improved error handling and logging.
- Removed commented-out code and unnecessary variables in backfill_zero_trades.py and other scripts.
- Added a pyproject.toml for Ruff and Vulture configuration.
- Introduced requirements-dev.txt for development dependencies.
- Removed commented-out stock entries in init.sql for cleaner migration scripts.
This commit is contained in:
dienakdz
2026-04-09 14:30:51 +07:00
parent 103055b3df
commit 87f2845483
157 changed files with 19026 additions and 17773 deletions
@@ -23,13 +23,11 @@ from __future__ import annotations
import os
import time
from dataclasses import dataclass
from typing import Dict, Any, List, Optional, Tuple
from typing import Any, Dict, List, Optional
from app.services.analysis_memory import AnalysisMemory, get_analysis_memory
from app.utils.db import get_db_connection
from app.utils.logger import get_logger
from app.services.analysis_memory import get_analysis_memory, AnalysisMemory
from app.services.market_data_collector import MarketDataCollector
logger = get_logger(__name__)
@@ -180,9 +178,7 @@ class AICalibrationService:
if validate_before:
memory: AnalysisMemory = get_analysis_memory()
# Validate anything older than ~7 days (matching your existing approx rules).
validated_stats = memory.validate_unvalidated_older_than(
min_age_days=7, limit=300
)
validated_stats = memory.validate_unvalidated_older_than(min_age_days=7, limit=300)
validated_count = int(validated_stats.get("validated", 0) or 0)
except Exception as e:
logger.warning(f"pre-validation failed (skipped): {e}", exc_info=True)
@@ -269,7 +265,9 @@ class AICalibrationService:
buy_threshold = float(best_abs_thr)
sell_threshold = float(-best_abs_thr)
cfg = self.get_latest(market)
min_consensus_abs_override = float(cfg.get("min_consensus_abs_override") or DEFAULTS["min_consensus_abs_override"])
min_consensus_abs_override = float(
cfg.get("min_consensus_abs_override") or DEFAULTS["min_consensus_abs_override"]
)
quality_hold_threshold = float(cfg.get("quality_hold_threshold") or DEFAULTS["quality_hold_threshold"])
try:
@@ -338,4 +336,3 @@ def start_ai_calibration_worker() -> None:
logger.info("[AI Calibration] No calibration update applied (not enough data).")
except Exception as e:
logger.error(f"start_ai_calibration_worker failed: {e}", exc_info=True)