Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Console portfolio doesn't work any more #32

Open
rushiagr opened this issue Oct 3, 2021 · 0 comments
Open

Console portfolio doesn't work any more #32

rushiagr opened this issue Oct 3, 2021 · 0 comments

Comments

@rushiagr
Copy link

rushiagr commented Oct 3, 2021

Describe the bug
When trying to do a .portfolio() on console object, it fails with

InputException: Missing or empty field `date`

From inspecting request from Console, now looks like 'date' query param, e.g. ?date=2021-09-03, is mandatory now.

Code snippet

from jugaad_trader import Console
c = Console(z)  # z is the logged-in Zerodha() object
c.login()
c.portfolio()

Error
(ipython shell output)

~/.myvenv/lib/python3.9/site-packages/jugaad_trader-0.18-py3.9.egg/jugaad_trader/zerodha.py in generic_function(**kwargs)
    317             if route == "portfolio":
    318                 kwargs["date"] = datetime.date.today().isoformat()
--> 319             return self._get(route, params=kwargs)
    320         generic_function.__doc__ = docstring
    321         return generic_function

~/.myvenv/lib/python3.9/site-packages/kiteconnect-3.9.4-py3.9.egg/kiteconnect/connect.py in _get(self, route, url_args, params, is_json)
    834     def _get(self, route, url_args=None, params=None, is_json=False):
    835         """Alias for sending a GET request."""
--> 836         return self._request(route, "GET", url_args=url_args, params=params, is_json=is_json)
    837
    838     def _post(self, route, url_args=None, params=None, is_json=False, query_params=None):

~/.myvenv/lib/python3.9/site-packages/jugaad_trader-0.18-py3.9.egg/jugaad_trader/zerodha.py in _request(self, route, method, url_args, params, is_json, query_params)
    193                 # native Kite errors
    194                 exp = getattr(ex, data["error_type"], ex.GeneralException)
--> 195                 raise exp(data["message"], code=r.status_code)
    196
    197             return data["data"]

InputException: Missing or empty field `date`

Fix
Console object's generic_function can be edited to add these two lines:

         def generic_function(**kwargs):
+            if route == "portfolio":
+                kwargs["date"] = datetime.date.today().isoformat()
             return self._get(route, params=kwargs)
         generic_function.__doc__ = docstring
         return generic_function

Hacky, but works!

Additional context
Note that I could only make it work after reverting the commit which broke Console access i.e. c0947e1, part of #23. Related issue #15 .

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant