Ethereum
$310.77 0.80%
ETH · 23w

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: github.com/bitfinexcom/bitfinex-api-py.

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) @bfx.ws.on('order_book_update')def log_update(data): print ("Book update: {}".format(data)) @bfx.ws.on('connected')async def start(): await bfx.ws.subscribe('book', 'tBTCUSD') bfx.ws.run()

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 medium.com
Recent news
ETH +0.80% · ccn.com · 1h

ETH could soar to $900

Analysts are predicting that Ethereum will skyrocket soon. Some reasons include bitcoin's rally, similarily to the 2017 ETH chart, and lack of a resistance.
ETH +0.80% · blog.bounty0x.io · 4h

Bi-Weekly Bounty0x Update — June 21, 2019

To be well positioned for the continued growth and adoption for cryptocurrencies, we have been very hard at work (as always) for the past 2 weeks. This update aims to summarize some of that work that…
ETH +0.80% · blog.district0x.io · 5h

district0x Dev Update - June 25th, 2019

Much of the past development cycle for district0x has been spent upgrading and rehabilitating Meme Factory as we address unforeseen issues with our production instance and its IPFS integration. In…
ETH +0.80% · discourse.foam.space · 5h

FOAM Map Release: Uniswap, Front-end and back-end updates

Hello FOAM community members some of you may have noticed already some updates to the FOAM map. This is because we are excited to announce the new release of the Map. The bulk of this release covers b...
ETH +0.80% · financemagnates.com · 8h

JPMorgan considering tokenized bonds

JP Morgan Chase is considering to start the trial of its much anticipated JPM Coin with its corporate customers, according to a Bloomberg Japan report.
ETH +0.80% · medium.com · 8h

Exploring Non-Fungible Tokens

Since the Crypto Kitties craze in 2017, Non-Fungible Tokens (NFTs) have gained a substantial amount of popularity within the crypto community. For those unfamiliar, NFTs are a special type of…
ETH +0.80% · bloomberg.co.jp · 10h

JPMorgan to Start Customer Trials of Its ‘JPM Coin’ Crypto -- Bloomberg Japan

米銀最大手のJPモルガン・チェースは、早ければ今年中にも同社が開発したデジタル通貨「JPMコイン」について、数社の法人顧客に対し試験çš...
ETH +0.80% · ethereumprice.org · 13h

Libra Vs Ethereum - Should ETH Holders Be Worried?

The Libra whitepaper was released on June 18th 2019 by the newly formed Libra Association – a collective of finance and technology firms who will serve as validators on the network. Originally spearhe...
ETH +0.80% · cryptoninjas.net · 14h

2019: Top Three Cryptocurrency Exchanges and Why

With over 2200 tokens in circulation, a market cap approaching $300 billion, and $60 - $70 million in daily volume, the cryptocurrency market is a force to be reckoned with. Additionally, the digital ...
17