-
-
Notifications
You must be signed in to change notification settings - Fork 3k
Closed
Description
yfinance version: 0.2.14
I just review the source code. I found a potential bug.
In multi.py#L87:
if interval[1:] in ['m', 'h']:in base.py#L755 / base.py#788 / base.py#1297:
intraday = interval[-1] in ("m", 'h')The list slicings are different. If using 15m for interval, for example, the results are different.
intv = '15m'
print(intv[1:] in ['m', 'h']) # False
print(intv[-1] in ['m', 'h']) # TrueIt's better to implement a utils function to check that:
# in utils.py
def isIntervalIntraday(interval):
# You may want to check whether the interval string is valid, and raise an exception if invalid.
# You may want to trim spaces before checking.
return interval[-1] in ('m', 'h')
# in multi.py
if utils.isIntervalIntraday(interval)
# in base.py
intrady = utils.isIntervalIntraday(interval)It's easier to write tests, and less bugs by calling the same pure function. It has benefit that if you want to add s for second timeframe in the future, you'll just need to change one line in the implementation.
This issue maybe is related to base.py#632:
# 1) fix weired bug with Yahoo! - returning 60m for 30m barsI'm not sure. I did not investigate this further.
paulmcq
Metadata
Metadata
Assignees
Labels
No labels