Skip to content

Commit

Permalink
Fix csv.get_csv_paths
Browse files Browse the repository at this point in the history
Fixes `get_csv_paths`  `_get_interval_from_filename` to
distinguish between malformed intervals and tickers with an
interval unit at either extreme.
  • Loading branch information
maread99 committed Feb 28, 2024
1 parent 16e79bf commit a9754c3
Showing 1 changed file with 7 additions and 1 deletion.
8 changes: 7 additions & 1 deletion src/market_prices/prices/csv.py
Original file line number Diff line number Diff line change
Expand Up @@ -130,17 +130,23 @@ def _get_interval_from_filename(name: str) -> TDInterval | None:
"""
parts = name.split("_")
intrvl = timedelta(0)
errors = False
for part in parts:
if (intrvl_ := _get_csv_interval(part)) is None:
continue
if intrvl_ in [ERROR_MALFORMED_INTRVL, ERROR_DAILY_INTRVL]:
if intrvl_ is ERROR_DAILY_INTRVL:
return None
if intrvl_ is ERROR_MALFORMED_INTRVL:
errors = True
continue
if intrvl and intrvl != intrvl_:
# at least two different valid intervals in filename
return None
intrvl = intrvl_
if intrvl:
return intrvl
if errors:
return None
return TDInterval.D1 # assume data is daily


Expand Down

0 comments on commit a9754c3

Please sign in to comment.