Using GenericCSVFeed with JSON data
I am fetching JSON OHLC from some endpoint and I wanted to create feed from it.
Since there is no JSON feed so I'm converting this data into CSV first.
To avoid writing at disk I'm using String IO buffer (File like object) but seems like the API only supports file path as I'm getting the below error:
_obj._name, _ = os.path.splitext(os.path.basename(_obj.p.dataname)) | | | -> <backtrader.feeds.csvgeneric.GenericCSVData object at 0x10e0ad7f0> | | -> <module 'os' from 'python3.5/os.py'> | -> <module 'os' from 'python3.5/os.py'> -> <backtrader.feeds.csvgeneric.GenericCSVData object at 0x10e0ad7f0>
File "../python3.5/posixpath.py", line 139, in basename
i = p.rfind(sep) + 1
| -> '/'
-> <_io.StringIO object at 0x10ad4db88>
AttributeError: '_io.StringIO' object has no attribute 'rfind'
Is there any better way of doing this?
GenericCSVFeedopens the files itself.
You can subclass directly from
GenericCSVFeeddoes) and simply override
It is fully documented here: Docs - CSV Data Feed Development
Why not converting the json to a panda dataframe which you can then load easily?