ValueError when using plot.py under certain conditions
BennyThadikaran opened this issue · 0 comments
BennyThadikaran commented
plot --watch hold-w --tf weekly --sma 30 --m-rs --preset-save hold
Preset saved as 'hold'
Traceback (most recent call last):
File "/home/benny/Documents/python/eod2/src/plot.py", line 176, in <module>
plotter.plot(symList[plotter.idx])
File "/home/benny/Documents/python/eod2/src/defs/Plotter.py", line 218, in plot
df = self._prepData(sym)
File "/home/benny/Documents/python/eod2/src/defs/Plotter.py", line 742, in _prepData
df = getDataFrame(
File "/home/benny/Documents/python/eod2/src/defs/utils.py", line 176, in getDataFrame
df = csv_loader(fpath, candle_count, end_date=toDate)
File "/home/benny/Documents/python/eod2/src/defs/utils.py", line 128, in csv_loader
current_dt = get_date(start, chunk)
File "/home/benny/Documents/python/eod2/src/defs/utils.py", line 46, in get_date
date = datetime.strptime(date_str, date_fmt)
File "/usr/lib/python3.10/_strptime.py", line 568, in _strptime_datetime
tt, fraction, gmtoff_fraction = _strptime(data_string, format)
File "/usr/lib/python3.10/_strptime.py", line 349, in _strptime
raise ValueError("time data %r does not match format %r" %
ValueError: time data 'Date' does not match format '%Y-%m-%d'
The error occurs when loading a file using the utils.py:csv_loader
function, as a chunk is read from the start of the file.
Under some circumstances the final chunk may read something like this b'Date,Open,High,Low,Close,Volume,TOT'
Trying to parse the Date
string as a Datetime value results in a ValueError. Issue was fixed by catching the ValueError, appending the chunk and returning the data as a DataFrame.
Updates to be posted soon.