MCPcopy
hub / github.com/microsoft/qlib / __init__

Method __init__

scripts/dump_bin.py:68–139  ·  view source on GitHub ↗

Parameters ---------- data_path: str stock data path or directory qlib_dir: str qlib(dump) data director backup_dir: str, default None if backup_dir is not None, backup qlib_dir to backup_dir freq: str, default "da

(
        self,
        data_path: str,
        qlib_dir: str,
        backup_dir: str = None,
        freq: str = "day",
        max_workers: int = 16,
        date_field_name: str = "date",
        file_suffix: str = ".csv",
        symbol_field_name: str = "symbol",
        exclude_fields: str = "",
        include_fields: str = "",
        limit_nums: int = None,
    )

Source from the content-addressed store, hash-verified

66 ALL_MODE = "all"
67
68 def __init__(
69 self,
70 data_path: str,
71 qlib_dir: str,
72 backup_dir: str = None,
73 freq: str = "day",
74 max_workers: int = 16,
75 date_field_name: str = "date",
76 file_suffix: str = ".csv",
77 symbol_field_name: str = "symbol",
78 exclude_fields: str = "",
79 include_fields: str = "",
80 limit_nums: int = None,
81 ):
82 """
83
84 Parameters
85 ----------
86 data_path: str
87 stock data path or directory
88 qlib_dir: str
89 qlib(dump) data director
90 backup_dir: str, default None
91 if backup_dir is not None, backup qlib_dir to backup_dir
92 freq: str, default "day"
93 transaction frequency
94 max_workers: int, default None
95 number of threads
96 date_field_name: str, default "date"
97 the name of the date field in the csv
98 file_suffix: str, default ".csv"
99 file suffix
100 symbol_field_name: str, default "symbol"
101 symbol field name
102 include_fields: tuple
103 dump fields
104 exclude_fields: tuple
105 fields not dumped
106 limit_nums: int
107 Use when debugging, default None
108 """
109 data_path = Path(data_path).expanduser()
110 if isinstance(exclude_fields, str):
111 exclude_fields = exclude_fields.split(",")
112 if isinstance(include_fields, str):
113 include_fields = include_fields.split(",")
114 self._exclude_fields = tuple(filter(lambda x: len(x) > 0, map(str.strip, exclude_fields)))
115 self._include_fields = tuple(filter(lambda x: len(x) > 0, map(str.strip, include_fields)))
116 self.file_suffix = file_suffix
117 self.symbol_field_name = symbol_field_name
118 self.df_files = sorted(data_path.glob(f"*{self.file_suffix}") if data_path.is_dir() else [data_path])
119 if limit_nums is not None:
120 self.df_files = self.df_files[: int(limit_nums)]
121 self.qlib_dir = Path(qlib_dir).expanduser()
122 self.backup_dir = backup_dir if backup_dir is None else Path(backup_dir).expanduser()
123 if backup_dir is not None:
124 self._backup_qlib_dir(Path(backup_dir).expanduser())
125

Callers 1

__init__Method · 0.45

Calls 1

_backup_qlib_dirMethod · 0.95

Tested by

no test coverage detected