Skip to content

Commit

Permalink
fixed Yahoo feed
Browse files Browse the repository at this point in the history
  • Loading branch information
jbaron committed Dec 13, 2024
1 parent eddc804 commit f0e275d
Show file tree
Hide file tree
Showing 4 changed files with 7 additions and 5 deletions.
1 change: 1 addition & 0 deletions roboquant/feeds/csvfeed.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,7 @@ def __init__(
files = self._get_files(path)
logger.info("located %s files in path %s", len(files), path)
self._parse_csvfiles(files) # type: ignore
self._update()

def _get_files(self, path):
if pathlib.Path(path).is_file():
Expand Down
8 changes: 4 additions & 4 deletions roboquant/feeds/historic.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,12 +38,12 @@ def _add_item(self, dt: datetime, item: PriceItem):

def assets(self) -> list[Asset]:
"""Return the list of unique symbols available in this feed"""
self.__update()
self._update()
return list(self.__assets)

def timeline(self) -> list[datetime]:
"""Return the timeline of this feed as a list of datatime objects"""
self.__update()
self._update()
return list(self.__data.keys())

def timeframe(self):
Expand All @@ -54,15 +54,15 @@ def timeframe(self):

return Timeframe.EMPTY

def __update(self):
def _update(self):
if self.__modified:
self.__data = dict(sorted(self.__data.items()))
price_items = chain.from_iterable(self.__data.values())
self.__assets = {item.asset for item in price_items}
self.__modified = False

def play(self, channel: EventChannel):
self.__update()
self._update()
for k, v in self.__data.items():
evt = Event(k, v)
channel.put(evt)
Expand Down
1 change: 1 addition & 0 deletions roboquant/feeds/randomwalk.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,7 @@ def __init__(
for i in range(n_prices):
item = item_gen(asset, prices[i], volume, spread_dev)
self._add_item(timeline[i], item)
self._update()

@staticmethod
def __get_trade(symbol, price, volume, _):
Expand Down
2 changes: 1 addition & 1 deletion roboquant/feeds/yahoo.py
Original file line number Diff line number Diff line change
Expand Up @@ -43,7 +43,7 @@ def __init__(self, *symbols: str, start_date: str = "2010-01-01", end_date: str

logger.info("retrieved symbol=%s items=%s", symbol, len(df))

self.__update()
self._update()

@staticmethod
def __auto_adjust(df):
Expand Down

0 comments on commit f0e275d

Please sign in to comment.