Data Driven Money

Live. Work. Retire. Smart.

Resources for Using Python with Robinhood

In this blog post I’ve consolidated several resources to get you on your way with using Python to trade at Robinhood through the ‘Robinhood API’ (more to follow on that topic). Robinhood’s democratization of investing for small time investors has been a great boon for bringing complex investing tools to the masses.

Being able to trade using algorithms, Machine Learning (ML) and Artificial Intelligence (AI) is the next big step towards unleashing the full potential of the Stock Market to Individuals… just keep in mind that being successful using these tools will still requires a considerable amount of work.

There are no shortcuts, but these resources should get you well on your way to getting to where you want to go.

Python Developer Trading Stocks

In this Article

Trading Stocks at Robinhood with Python Tutorial

Trading stocks using python requires a few things to be set up with your account that aren’t typical. First you will need to be able to generate a key thereby utilizing Multi-Factor Authentication. Then you can pass your normal credentials via Robinhood remotely.

I cover all these topics in the article, ‘How to Use Python to Trade Stocks at Robinhood.’ I give you all the code necessary and use a free instance of Google Colab to conduct several trades with just a few lines of python code. This is a basic proof primer… it will show you that it is possible and exceptionally easy.

Robinhood API Resources

An API allows you to pragmatically interact with a service or website. Robinhood doesn’t have an official API… but that doesn’t mean that others haven’t found a way to engineer something that acts as an API on their behalf. Here are several resources to get you started:

  • Robinhood API – Complete Guide – This guide walks you through how to use the robin_stocks python library which is a solid choice to interface with your account and make trades through python.

  • Github of Unofficial Documentation of Robinhood Trade’s Private APIThis is an incredibly intriguing resource of information. Up until late 2020 this coder was providing this resource free for the opensource community. He ended up stopping due to being tracked and stalked by random people on the internet. Despite that, the work he had completed up and unto that point is still excellent and is great background if you are a developer.

Robinhood Python Libraries

I will keep this section updated as more python libraries become available but there are only two worth mentioning. Many python libraries are out of date and will no longer be able to even get you past authentication much less trading. As mentioned above, Robinhood’s API isn’t necessarily public so a lot of work goes into trying to understand software and configuration changes Robinhood makes periodically.

Robin_stocks – Available from pypi, Robin_stocks is a library that, ‘provides a pure python interface to interact with the Rboinhood API, Gemini API, and TD Ameritrade API.’

This is the package that I personally use to conduct trades when needed. The added bonus is the additional trading platforms that are available as well. At time of publication, the package seemed well updated and functional.

Fast_arrow – Also available through pypi, this package combined with fast_arrow_auth will enable you to conduct similar trading activity as with Robin_stocks. This package is not updated as much but still functions… but for how long is up in the air.

Algorithmic and ML Trading Resources

Assuming that the reason for using Python in the first place to conduct trades with Robinhood is to in turn be using some type of algorithmic trading methodology I have included some appropriate resources of varying media types.

These sources are valid for any type of ML / AI implementation using Python… not just for Robinhood.

Additionally, you may want to consider using a data source independent of Robinhood (sources below) since pricing data can be slow and somewhat limited to the spot price anyway when using only Robinhood.

  • Machine Learning for Algorithmic Trading (Book, 2nd Edition) – I consider this book the holy grail for quickly considering numerous trading methodologies using python. Code is provided that is easily modifiable for your own purposes. The models presented are not simple or easy… if you want the whole kit’n kaboodle then this it.

  • Financial Data Sources for Machine Learning and Trading Algorithms (Blog Post)I wrote this article to go over the numerous ways to pull in accurate and timely date. To build your models, especially with ML and AI, you will need to train them. Training requires data. Additionally, for purely algorithmic trades you will want to conduct backtesting… these data sources will get you what you need. Both free and paid sources are available.

  • Jacob Amaral’s Youtube Channel – This channel only has 20k subscribers at the time of writing, however the quality is pretty high in terms of thought and usable resources. All his videos that show code have accompanying GitHub repositories. His channel covers various approaches around Machine Learning and also shows how he used Robinhood at one point specifically to conduct trades.

Information You Should Know about Robinhood

Robinhood really took a foothold in the retail investor world in early 2020. After several meme stock fiascos the press (including testimony before Congress) hasn’t been kind to how Robinhood conducts business. Here are several resources to learn more about what that may mean for your trading activity… using python or otherwise

  • How 0% Commission Brokers Make MoneyRobinhood’s claim to fame is that they don’t charge a commission. They are a 0% Commission Broker. Understanding how their business model works is important to ensure that whatever trading system you implement on the platform makes sense for you.

  • Possible Risks if Trading is Halted (YouTube) – Back in 2020, Robinhood halting trading during historic volatility. What would happen if you were suddenly unable to exit out of a trade? This video details the CEO’s explanation of what and how that happened.

  • Is Robinhood safe? Experts weigh in on using the commission-free investing app (Article) – This is a good overview of some of the basic risks using Robinhood may present to your trading endeavors. The risks are not 0… they aren’t catastrophic either. But they do exist.

A Word of Caution

Trading using python code is important next step if you are looking to implement various statistical methods to gain an edge. Just keep in mind that a program will do whatever you tell it to do… if even you didn’t mean to.

This could mean large losses if you mess up either the coding, the intellectual due diligence required of a successful algorithm, or even if market conditions change unexpectedly. Make sure you build in fail-safes and monitor what your program is doing in real time.

All that said, I don’t make recommendations. This article is an expression of my opinion, and you should consider hiring a professional if you are looking for advice on how to spend or invest your money.

Wrapping Things Up

I will keep this page updated regularly. I go through a lot of content on this subject and much of it is not of high quality… I’ll keep the junk from making it here. As a result, the number of resources initially may seem small. Bookmark this page and just keep in mind that the consequence of implementing bad ideas on this front can be devastating.

Trading via Robinhood with Python using Machine Learning and AI is an exciting way to cut your teeth in a discipline that has largely been something reserved for large institutions. I hope you enjoyed this article and if you have any resources, that you think I should add then throw them down in the comments below.

Guy Money

As a formally trained Data Scientist I find excitement in writing about Personal Finance and how to view it through a lens filtered by data. I am excited about helping others build financial moats while at the same time helping to make the world a more livable and friendly place.

Leave a Reply

Your email address will not be published. Required fields are marked *

Scroll to top