-
Notifications
You must be signed in to change notification settings - Fork 466
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
39 additions
and
3 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -43,9 +43,36 @@ Example Usage | |
When you write a new python script, you'll have to load the module and login to Robinhood. This is | ||
accomplished by typing | ||
|
||
Basic | ||
^^^^^ | ||
|
||
>>> import robin_stocks as r | ||
>>> login = r.login('[email protected]','password') | ||
|
||
You will be prompted for your MFA token if you have MFA enabled and choose to do the above basic example. | ||
|
||
With MFA entered programmatically from Time-based One-Time Password (TOTP) | ||
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | ||
|
||
NOTE: to use this feature, you will have to sign into your robinhood account and turn on two factor authentication. | ||
Robinhood will ask you which two factor authorization app you want to use. Select "other". Robinhood will present you with | ||
an alphanumeric code. This code is what you will use for "My2factorAppHere" in the code below. Run the following code and put | ||
the resulting MFA code into the prompt on your robinhood app. | ||
|
||
>>> import pyotp | ||
>>> totp = pyotp.TOTP("My2factorAppHere").now() | ||
>>> print("Current OTP:", totp) | ||
|
||
Once you have entered the above MFA code (the totp variable that is printed out) into your Robinhood account, it will give you a backup code. | ||
Make sure you do not lose this code or you may be locked out of your account!!! | ||
|
||
Now you should be able to login with the following code, | ||
|
||
>>> import pyotp | ||
>>> import robin_stocks as r | ||
>>> totp = pyotp.TOTP("My2factorAppHere").now() | ||
>>> login = r.login('[email protected]','password', mfa_code=totp) | ||
|
||
Not all of the functions contained in the module need the user to be authenticated. A lot of the functions | ||
contained in the modules 'stocks' and 'options' do not require authentication, but it's still good practice | ||
to log into Robinhood at the start of each script. | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters