Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Python async: Bitfinex connector returns empty order book, others work fine #2086

Closed
UnitNote opened this issue Feb 28, 2018 · 3 comments
Closed
Assignees

Comments

@UnitNote
Copy link

Consider the following mini-program:

import ccxt.async as ccxt
import asyncio

bitfinex = ccxt.bitfinex()
poloniex = ccxt.poloniex()
for exchange in (bitfinex, poloniex):
    exchange.verbose = True

async def get_book(exchange, symbol):
    result = await exchange.fetch_order_book(symbol)
    return result

async def get_data_directly(exchange):
    result = await get_book(exchange, 'ETH/BTC')
    print(result)

loop = asyncio.get_event_loop()

Running get_data_directly with either bitfinex or poloniex should print the order book. But that's not what happens.
Running it with poloniex works fine:

>>> loop.run_until_complete(get_data_directly(poloniex))

Request: GET https://poloniex.com/public?command=returnOrderBook&currencyPair=BTC_ETH {'User-Agent': 'python-requests/2.18.4', 'Accept-Encoding': 'gzip, deflate'} None

Response: GET https://poloniex.com/public?command=returnOrderBook&currencyPair=BTC_ETH 200 <CIMultiDictProxy('Date': 'Wed, 28 Feb 2018 08:22:35 GMT', 'Content-Type': 'application/json', 'Transfer-Encoding': 'chunked', 'Connection': 'keep-alive', 'Access-Control-Allow-Origin': '*', 'Access-Control-Allow-Methods': 'GET', 'Content-Encoding': 'gzip', 'Expect-CT': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', 'Server': 'cloudflare', 'CF-RAY': '3f41fa0e9a001798-SIN')> 

{"asks":[["0.08136930",4],["0.08136997",3.08290226],["0.08138340",0.12599382],["0.08140007",0.37714999],["0.08140597",129.17701955],["0.08140598",75.835],["0.08140600",11.4139],["0.08141055",73.81301107],["0.08143130",0.00228914],["0.08145754",0.0030698],["0.08146258",3.739],["0.08149999",0.00124198]

(poloniex orderbook truncated for display purposes)

However running it with bitfinex results in an empty order book:

>>> loop.run_until_complete(get_data_directly(bitfinex))

Request: GET https://api.bitfinex.com/v1/book/ETHBTC?limit_bids=None&limit_asks=None {'User-Agent': 'python-requests/2.18.4', 'Accept-Encoding': 'gzip, deflate'} None

Response: GET https://api.bitfinex.com/v1/book/ETHBTC?limit_bids=None&limit_asks=None 200 <CIMultiDictProxy('Date': 'Wed, 28 Feb 2018 08:22:25 GMT', 'Content-Type': 'application/json; charset=utf-8', 'Content-Length': '21', 'Connection': 'keep-alive', 'X-Frame-Options': 'SAMEORIGIN', 'X-XSS-Protection': '1; mode=block', 'X-Content-Type-Options': 'nosniff', 'ETag': 'W/"0036d08cbce146de126d93d51f91c968"', 'Cache-Control': 'max-age=0, private, must-revalidate', 'X-Request-Id': 'f2faa7a6-3a3d-43b9-9a53-fc8a322e1cff', 'X-Runtime': '0.002434', 'Strict-Transport-Security': 'max-age=31536000', 'X-Frame-Options': 'SAMEORIGIN', 'Expect-CT': 'max-age=604800, report-uri="https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct"', 'Server': 'cloudflare', 'CF-RAY': '3f41f9d81c066f96-SIN')> {"bids":[],"asks":[]}

{'bids': [], 'asks': [], 'timestamp': 1519806145693, 'datetime': '2018-02-28T08:22:26.693Z'}
  • OS: MacOS
  • Programming Language version: Python 3.6.2 (default, Sep 24 2017, 23:37:10)
    [GCC 4.2.1 Compatible Apple LLVM 8.1.0 (clang-802.0.42)] on darwin
  • CCXT version: Version: 1.10.1237
  • Exchange: bitfinex
  • Method: fetch_order_book()
@kroitor kroitor self-assigned this Feb 28, 2018
@UnitNote
Copy link
Author

Wow that was fast.

@kroitor
Copy link
Member

kroitor commented Feb 28, 2018

@UnitNote thanks for your thorough report! Try ccxt 1.10.1254, it should work now. Let us know if you still have difficulties with it. Thx again!

@UnitNote
Copy link
Author

No problem. Confirmed working with the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants