zerodha / pykiteconnect

The official Python client library for the Kite Connect trading APIs
MIT License
983 stars 470 forks source link

Incorrect use of the StringIO library from six #10

Closed aakashef closed 8 years ago

aakashef commented 8 years ago

Hi,

When fetching the Instruments I am getting the following error

Error:

> /Users/aakashdeep/Documents/PersonalProjects/kitetrader/VirtualEnv/lib/python2.7/site-packages/kiteconnect/__init__.py(422)_parse_csv()
-> reader = csv.reader(StringIO.StringIO(data.strip()))
(Pdb) c
Traceback (most recent call last):
  File "/Users/aakashdeep/Documents/PersonalProjects/kitetrader/trader/Boot.py", line 16, in <module>
    instruments = Instruments()
  File "/Users/aakashdeep/Documents/PersonalProjects/kitetrader/trader/KiteUtils.py", line 25, in load_instruments
    self.instruments = pd.DataFrame(self.kite.instruments())
  File "/Users/aakashdeep/Documents/PersonalProjects/kitetrader/VirtualEnv/lib/python2.7/site-packages/kiteconnect/__init__.py", line 378, in instruments
    return self._parse_csv(self._get("market.instruments.all"))
  File "/Users/aakashdeep/Documents/PersonalProjects/kitetrader/VirtualEnv/lib/python2.7/site-packages/kiteconnect/__init__.py", line 422, in _parse_csv
    reader = csv.reader(StringIO.StringIO(data.strip()))
AttributeError: class StringIO has no attribute 'StringIO'

I think this is because of incorrect use of StringIO from six here: There is an issue in the code, https://github.com/rainmattertech/pykiteconnect/blob/master/kiteconnect/__init__.py#L421

aakashef commented 8 years ago

https://github.com/rainmattertech/pykiteconnect/pull/11