chore(config): 添加环境变量示例及.gitignore更新
- 新增 .env.example,包含 Tushare API、钉钉机器人和PostgreSQL数据库配置模板 - 更新.gitignore,忽略本地配置文件如 .env.local 和 config_local.py - 添加对报表文件命名规则的支持,保留示例文件不忽略 - 删除废弃的 chart.py 及相关图表模块代码 - 新增 config/settings.py,实现从环境变量读取配置的统一接口 - 设置数据目录及缓存目录,确保目录存在,提高配置管理规范性
This commit is contained in:
41
strategies/base.py
Normal file
41
strategies/base.py
Normal file
@@ -0,0 +1,41 @@
|
||||
"""
|
||||
策略基类定义
|
||||
"""
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import Any
|
||||
|
||||
|
||||
class Strategy(ABC):
|
||||
"""策略抽象基类"""
|
||||
|
||||
def __init__(self, name: str, config: dict = None):
|
||||
self.name = name
|
||||
self.config = config or {}
|
||||
|
||||
@abstractmethod
|
||||
def run(self, **kwargs) -> Any:
|
||||
"""执行策略"""
|
||||
pass
|
||||
|
||||
@abstractmethod
|
||||
def get_signals(self, **kwargs) -> Any:
|
||||
"""获取当前信号"""
|
||||
pass
|
||||
|
||||
|
||||
class BacktestStrategy(Strategy):
|
||||
"""回测策略基类"""
|
||||
|
||||
def __init__(self, name: str, config: dict = None):
|
||||
super().__init__(name, config)
|
||||
self.results = None
|
||||
|
||||
@abstractmethod
|
||||
def run_backtest(self, **kwargs) -> dict:
|
||||
"""执行回测,返回绩效指标"""
|
||||
pass
|
||||
|
||||
def get_results(self) -> dict:
|
||||
"""获取回测结果"""
|
||||
return self.results
|
||||
Reference in New Issue
Block a user