refactor(archive): move unused modules to archive/
Archive legacy framework and utility modules that are no longer referenced by the active core (datasource/ and rotation/): - framework/ -> archive/framework/ - framework_v2/ -> archive/framework_v2/ - strategies/ -> archive/strategies/ - config/ -> archive/config/ - visualization/ -> archive/visualization/ - scripts/ -> archive/scripts/ - tests/ -> archive/tests/ - run_rotation.py, run_us_rotation.py -> archive/single_files/ - compare_*.py, test_api_dates.py -> archive/single_files/
This commit is contained in:
54
archive/framework/signals/__init__.py
Normal file
54
archive/framework/signals/__init__.py
Normal file
@@ -0,0 +1,54 @@
|
||||
"""
|
||||
信号层抽象接口(通用)
|
||||
|
||||
只提供抽象基类,具体信号生成器在strategies/shared/signals/
|
||||
"""
|
||||
|
||||
from abc import ABC, abstractmethod
|
||||
from typing import List, Optional, Any
|
||||
import pandas as pd
|
||||
|
||||
|
||||
class SignalGenerator(ABC):
|
||||
"""
|
||||
信号生成器抽象基类
|
||||
|
||||
所有信号生成器必须实现generate方法
|
||||
"""
|
||||
|
||||
mode: str = "base"
|
||||
|
||||
def __init__(self, **params):
|
||||
"""初始化信号生成器参数"""
|
||||
self._params = params
|
||||
|
||||
@abstractmethod
|
||||
def generate(self, factor_data: pd.DataFrame) -> pd.DataFrame:
|
||||
"""
|
||||
生成交易信号
|
||||
|
||||
Args:
|
||||
factor_data: 因子数据DataFrame
|
||||
|
||||
Returns:
|
||||
包含'signal'列的DataFrame
|
||||
"""
|
||||
pass
|
||||
|
||||
def validate_factor_data(self, factor_data: pd.DataFrame) -> bool:
|
||||
"""验证因子数据是否有效"""
|
||||
if factor_data.empty:
|
||||
return False
|
||||
|
||||
if 'signal' in factor_data.columns:
|
||||
print("Warning: factor_data already contains 'signal' column")
|
||||
|
||||
return True
|
||||
|
||||
def __repr__(self) -> str:
|
||||
params_str = ', '.join([f"{k}={v}" for k, v in self._params.items()])
|
||||
return f"{self.__class__.__name__}({params_str})"
|
||||
|
||||
|
||||
# 导出抽象接口
|
||||
__all__ = ['SignalGenerator']
|
||||
Reference in New Issue
Block a user