$222.53 -1.30%
ETH · 27w

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 -1.30% · · 7h

Augur App Release v1.15.1

Augur App Release v1.15.1🐛 Fixed category bug where they disappear— Augur (@AugurProject) July 19, 2019
ETH -1.30% · · 7h

Facebook's Fake Money — Libra Is "A Fiat-Money Clone"

Starting in 2020, Facebook wants to offer its customers a global high-tech currency and infrastructure. The US IT giant says that this will provide many people around the world with easy and cost-effe...
ETH -1.30% · · 17h

Build the future with Ethereum.

For more info + free access to our Blockchain Job Kit, visit: #web3ishere #dontgetleftbehind #buildthefuture And...