| | |
| | | import logging |
| | | import json |
| | | import pickle |
| | | from pathlib import Path |
| | | import pandas as pd |
| | | import numpy as np |
| | | from typing import Dict, List, Tuple, Optional |
| | |
| | | except ImportError: |
| | | FACTOR_RISK_AVAILABLE = False |
| | | |
| | | PROJECT_ROOT = Path(__file__).resolve().parents[1] |
| | | LOG_DIR = PROJECT_ROOT / 'logs' |
| | | LOG_DIR.mkdir(parents=True, exist_ok=True) |
| | | |
| | | |
| | | def _configure_console_encoding() -> None: |
| | | """Keep Windows GBK consoles from aborting on symbols or emoji.""" |
| | | for stream in (sys.stdout, sys.stderr): |
| | | reconfigure = getattr(stream, 'reconfigure', None) |
| | | if reconfigure is None: |
| | | continue |
| | | try: |
| | | reconfigure(errors='backslashreplace') |
| | | except (OSError, ValueError): |
| | | pass |
| | | |
| | | |
| | | _configure_console_encoding() |
| | | |
| | | logging.basicConfig( |
| | | level=logging.INFO, |
| | | format='%(asctime)s - %(name)s - %(levelname)s - %(message)s', |
| | | handlers=[ |
| | | logging.FileHandler('logs/daily_master.log'), |
| | | logging.FileHandler(LOG_DIR / 'daily_master.log', encoding='utf-8'), |
| | | logging.StreamHandler() |
| | | ] |
| | | ) |