mirror of
https://github.com/microsoft/qlib.git
synced 2026-07-15 08:46:56 +08:00
12
.deepsource.toml
Normal file
12
.deepsource.toml
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
version = 1
|
||||||
|
|
||||||
|
test_patterns = ["tests/test_*.py"]
|
||||||
|
|
||||||
|
exclude_patterns = ["examples/**"]
|
||||||
|
|
||||||
|
[[analyzers]]
|
||||||
|
name = "python"
|
||||||
|
enabled = true
|
||||||
|
|
||||||
|
[analyzers.meta]
|
||||||
|
runtime_version = "3.x.x"
|
||||||
@@ -61,7 +61,7 @@ def get_position_value(evaluate_date, position):
|
|||||||
# load close price for position
|
# load close price for position
|
||||||
# position should also consider cash
|
# position should also consider cash
|
||||||
instruments = list(position.keys())
|
instruments = list(position.keys())
|
||||||
instruments = list(set(instruments) - set(["cash"])) # filter 'cash'
|
instruments = list(set(instruments) - {"cash"}) # filter 'cash'
|
||||||
fields = ["$close"]
|
fields = ["$close"]
|
||||||
close_data_df = D.features(
|
close_data_df = D.features(
|
||||||
instruments,
|
instruments,
|
||||||
@@ -80,7 +80,7 @@ def get_position_list_value(positions):
|
|||||||
instruments = set()
|
instruments = set()
|
||||||
for day, position in positions.items():
|
for day, position in positions.items():
|
||||||
instruments.update(position.keys())
|
instruments.update(position.keys())
|
||||||
instruments = list(set(instruments) - set(["cash"])) # filter 'cash'
|
instruments = list(set(instruments) - {"cash"}) # filter 'cash'
|
||||||
instruments.sort()
|
instruments.sort()
|
||||||
day_list = list(positions.keys())
|
day_list = list(positions.keys())
|
||||||
day_list.sort()
|
day_list.sort()
|
||||||
|
|||||||
@@ -63,7 +63,7 @@ class UserManager:
|
|||||||
account_path = self.data_path / user_id
|
account_path = self.data_path / user_id
|
||||||
strategy_file = self.data_path / user_id / "strategy_{}.pickle".format(user_id)
|
strategy_file = self.data_path / user_id / "strategy_{}.pickle".format(user_id)
|
||||||
model_file = self.data_path / user_id / "model_{}.pickle".format(user_id)
|
model_file = self.data_path / user_id / "model_{}.pickle".format(user_id)
|
||||||
cur_user_list = [user_id for user_id in self.users]
|
cur_user_list = list(self.users)
|
||||||
if user_id in cur_user_list:
|
if user_id in cur_user_list:
|
||||||
raise ValueError("User {} has been loaded".format(user_id))
|
raise ValueError("User {} has been loaded".format(user_id))
|
||||||
else:
|
else:
|
||||||
|
|||||||
@@ -161,7 +161,7 @@ class DistplotGraph(BaseGraph):
|
|||||||
"""
|
"""
|
||||||
_t_df = self._df.dropna()
|
_t_df = self._df.dropna()
|
||||||
_data_list = [_t_df[_col] for _col in self._name_dict]
|
_data_list = [_t_df[_col] for _col in self._name_dict]
|
||||||
_label_list = [_name for _name in self._name_dict.values()]
|
_label_list = list(self._name_dict.values())
|
||||||
_fig = create_distplot(_data_list, _label_list, show_rug=False, **self._graph_kwargs)
|
_fig = create_distplot(_data_list, _label_list, show_rug=False, **self._graph_kwargs)
|
||||||
|
|
||||||
return _fig["data"]
|
return _fig["data"]
|
||||||
|
|||||||
@@ -1045,9 +1045,6 @@ class SimpleDatasetCache(DatasetCache):
|
|||||||
class DatasetURICache(DatasetCache):
|
class DatasetURICache(DatasetCache):
|
||||||
"""Prepared cache mechanism for server."""
|
"""Prepared cache mechanism for server."""
|
||||||
|
|
||||||
def __init__(self, provider):
|
|
||||||
super(DatasetURICache, self).__init__(provider)
|
|
||||||
|
|
||||||
def _uri(self, instruments, fields, start_time, end_time, freq, disk_cache=1, **kwargs):
|
def _uri(self, instruments, fields, start_time, end_time, freq, disk_cache=1, **kwargs):
|
||||||
return hash_args(*self.normalize_uri_args(instruments, fields, freq), disk_cache)
|
return hash_args(*self.normalize_uri_args(instruments, fields, freq), disk_cache)
|
||||||
|
|
||||||
|
|||||||
@@ -654,9 +654,6 @@ class LocalExpressionProvider(ExpressionProvider):
|
|||||||
Provide expression data from local data source.
|
Provide expression data from local data source.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self):
|
|
||||||
super().__init__()
|
|
||||||
|
|
||||||
def expression(self, instrument, field, start_time=None, end_time=None, freq="day"):
|
def expression(self, instrument, field, start_time=None, end_time=None, freq="day"):
|
||||||
expression = self.get_expression_instance(field)
|
expression = self.get_expression_instance(field)
|
||||||
start_time = pd.Timestamp(start_time)
|
start_time = pd.Timestamp(start_time)
|
||||||
|
|||||||
@@ -76,18 +76,7 @@ class DatasetH(Dataset):
|
|||||||
- The processing is related to data split.
|
- The processing is related to data split.
|
||||||
"""
|
"""
|
||||||
|
|
||||||
def __init__(self, handler: Union[Dict, DataHandler], segments: Dict):
|
def init(self, handler_kwargs: dict = None, segment_kwargs: dict = None):
|
||||||
"""
|
|
||||||
Parameters
|
|
||||||
----------
|
|
||||||
handler : Union[dict, DataHandler]
|
|
||||||
handler will be passed into setup_data.
|
|
||||||
segments : dict
|
|
||||||
handler will be passed into setup_data.
|
|
||||||
"""
|
|
||||||
super().__init__(handler, segments)
|
|
||||||
|
|
||||||
def init(self, handler_kwargs: Optional[Dict] = None, segment_kwargs: Optional[Dict] = None):
|
|
||||||
"""
|
"""
|
||||||
Initialize the DatasetH
|
Initialize the DatasetH
|
||||||
|
|
||||||
|
|||||||
@@ -212,7 +212,7 @@ def get_cls_kwargs(config: Union[dict, str], module) -> (type, dict):
|
|||||||
|
|
||||||
|
|
||||||
def init_instance_by_config(
|
def init_instance_by_config(
|
||||||
config: Union[str, dict, object], module=None, accept_types: Union[type, Tuple[type]] = tuple([]), **kwargs
|
config: Union[str, dict, object], module=None, accept_types: Union[type, Tuple[type]] = (), **kwargs
|
||||||
) -> object:
|
) -> object:
|
||||||
"""
|
"""
|
||||||
get initialized instance with config
|
get initialized instance with config
|
||||||
|
|||||||
Reference in New Issue
Block a user