Giter Site home page Giter Site logo

jmfernandes / robin_stocks Goto Github PK

View Code? Open in Web Editor NEW
1.6K 85.0 451.0 8.21 MB

This is a library to use with Robinhood Financial App. It currently supports trading crypto-currencies, options, and stocks. In addition, it can be used to get real time ticker information, assess the performance of your portfolio, and can also get tax documents, total dividends paid, and more. More info at

Home Page: http://www.robin-stocks.com

License: MIT License

Python 100.00%
robinhood-api robinhood-python trading quantitative-finance trading-api robinhood robinhood-portfolio cryptocurrency trading-algorithms stock-trading

robin_stocks's Introduction

docs/source/_static/pics/title.PNG

Robin-Stocks API Library

This library provides a pure python interface to interact with the Robinhood API, Gemini API, and TD Ameritrade API. The code is simple to use, easy to understand, and easy to modify. With this library you can view information on stocks, options, and crypto-currencies in real time, create your own robo-investor or trading algorithm, and improve your programming skills.

To join our Slack channel where you can discuss trading and coding, click the link https://join.slack.com/t/robin-stocks/shared_invite/zt-7up2htza-wNSil5YDa3zrAglFFSxRIA

Supported APIs

The supported APIs are Robinhood, Gemini, and TD Ameritrade. For more information about how to use the different APIs, visit the README documents for Robinhood Documentation, Gemini Documentation, and TDA Documentation.

Below are examples on how to call each of those modules.

>>> import robin_stocks.robinhood as rh
>>> import robin_stocks.gemini as gem
>>> import robin_stocks.tda as tda
>>> # Here are some example calls
>>> gem.get_pubticker("btcusd") # gets ticker information for Bitcoin from Gemini
>>> rh.get_all_open_crypto_orders() # gets all cypto orders from Robinhood
>>> tda.get_price_history("tsla") # get price history from TD Ameritrade

Contributing

If you would like to contribute to this project, follow our contributing guidelines Here.

Automatic Testing

If you are contributing to this project and would like to use automatic testing for your changes, you will need to install pytest and pytest-dotenv. To do this type into terminal or command prompt:

>>> pip install pytest
>>> pip install pytest-dotenv

You will also need to fill out all the fields in .test.env. I recommend that you rename the file as .env once you are done adding in all your personal information. After that, you can simply run:

>>> pytest

to run all the tests. If you would like to run specific tests or run all the tests in a specific class then type:

>>> pytest tests/test_robinhood.py -k test_name_apple # runs only the 1 test
>>> pytest tests/test_gemini.py -k TestTrades # runs every test in TestTrades but nothing else

Finally, if you would like the API calls to print out to terminal, then add the -s flag to any of the above pytest calls.

Installing

There is no need to download these files directly. This project is published on PyPi, so it can be installed by typing into terminal (on Mac) or into command prompt (on PC):

>>> pip install robin_stocks

Also be sure that Python 3 is installed. If you need to install python you can download it from Python.org. Pip is the package installer for python, and is automatically installed when you install python. To learn more about Pip, you can go to PyPi.org.

If you would like to be able to make changes to the package yourself, clone the repository onto your computer by typing into terminal or command prompt:

>>> git clone https://github.com/jmfernandes/robin_stocks.git
>>> cd robin_stocks

Now that you have cd into the repository you can type

>>> pip install .

and this will install whatever you changed in the local files. This will allow you to make changes and experiment with your own code.

List of Functions and Example Usage

For a complete list of all Robinhood API functions and what the different parameters mean, go to robin-stocks.com Robinhood Page. If you would like to see some example code and instructions on how to set up two-factor authorization for Robinhood, go to the Robinhood Documentation.

For a complete list of all TD Ameritrade API functions and what the different parameters mean, go to robin-stocks.com TDA Page. For detailed instructions on how to generate API keys for TD Ameritrade and how to use the API, go to the TDA Documentation.

For a complete list of all Gemini API functions and what the different parameters mean, go to robin-stocks.com Gemeni Page. For detailed instructions on how to generate API keys for Gemini and how to use both the private and public API, go to the Gemini Documentation.

robin_stocks's People

Contributors

