$140.17 0.41%
ETH · 9w

Bitfinex releases new Python API client + tutorial

Tutorial: Creating and managing trades with the new Python client

Jan 10

We received really good feedback with our original NodeJS client and a lot of people requested a port to Python so they can continue to create advanced strategies on the Bitfinex platform in a language that is extremely friendly to data analytics.

The team at Bitfinex have been working on the bitfinex-api-py repo which can be found here:

The client is designed to make it easy to interact with both the REST and websocket interface.

The client handles all of the nasty parts that are associated with websockets such as subscriptions, authentication, confirmation callbacks and reconnecting when the connection is intermittent. The REST interface is as easy as ever to use, it exposes function calls such as get_active_orders() and then handles all of the authentication for you.

In this tutorial we will cover three basic examples such as subscribing to the order-book, sending an order and retrieving open orders. These examples will be a good place to start since it will show how to manage a subscription and also authenticated REST + websocket calls.

Subscribing to an order-book

Firstly we have to create an instance of the Bitfinex client. Since the order-books are public, we don’t need to worry about passing in any auth keys.

Once we have done this we can use Python decorators to call a function when a certain event occurs (for a full list of events that are available please see the github repo).

from bfxapi import Client bfx = Client( logLevel='INFO', manageOrderBooks=True)'order_book_update')def log_update(data): print ("Book update: {}".format(data))'connected')async def start(): await'book', 'tBTCUSD')

Here we listen to 2 different events — the order-book update event and the ‘connected’ event which is triggered when the connection is s...

Continue on
Recent news
ETH +0.41% · · 2h

Ethereum Trade Idea

Ethereum has been trading inside a channel in the last two weeks. With $140 upper resistance  line and $130 support line. Also, it is trad...
ETH +0.41% · · 4h

district0x Dev Update - March 19th, 2019

The past development cycle has seen the nearly entire district0x organization shift energy into testing and improving Meme Factory. The District Registry continues working towards a complete Aragon…
ETH +0.41% · · 8h

Why The Cryptocurrency Space Is Stronger Than Ever

It’s safe to say bitcoin is now a legitimate financial asset. The same can’t be said for all cryptocurrencies, which is why the volatility of the past year was a blessing for the cryptocurrency space.
ETH +0.41% · · 8h

HYGH STO. Tokio Hotel on blockchain

German teenagers decided to hustle on cheap outdoor advertising. The Kaulitz brothers, dead Colt, and a living member of the UBEX team as witnesses.   Remember the Tokio Hotel band? That band where th...