$123.39 0.68%
ETH · 6d

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.68% · · 13h

2018: A Year In Review - Keep Network

Everyone here at Keep hopes your holidays were fantastic and you got the chance to unplug and relax. While wrapping up 2018, we took a moment to reflect upon and appreciate our past year’s work and…
ETH +0.68% · · 16h

Ether Chain Splits!

Ethereum is currently undergoing a chain-split after a planned upgrade was called off at the very last minute. “We were not able to get in contact with every single mining...
ETH +0.68% · · 17h

How Smart Regulation Will Change the World

Cryptocurrencies were originally thought of as decentralized networks run by anti-government libertarians that were constantly at odds with regulatory agencies. Ironically, blockchain technology is…