6r0k3d avatar ankit1200 avatar anson-vandoren avatar arequ avatar bfoz avatar bvandorf avatar dependabot[bot] avatar drbh avatar gloera avatar guitarguychrisb avatar henryzhangpku avatar jhbalaji avatar jmarkaba avatar jmfernandes avatar jraisher avatar lordnapi avatar muhammada1 avatar nbr23 avatar oolubayo avatar penlo avatar pyuvaraj37 avatar sachinparyani avatar shobnaren avatar solarplex avatar supercilex avatar unacceptable avatar waaronmorris avatar whoisthegingerbreadman avatar wilderfield avatar yilabs avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

robin_stocks's Issues

Invalid Bearer Token - Unable to load pickle file

I was able to login successfully previously, but today when I tried to login I got the following error. I was able to get around this by deleting the site-packages/robin_stocks/data.pickle file and then re-authenticating my computer.

ERROR: There was an issue loading pickle file - logging in normally.
/usr/lib/python3/dist-packages/apport/report.py:13: DeprecationWarning: the imp module is deprecated in favour of importlib; see the module's documentation for alternative uses
  import fnmatch, glob, traceback, errno, sys, atexit, locale, imp
Traceback (most recent call last):
  File "get_stocks.py", line 11, in <module>
    login = robin_stocks.login(user, passwd)
  File "/home/myusr/.local/lib/python3.6/site-packages/robin_stocks/authentication.py", line 142, in login
    raise Exception(data['detail'])
Exception: Invalid bearer token.

authentication data.pickle for multiple users

when user wishes to run multiple instances for different accounts, they can pass the different pickle_path per user.

This would be useful to run on one code base but with multiple instance execution on same virtual env.

Issue with find_tradeable_options_for_stock for stocks that don't have options available

I've been struggling with this for the last two days until I actually looked at the data robinhood was sending back. When you query a stock that (apparently) doesn't have options available robinhood goes ahead and tries to give you EVERYTHING. It starts at the beginning and just spits out all market data on every option chain.

A pretty reasonable check would be to compare the response we're getting the to the symbol we want to query. If we're getting mismatch data the case is likely that there are no options.

quick and easy test for this would be to run
find_tradable_options_for_stock('AAAU')

How to get a list of option quotes?

Hi I am trying to get a list of all the option quotes on a specific expiration date, how could I do that? I can only get chain-id and I don't know how to use chain-id to get the quotes and place option order. Could you help me on that with a simple example? Or it's not possible to buy options via API?

Full set of available options aren't being received

Im using:
r.options.find_tradable_options_for_stock(ticker='MCHP')

To find all possible options availble, however, I'm only receiving options with expiration date in 2020, looking at the RH app I can see that there are many options with expiration dates in 2019.

Issue with accessing data on date of expiry for an option chain

Hello jmfernandes,

I believe this is the issue I ran into a while back, but by the time we had discussed it, you suggested that the old chain had expired, as it had indeed and that was why it was unable to access said data. This was perfectly logical so I didn't think much of it after that.

Now however, I've been running this real-time today trying to access "2019-03-08" option data, and my file saves are [null]. The chain is active on Robinhood's end(I can access the data, on their site, etc.) but for some reason the code does not respond as expected and returns [null].

I get no errors on my end using your .api so I believe it must be a logic error of some sort within the code. The empty list infers that the function runs properly but the code does not execute as expected to be able to store the data as a dictionary in a list as you've made it do, so it instead returns an empty list with null, saving the [ null ] . I suspect you have a function that returns Null (for the dictionary methinks?), and this may be a great place to look at why it is returning null on a day of expiry, and only the date of expiry.

Also just to test this further, after running the save twice and getting a file saved with null in it, I changed the expirationDate from "2019-03-08" to "2019-03-15" and this worked like a charm. So this further confirms my suspicion.

I have no idea if you're aware of this issue or not, but I thought I should at least mention it.

I've been learning more, but I don't think I'm capable of debugging such a large project, but I'll attempt to read through the lines and see if I catch anything. I suspect some of this will definitely beyond my level of understanding. I'm hoping you can find it though as not having that last day of data is very detrimental to being able to review a full week of data from start to finish.

