# coding:utf-8
import os
import yaml
import sys

def load_config():
    """加载配置文件"""
    config_path = os.path.join(os.path.dirname(__file__), 'config.yaml')
    try:
        with open(config_path, 'r', encoding='utf-8') as f:
            config = yaml.safe_load(f)
        return config
    except Exception as e:
        print(f"加载配置文件失败: {str(e)}")
        sys.exit(1)

def get_qmt_config():
    """获取QMT配置"""
    config = load_config()
    return config['qmt_config']

def get_database_config():
    """获取数据库配置"""
    config = load_config()
    return config['database']

def get_logging_config():
    """获取日志配置"""
    config = load_config()
    return config['logging']

def get_strategy_config():
    """获取策略配置"""
    config = load_config()
    return config.get('strategy', {})

def get_database_config():
    """获取数据库配置"""
    config = load_config()
    print(config)
    return config.get('database', {})

def get_redis_config():
    """获取Redis配置"""
    config = load_config()
    return config.get('redis', {})

def get_plan_sync_config():
    """获取计划同步配置"""
    config = load_config()
    return config.get('plan_sync', {'interval_seconds': 60})