How to Easily Fetch Bitfinex Historical Trades Using Python

Create a reliable script to extract historical trade data from Bitfinex

Thiago Candido
The Startup

--

Photo by Jason Briscoe on Unsplash

Note: this article is provided for entertainment and educational purposes only and is not intended as financial advice.

As an ex-CTO of a cryptocurrency exchange, I had my fair share of messing around with several major exchanges’ APIs. In this article, I will guide you through the process of creating a reliable Python script to extract historical trade data from Bitfinex.

I will spare you the algotrading/backtesting intro since you can read my previous story on this subject, which talks about how you can extract historical trade data from Binance and get right into the code. You can also find that more related stories on my profile.

What We’ll Be Coding

We will create a Python script that receives as command-line arguments the pair symbol, a starting date, and an ending date. It will output to disk a CSV file containing all the trades. The following steps can detail the process:

  • Parse symbol, starting_date, and ending_datearguments.
  • Fetch the first trade that happened on the starting date to get the first trade_id.
  • Loop fetching 10,000…

--

--

Thiago Candido
The Startup

I help people to use their products and services data intelligently @eximiaco