anthonykrivonos / Quantico

🌿 (Help wanted) Live quant trading engine for Robinhood in Python 3, now with backtesting.
MIT License
17 stars 10 forks source link

Issue with login #2

Open pringithub opened 6 years ago

pringithub commented 6 years ago

I don't know if this is a holdover from Jamonek's login issue - I can't seem to log in, and can't follow the code flow

Is @anthonykrivonos able to login?

I'm getting different errors from different angles:

1. Looks like it doesn't find query.py in the sibling directory

~driver$ python3 driver/driver.py
2018-11-05T20:24:10.794065E: Could not log in: name 'Query' is not defined
  1. Looks like it can't register utility.py - maybe change driver.py:10:sys.path.append('src')

    ~Quantico/driver$ python3 driver.py Traceback (most recent call last): File "driver.py", line 22, in from utility import * ModuleNotFoundError: No module named 'utility'```

  2. putting driver.py in src ... no error specified

    ~Quantico/src$ python3 driver.py gets_to_init robinhood_initiialized 2018-11-05T20:27:21.434212E: Could not log in:

Debug lines added by me:

 18 class Query:
 19
 20     # __init__:Void
 21     # param email:String => Email of the Robinhood user.
 22     # param password:String => Password for the Robinhood user.
 23     def __init__(self, email, password):
 24         print('gets_to_init')
 25         self.trader = Robinhood()
 26         print('robinhood_initiialized')
 27         self.trader.login(username=email, password=password)
 28         print('logged_in')

Also I'd love to contribute on this project, but that would require me being able to use it :)

anthonykrivonos commented 6 years ago

Thanks for submitting the issue! I had a similar login error a couple hours ago––the Robinhood Python API uses a client key that's shared amongst all users of the API (terrible, but no way around it for now), so login usually experiences downtime once in a while. From my experience, if you login once, the login script I wrote work flawlessly after that.

What Python version are you running? It looks like you're running the script from the driver directory in parts 1 and 2 of your issue, whereas the driver.py script should be run from the root directory of the project.

~some_dir$ cd Quantico
~quantico$ python driver/driver.py
pringithub commented 6 years ago

Interesting note about the client key ... hopefully one of these tries they'll let me in :__(

This is kinda what I wanted to bring attention to (running from project root)

~/Projects/Quantico python3 driver/driver.py
2018-11-05T21:41:17.630812E: Could not log in: name 'Query' is not defined

I'm on python 3.7.0

do you mean to run python3 driver/driver.py?

smalbadger commented 5 years ago

@pringithub were you able to login? I'm having a related issue, but don't know if it's the same as yours.

Traceback (most recent call last): File "/home/smalbadger/.local/lib/python3.6/site-packages/Robinhood/Robinhood.py", line 124, in login res.raise_for_status() File "/home/smalbadger/.local/lib/python3.6/site-packages/requests/models.py", line 935, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: https://api.robinhood.com/oauth2/token/

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "driver/driver.py", line 35, in query = Query(EMAIL, PASSWORD) File "src/query.py", line 25, in init self.trader.login(username=email, password=password) File "/home/username/.local/lib/python3.6/site-packages/Robinhood/Robinhood.py", line 127, in login raise RH_exception.LoginFailed() Robinhood.exceptions.LoginFailed

I removed the try/except block around the Query line in the driver to produce this error.

anthonykrivonos commented 5 years ago

Hey @pringithub, sorry for only getting back to you now. Let me know if things have changed, I'm quite a few commits deeper than I was a month ago and have made many dependency-related changes since.

Also, hey @smalbadger! Have you created a .env file in the root of the project with your credentials? It should look like this.

EMAIL=example@email.com
PASSWORD=p@ssw0rd
pringithub commented 5 years ago

@smalbadger I was, alas, unable to login. @anthonykrivonos simply forgot about me :___( jk

I haven't played around with the RH API in awhile ... rather focused on building my own trading platform using richer data. While the platform is kickass I must say, developing a seaworthy algorithm to sail the intraday tides is much more complicated :)

The end goal of my project (if it ever gets intraday profitable) would be to hook it up to RH - alas ... until then ...

I might also just focus on long trades using daily data (boring, I know) in which case I will care again!

smalbadger commented 5 years ago

Hi @pringithub, it your repository public? I'd like to take a look at it if you don't mind. I'm creating something similar though the work is coming along quite slow. If you're interested, take a look here.

pringithub commented 5 years ago

@smalbadger it's not public at the moment ... the brunt of it is a python wrapper for AlphaVantage, with backtesting done using a database of saved API call data. Algorithms are built on top of that, and a simulator simulatez in causal time. (I first was making $$$$$ with a non-causal algorithm lol - i.e. using future data)

I will probably make the API wrapper publicly available, but the algos are trade secret until I find something profitable :)

pringithub commented 5 years ago

@smalbadger Hey! Just took a look at your repo - definitely a cool platform (looks like we had similar ideas muehehe). Is the main problem not getting authentication on RH?

smalbadger commented 5 years ago

@pringithub The main problem is that I'm a newbie and I keep learning from my mistakes. I am able to login with my application though. I also use my own forked Robinhood repository. You can take a look if you're still trying to login.

smalbadger commented 5 years ago

@anthonykrivonos yeah I did. The issue may be that I have my own version of the Robinhood API (forked from Jamonek).

pringithub commented 5 years ago

You both have Jamonek's repo forked .. I'm thinking someone at RH has caught on and made it harder for newer people to login through their private api. At one point, I tried to login through the browser url (unfortunately I've forgotten how exactly) but was denied several times.

At any rate, you could just as well make a webbot 'external' api. Within a few minutes and with basic knowledge of the very powerful python selenium module, I was able to login and make trades.