mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-01 01:51:18 +08:00
* feat: add context to data loader * refactor: add instrument to interface of InstProcessor Co-authored-by: Jiabao Qu <qujiabao@logiocean.com>
23 lines
598 B
Python
23 lines
598 B
Python
import abc
|
|
import json
|
|
import pandas as pd
|
|
|
|
|
|
class InstProcessor:
|
|
@abc.abstractmethod
|
|
def __call__(self, df: pd.DataFrame, instrument, *args, **kwargs):
|
|
"""
|
|
process the data
|
|
|
|
NOTE: **The processor could change the content of `df` inplace !!!!! **
|
|
User should keep a copy of data outside
|
|
|
|
Parameters
|
|
----------
|
|
df : pd.DataFrame
|
|
The raw_df of handler or result from previous processor.
|
|
"""
|
|
|
|
def __str__(self):
|
|
return f"{self.__class__.__name__}:{json.dumps(self.__dict__, sort_keys=True, default=str)}"
|