1
0
mirror of https://github.com/microsoft/qlib.git synced 2026-07-01 01:51:18 +08:00
Files
qlib/qlib/data/inst_processor.py
Jiabao Qu d2f0bebf60 feat: add instrument context to inst_processor (#959)
* feat: add context to data loader

* refactor: add instrument to interface of InstProcessor

Co-authored-by: Jiabao Qu <qujiabao@logiocean.com>
2022-03-11 12:15:13 +08:00

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)}"