DEV Community

Cover image for 8 Best Python Libraries for Algorithmic Trading

8 Best Python Libraries for Algorithmic Trading

sewinter profile image Sam Winter Originally published at ・4 min read

Even as someone with significant experience in software engineering and some knowledge of data science, I underwent a learning curve when I started algorithmic trading. Feeling productive took some time. I found myself writing my own Bollinger bands, or scouring for trading calendars, or using each cryptocurrency exchange's idiosyncratic APIs instead of an abstraction over all of them. These are the Python libraries I wish I'd known when I began chasing alpha. They'll help you make money faster.

1. FinTA

FinTA (Financial Technical Analysis) implements over eighty trading indicators in Pandas. Unlike many other trading libraries, which try to do a bit of everything, FinTA only ingests dataframes and spits out trading indicators. Even the comments above each method are instructive, e.g., this comment annotating MACD. You'll likely see some indicators you don't even recognize, and the breadth of technical analysis encourages experimentation.

2. Zipline

Zipline is the best of the generalist trading libraries. It has almost 13k stars (see my article on using data to evaluate software packages here) and powers Quantopian, one of the most popular quant-finance communities, at least until Robinhood recently acquired it. Zipline allows you to ingest data from the command line (or a Jupyter notebook) and comes built-in with methods to facilitate writing complex strategies and backtesting them.


CCXT (CryptoCurrency eXchange Trading) is a lifesaver if you programmatically trade cryptocurrency. No more will you have to write custom logic for each exchange. CCXT abstracts away differences between individual exchange APIs with a unified interface. It supports more than 120 exchanges. If you're not a Pythonist, you can even use the JavaScript and PHP implementations of CCXT (though you should get better taste in programming languages).

4. Freqtrade

Freqtrade is another crypto trading library that supports many exchanges. It facilitates backtesting, plotting, machine learning, performance status, reports, etc. You might be sighing at this point. How many cryptocurrency trading libraries does one algorithmic trading enthusiast need? What's amazing about Freqtrade is that you can control it with Telegram. That's right: you can henceforth DM your robot investment manager. Here are some of its awesome Telegram commands:

  • /status [table]: lists all open trades;
  • /profit: lists cumulative profit;
  • /forcesell <trade_id>|all: sells the given trade;
  • /performance: performance of each finished trade grouped by pair;
  • /balance: account balance per currency;
  • /daily <n>: profit or loss per day, over the last n days.

If you want to power up your Freqtrade trading bot and turn it into a Gundam ready to ravage financial markets on your behalf, check out Freqtrade Strategies, which is what its name suggests.

5. YFinance

If you've been trading for long, you've likely heard of Yahoo! Finance. YFinance allows you to reliably and efficiently download market data from Yahoo! Finance. The library arose from a dire need when Yahoo decommissioned their historical data API. The library's creator wrote a helpful tutorial here.

6. Backtrader

Backtrader is a popular Python framework for backtesting and trading that includes data feeds, resampling tools, trading calendars, etc. What sets Backtrader apart aside from its features and reliability is its active community and blog. Backtrader's community could fill a need given Quantopian's recent shutdown.

7. TensorTrade

TensorTrade is a framework for building trading algorithms that use deep reinforcement learning. It provides abstractions over numpy, pandas, gym, keras, and tensorflow to accelerate development. TensorTrade is still in beta, but it's quickly gaining traction and will likely become a mainstay in the quant community. Adam King, the creator of Tensor Trade, wrote an excellent tutorial.

8. Trump2Cash

I saved the memeiest library for last. Trump2Cash monitors Donald Trump's tweets. When he mentions publicly traded companies, it analyzes the tweet's sentiment and executes trades accordingly. The library even includes a utility to benchmark its historical performance. I'm not making any kind of recommendation, but the algorithm has been surprisingly successful.

Even supposing that Trump's ability to influence financial markets will soon wane, the source code is easily adaptable to other Twitter accounts. If you're interested in Twitter sentiment as a feature for a trading strategy, the repo is more than worth a look.

About Us

At Carrots we're building a hiring platform specifically for software engineers. You can connect your GitHub, Stack Overflow, and more to go beyond your resume. Our algorithm shows where you rank among world-class talent and surfaces your profile to top companies. Check out our Telegram channel for a live feed of developer jobs.


Editor guide
ricardo profile image
Ricardo Luz

Your article unites two things that I'm studying recently which is Python and trading; it's very motivating think that both studies together could bring to something bigger