[Solved] Failure in login: [Errno 13] Permission denied

I am getting this error

>>> import robin_stocks as r
>>> login = r.login('email','password')
Enter Robinhood code for validation: 764239
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/usr/local/lib/python3.5/dist-packages/robin_stocks/authentication.py", line 148, in login
    with open(pickle_path, 'wb') as f:
PermissionError: [Errno 13] Permission denied: '/usr/local/lib/python3.5/dist-packages/robin_stocks/data.pickle'

For some reasons, the permission of the /usr/local/lib/python3.5/dist-packages/robin_stocks was not set right. I have fixed this issue by running this command:

sudo chown my_linux_username /usr/local/lib/python3.5/dist-packages/robin_stocks

Issue with robin_stocks.get_option_historicals

Trying to find an alternative way of getting the expiry day data, I figured I would try to get the historical option data and run through each strike as desired. Unfortunately, I got the following error:

Getting the option ID failed. Perhaps the expiration date is wrong format, or the strike price is wrong.
404 Client Error: Not Found for url: https://api.robinhood.com/marketdata/options/historicals/None/?span=week&interval=10minute
None

Here is my code:


import robin_stocks as r

username = ""'
password = "
"

symbol = 'SPY'
expirationDate = '2018-12-21'
strike = '245.00'
optionType = 'call' #I think 'both' or empty '' may yield both, but am unsure.
span = 'week'

r.login(username, password)

data = r.options.get_option_historicals(symbol, expirationDate, strike, optionType, span)

print(data)


Something to do with the optionID for this request it seems.

Support Crypto-Currencies

Robinhood has supported Bitcoin and Ethereum for a while. It would be great if robin_stocks can support bitcoin or other cryptocurrencies.

Prices above $1.00 can't have subpenny increments

Im running a simple program that buys/sells a given stock, and I keep getting the following error:
{'price': ["Prices above $1.00 can't have subpenny increments."]}

My program is as follows:
r.login('myUsername','myPassword')
print(r.order_buy_market('NIO',1,'gfd','true'))

would anyone know why this is happening?

Authentication Timeout after 24hrs

Was curious if someone had a workaround that would extend the Authentication almost indefinitely. I apologize if this is a redundant or previously solved issue, I haven't found a direct answer to this question yet.

class online_collect():
def login(self):
username = '[email protected]'
password = 'xxxxxxxxx'
login = r.login(username,password, expiresIn = 3000000, by_sms = True, store_session = True)

Thanks

0.9.8 *inputsymbols update breaks the usage of strings

0.9.8 *inputsymblos update breaks the usage of strings

While trying to pass though stock symbol for Apple it returns the company for stock symbol "P"

I have found it does this for all company strings i pass through.

Example:
code:
stockTicker = 'AAPL'
quote = robinhood.stocks.get_quotes(stockTicker, info=None)
print('Quote:', quote)

output:
Quote: [{'ask_price': '70.380000', 'ask_size': 3300, 'bid_price': '70.370000', 'bid_size': 2500, 'last_trade_price': '70.380000', 'last_extended_hours_trade_price': '70.380000', 'previous_close': '69.900000', 'adjusted_previous_close': '69.900000', 'previous_close_date': '2019-01-10', 'symbol': 'A', 'trading_halted': False, 'has_traded': True, 'last_trade_price_source': 'consolidated', 'updated_at': '2019-01-11T21:02:52Z', 'instrument': 'https://api.robinhood.com/instruments/2095bd69-d441-4da8-a014-5af9bcbf5394/'}, {'ask_price': '8.600000', 'ask_size': 6500, 'bid_price': '8.590000', 'bid_size': 28000, 'last_trade_price': '8.590000', 'last_extended_hours_trade_price': '8.590000', 'previous_close': '8.620000', 'adjusted_previous_close': '8.620000', 'previous_close_date': '2019-01-10', 'symbol': 'P', 'trading_halted': False, 'has_traded': True, 'last_trade_price_source': 'consolidated', 'updated_at': '2019-01-11T21:02:06Z', 'instrument': 'https://api.robinhood.com/instruments/d15643d2-545c-4b83-a290-f85fe4575b0e/'}, {'ask_price': '46.580000', 'ask_size': 6100, 'bid_price': '46.570000', 'bid_size': 1300, 'last_trade_price': '46.580000', 'last_extended_hours_trade_price': '46.580000', 'previous_close': '46.390000', 'adjusted_previous_close': '46.390000', 'previous_close_date': '2019-01-10', 'symbol': 'L', 'trading_halted': False, 'has_traded': True, 'last_trade_price_source': 'consolidated', 'updated_at': '2019-01-11T21:28:48Z', 'instrument': 'https://api.robinhood.com/instruments/0261820d-077e-4b8f-99e4-28afb01868e1/'}]

