From f0e275dd1a5c8510487040bf4e5ba316241aeef2 Mon Sep 17 00:00:00 2001 From: Peter Dekkers Date: Fri, 13 Dec 2024 19:50:25 +0100 Subject: [PATCH] fixed Yahoo feed --- roboquant/feeds/csvfeed.py | 1 + roboquant/feeds/historic.py | 8 ++++---- roboquant/feeds/randomwalk.py | 1 + roboquant/feeds/yahoo.py | 2 +- 4 files changed, 7 insertions(+), 5 deletions(-) diff --git a/roboquant/feeds/csvfeed.py b/roboquant/feeds/csvfeed.py index 73726de..27d3183 100644 --- a/roboquant/feeds/csvfeed.py +++ b/roboquant/feeds/csvfeed.py @@ -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(): diff --git a/roboquant/feeds/historic.py b/roboquant/feeds/historic.py index 2ea2d48..e247e82 100644 --- a/roboquant/feeds/historic.py +++ b/roboquant/feeds/historic.py @@ -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): @@ -54,7 +54,7 @@ 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()) @@ -62,7 +62,7 @@ def __update(self): 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) diff --git a/roboquant/feeds/randomwalk.py b/roboquant/feeds/randomwalk.py index 7b30392..60b7d02 100644 --- a/roboquant/feeds/randomwalk.py +++ b/roboquant/feeds/randomwalk.py @@ -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, _): diff --git a/roboquant/feeds/yahoo.py b/roboquant/feeds/yahoo.py index c268f9e..c180ff0 100644 --- a/roboquant/feeds/yahoo.py +++ b/roboquant/feeds/yahoo.py @@ -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):