업데이트

This commit is contained in:
2025-12-09 21:39:23 +09:00
parent dd9acf62a3
commit 37a150bd0d
35 changed files with 5587 additions and 493 deletions

36
main.py
View File

@@ -1,22 +1,18 @@
import os
import time
import threading
import argparse
import signal
import sys
import time
from dotenv import load_dotenv
import logging
# Modular imports
from src.common import logger, setup_logger, HOLDINGS_FILE
from src.config import load_config, read_symbols, get_symbols_file, build_runtime_config
from src.common import HOLDINGS_FILE, logger, setup_logger
from src.config import build_runtime_config, get_symbols_file, load_config, read_symbols
from src.holdings import holdings_lock, load_holdings
from src.notifications import report_error, send_startup_test_message
from src.signals import check_profit_taking_conditions, check_stop_loss_conditions
from src.threading_utils import run_sequential, run_with_threads
from src.notifications import send_telegram, report_error, send_startup_test_message
from src.holdings import load_holdings, holdings_lock
from src.signals import check_stop_loss_conditions, check_profit_taking_conditions
# NOTE: Keep pandas_ta exposure for test monkeypatch compatibility
import pandas_ta as ta
load_dotenv()
# [중요] pyupbit/requests 교착 상태 방지용 초기화 코드
@@ -153,7 +149,7 @@ def process_symbols_and_holdings(
# Upbit 최신 보유 정보 동기화
if cfg.upbit_access_key and cfg.upbit_secret_key:
from src.holdings import save_holdings, fetch_holdings_from_upbit
from src.holdings import fetch_holdings_from_upbit, save_holdings
updated_holdings = fetch_holdings_from_upbit(cfg)
if updated_holdings is not None:
@@ -233,6 +229,22 @@ def main():
logger.info("[SYSTEM] MACD 알림 봇 시작")
logger.info("[SYSTEM] " + "=" * 70)
# ✅ [NEW] Upbit API 키 유효성 검증 (실전 모드일 때만)
if not cfg.dry_run:
from src.order import validate_upbit_api_keys
if not cfg.upbit_access_key or not cfg.upbit_secret_key:
logger.error("[ERROR] 실전 모드에서 Upbit API 키가 설정되지 않았습니다. 종료합니다.")
return
is_valid, msg = validate_upbit_api_keys(cfg.upbit_access_key, cfg.upbit_secret_key)
if not is_valid:
logger.error("[ERROR] Upbit API 키 검증 실패: %s. 종료합니다.", msg)
return
logger.info("[SUCCESS] ✅ Upbit API 키 검증 완료")
else:
logger.info("[INFO] Dry-run 모드: API 키 검증 건너뜀")
# Load symbols
symbols = read_symbols(get_symbols_file(config))
if not symbols: