Skip to content

Commit 8174298

Browse files
committed
feat: ListMaker(ABC) must use first_date and last_date
1 parent eb809e0 commit 8174298

File tree

1 file changed

+15
-3
lines changed

1 file changed

+15
-3
lines changed

okama/common/make_asset_list.py

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,11 @@ def __init__(
5252
):
5353
self._assets = list(dict.fromkeys(assets)) if assets else [settings.default_ticker]
5454
self._currency = asset.Asset(symbol=f"{ccy}.FX")
55-
self.asset_obj_dict = ListMaker._get_asset_obj_dict(self._list_of_asset_like_objects)
55+
self.asset_obj_dict = ListMaker._get_asset_obj_dict(
56+
self._list_of_asset_like_objects,
57+
first_date=first_date,
58+
last_date=last_date,
59+
)
5660
(
5761
self.first_date,
5862
self.last_date,
@@ -104,9 +108,17 @@ def __getitem__(self, item):
104108
return list(self.asset_obj_dict.values())[item]
105109

106110
@staticmethod
107-
def _get_asset_obj_dict(ls: list) -> dict:
111+
def _get_asset_obj_dict(
112+
ls: list,
113+
first_date: Optional[str] = None,
114+
last_date: Optional[str] = None,
115+
) -> dict:
108116
def get_item(symbol):
109-
asset_item = symbol if hasattr(symbol, "symbol") and hasattr(symbol, "ror") else asset.Asset(symbol)
117+
asset_item = (
118+
symbol
119+
if hasattr(symbol, "symbol") and hasattr(symbol, "ror")
120+
else asset.Asset(symbol, first_date=first_date, last_date=last_date)
121+
)
110122
# Primary guard: use asset_item.pl when available
111123
try:
112124
if asset_item.pl.years == 0 and asset_item.pl.months <= 2:

0 commit comments

Comments
 (0)