percent_change float division by zero

running the basic starting code:

from robin_stocks import robin_stocks
r = robin_stocks()
login = r.login('<myemail>','<mypassword>')
my_stocks = r.build_holdings()

returns the following error

line 4, in
my_stocks = r.build_holdings()

"init.py", line 921, in build_holdings
percent_change = (float(price)-float(item['average_buy_price']))*100/float(item['average_buy_price'])
ZeroDivisionError: float division by zero

account.get_current_positions() doesn't return option positions

The following is used to return current positions, and per the function comments should "return stocks/options currently held":
url = urls.positions() payload = { 'nonzero' : 'true'} data = helper.request_get(url,'pagination',payload)

I believe this will effectively return the data from 'https://api.robinhood.com/positions/?nonzero=true'. I currently only hold options in my robinhood account (no stocks), and account.get_current_positions() returns an empty list ([]).

I'm not sure if the intent is to include options as well, so if not the comment could just be modified to just call out stocks. I haven't yet been able to find a comprehensive current stock+option list.

400 Client Error: Bad Request for url: https://api.robinhood.com/oauth2/token/

I have encountered this issue today:

 token = 'Bearer {}'.format(data['access_token'])
TypeError: 'NoneType' object is not subscriptable

I have done some digging and it looks like the issue is happening in this line in authetication.py:
data = helper.request_post(url,payload)

The error that I'm seeing is:
data = helper.request_post(url,payload)

this is the redacted payload, note that the password and username are working correctly in the robinhood app.

challenge_type:sms
client_id:xxx
device_token:b34e3cf0-c549-8cef-2722-4f662bb12d96
expires_in:86400
grant_type:password
password:xxx
scope:internal
username:diego.vargas.frontanilla@xxx

I've seen this error before but it usually went away after restarting my python interpreter, however today, it is just not going away. I have even tried re installing robin_stocks.

Website Documentation Missing

The following documentation is not visible on the Robin Stocks website:
Getting Positions and Account Information
Placing and Cancelling Orders

Valid Option Query returning None

I am doing the following which I think is valid but the API returns None

robin_stocks.options.find_options_for_stock_by_expiration("MSFT","2019-07-26",optionType="call")
Found Additional pages.
Loading page 2 ...
Loading page 3 ...
Loading page 4 ...
Loading page 5 ...
Loading page 6 ...
Out[101]: [None]

login issue

I am really sorry for posting this, i know there are a few posts regarding the same issue. but i am new to this and i really dont understand how you fix this problem. could someone give me some specific instructions to fixing this?
this is my code: my two factor authentication is off

import pandas as pd, numpy as np
import os
import time
import robin_stocks as r
import matplotlib.pyplot as plt
import datetime as dt

username='[email protected]'
password='*******'

login= r.login(username,password)

print ('done')

this is the error message:
400 Client Error: Bad Request for url: https://api.robinhood.com/oauth2/token/
Traceback (most recent call last):
File "C:\Users\HoneyMochi\Desktop\stock\stock 1.py", line 31, in
login= r.login(username,password)
File "C:\Python37\lib\site-packages\robin_stocks\authentication.py", line 61, in login
token = 'Bearer {}'.format(data['access_token'])
TypeError: 'NoneType' object is not subscriptable

also , i get a text message that gives me a robinhood code everytime i run this script
so please, anyone, help me. i apologize again for the inconvenience.

Issue with newest example - trying to use a different function, but need help with proper inputs

`import robin_stocks as r
import os
import datetime
import time as t

'''
This is an example script that will print out options data every 10 seconds for 1 minute.
It also saves the data to a txt file. The txt file is saved in the same directory as this code.
'''

#!!! Fill out username and password
username = ''
password = ''
#!!!

login = r.login(username,password)

#!!! fill out the specific option information
strike = 150.0
date = "2019-06-21"
stock = "V"
optionType = "call" #or "put"
#!!!

File saving variables

minutesToTrack = 1 #in minutes
PrintInterval = 10 #in seconds
endTime = t.time() + 60 * minutesToTrack
fileName = "options.txt"
writeType = "w" #or enter "a" to have it continuously append every time script is run

os.chdir(os.path.dirname(file))
path = os.getcwd()
filename = os.path.join(path,fileName)
fileStream = open(filename,mode=writeType)

while t.time() < endTime:
time = str(datetime.datetime.now())
#Both write and print the data so that you can view it as it runs.
fileStream.write("\n")
fileStream.write(time)
print(time)
#Get the data
instrument_Data = r.get_option_instrument_data(stock,date,strike,optionType)
market_Data = r.get_option_market_data(stock,date,strike,optionType)

fileStream.write("\n")
fileStream.write("{} Instrument Data {}".format("="*30,"="*30))
print("{} Instrument Data {}".format("="*30,"="*30))
#Instrument_Data is a dictionary, and the key/value pairs can be accessed with .items()
for key, value in instrument_Data.items():
    fileStream.write("\n")
    fileStream.write("key: {:<25} value: {}".format(key,value))
    print("key: {:<25} value: {}".format(key,value))

fileStream.write("\n")
fileStream.write("{} Market Data {}".format("="*30,"="*30))
print("{} Market Data {}".format("="*30,"="*30))

for key, value in market_Data.items():
    fileStream.write("\n")
    fileStream.write("key: {:<25} value: {}".format(key,value))
    print("key: {:<25} value: {}".format(key,value))

t.sleep(PrintInterval)

#make sure to close the file stream when you are done with it.
fileStream.close()`


I am getting an error while trying to use a different function for options data.

I get this error:

Traceback (most recent call last):
File "C:\Users\Username\Desktop\Python\Version 2.1.py", line 63, in
for key, value in OptData.item():
AttributeError: 'list' object has no attribute 'item'

I am using the function,
'#Get the data
OptData = r.find_options_for_stock_by_expiration(symbol, expirationDate, optionType, info)

fileStream.write('\n')

fileStream.write("{} OptData".format("="*30,"="*30))
print("{} OptData {}".format("="*30,"="*30))
#OptData is a dictionary, and the key/value pairs can be accessed with .items()
## for key, value in OptData.items():
for key, value in OptData.items():
    item(['chain_symbol'])'

when I try to print it though, I'm missing something in the code and it is giving me this error. Some direction would be greatly appreciated. I tried to just replace what you had input with what I'm trying to get, the line I get the error on is: item(['chain_symbol'])'

[bug] stopPrice should compare to the last regular hour price (instead of extended hour price)

in func order_buy_stop_limit(), on line:

latestPrice = helper.round_price(stocks.get_latest_price(symbol)[0])

latestPrice = helper.round_price(stocks.get_latest_price(symbol)[0])
this returns the extended hour price.
and then it's used on line 328:
print('Error: stopPrice must be above the current price.')

if (latestPrice > stopPrice):

When user calls this function during off-hours (e.g. at night for the next morning's order), it's comparing with the extended hour price, and the order will not be placed because of this client side check; but the user can actually place such order (as long as stopPrice > the_last_regular_hour_price) on the Robinhood website.

We should either refine this client side check to allow such order be placed, or we should remove this check and rely on the Robinhood server side check.

Same problem on order_buy_stop_loss() line 269 and 275

latestPrice = helper.round_price(stocks.get_latest_price(symbol)[0])

if (latestPrice > stopPrice):

login with recieving text message after

I am attempting to gain access to my Robinhood stock information through
The robin stocks API python library. Currently, I am receiving the error:

400 Client Error: Bad Request for URL:
https://api.robinhood.com/oauth2/token/
import robin_stocks as r
username = '[email protected]'
password = '*****************'
login = r.login(username, password)
My user name is my email, and the password I am using is the
same to log into the website. I also get a text message whenever I run my
script stating a token which is valid for 5 minutes.

API to trade options

I'd like to have ability to buy/sell options using this API. You mentioned that you are working on such capability #3. Are you close to getting it working? I'd like to help if you can give me pointers. Though I'm new to REST API and Robinhood API, I'm a software engineer so I think I can help if you want.

Also, thanks for great software!

400 Client Error

Hey Joshua,

Excellent work with the robin_stocks project!

I've been working on a program for about a week and a half and have been able to execute orders. However, in the last two days when I am placing market orders, I am running into a "400 Client Error: Bad Request for url" (Stop loss and limit still work). I have tried many different stocks, and I can still order from the app. Also from the start, I have been getting that error when trying to check day trades.

I was wondering if you ever ran into this problem, or if you have any ideas to solve it.

Thanks!

KeyError on previously available keys

KeyError on using previous option functions for option greeks, volume, open_interest, etc.

KeyError on item['delta'] was the first error I've gotten on this, and it carries over into several other functions having no or limited option data compared to using this just a week ago.

login fail

Jmfernandes here.

deleted your post cause it had your username and password

options.get_all_option_positions() returns exactly twice the amount expected

The robin_stocks.options.get_all_option_positions() request seems to return twice the number that it is supposed to. I joined it together with the instrument data to get a better picture and it appears to have an exact duplicate for each option in the response. Any ideas on why it might return the same option twice?

Getting open option positions details

First of all, awesome code and amazingly useful! Perhaps I missed it, but utilizing get_open_option_positions for current open option positions seems to return the correct option chains, but I didn't notice the strike price of the options being returned. Is there somewhere that this is available based on current open positions?

Order Sell Stop Loss: Error - stopPrice must be above the current price

Placing r.order_sell_stop_loss with a stop price lower than current market price creates the following error:
Error: stopPrice must be above the current price

To recreate error :
ZNGA Current price is $5.58

r.order_sell_stop_loss(symbol='ZNGA', quantity= 1, stopPrice= 5.25, timeInForce='gtc')

Here is stop order definition from Robinhood to make sure there is no confusion:

A stop order is an order type that triggers a market order to buy or sell when the stock reaches your designated stop price. For example, if XYZ stock is trading at $25, you can place a sell stop order at $20 to trigger a market sell order in the event the stock reaches $20 or lower.

Given this the stop price should below the current market price not above,

The code appears to be the same for order_sell_stop_limit which should also use a stop price lower than current market price.

Missing function for viewing crypto holdings

I can't seem to find the method for requesting crypto holdings or USD valuations of crypto holdings. I've tried ever method available, but none return crypto. Am I missing something?

Wrong total money invested

I kept getting wrong total money invested until I realized I have a canceled transaction. In case anyone has the same issue, just modify the deposit and withdrawal definition to make sure they are "completed". For example:

deposits = sum(float(x['amount']) for x in allTransactions if (x['direction'] == 'deposit') and (x['state'] == 'completed'))
withdrawals = sum(float(x['amount']) for x in allTransactions if (x['direction'] == 'withdraw') and (x['state'] == 'completed'))

deposits = sum(float(x['amount']) for x in allTransactions if x['direction'] == 'deposit')

issue with build_holdings method

Hi,
I am getting the following error while trying to use "build_holdings()" methods

Traceback (most recent call last):
File "a.py", line 6, in
my_stocks = robin_stocks.build_holdings()
File "/usr/local/lib/python3.5/dist-packages/robin_stocks/helper.py", line 20, in login_wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.5/dist-packages/robin_stocks/account.py", line 490, in build_holdings
holdings[symbol].update({'name': stocks.get_name_by_symbol(symbol)})
File "/usr/local/lib/python3.5/dist-packages/robin_stocks/stocks.py", line 139, in get_name_by_symbol
if not data['simple_name']:
TypeError: 'NoneType' object is not subscriptable

My code is simple:
import robin_stocks
robin_stocks.login('xxxxxx','xxx')
my_stocks = robin_stocks.build_holdings()
print (my_stocks)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.