-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added examples/py/bitfinex-rate-limiting.py fix ccxt#3738
- Loading branch information
Showing
1 changed file
with
38 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
# -*- coding: utf-8 -*- | ||
|
||
from pprint import pprint | ||
|
||
import os | ||
import sys | ||
|
||
root = os.path.dirname(os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) | ||
sys.path.append(root + '/python') | ||
|
||
import ccxt # noqa: E402 | ||
|
||
|
||
symbol = 'ETH/BTC' | ||
|
||
exchange = ccxt.bitfinex({ | ||
|
||
'enableRateLimit': True, # or .enableRateLimit = True later | ||
|
||
# BITFINEX RATELIMITS DON'T CORRESPOND TO THEIR DOCUMENTATION! | ||
|
||
# their actual rate limit is significantly more strict than documented! | ||
'rateLimit': 3000, # once every 3 seconds, 20 times per minute – will work | ||
|
||
# this is their documented ratelimit according to this page: | ||
# https://docs.bitfinex.com/v1/reference#rest-public-orderbook | ||
# 'rateLimit': 1000, # once every second, 60 times per minute – won't work, will throw DDoSProtection | ||
}) | ||
|
||
for i in range(0, 100): | ||
print('--------------------------------------------------------------------') | ||
print(i) | ||
print('sent:', exchange.iso8601(exchange.milliseconds())) | ||
orderbook = exchange.fetch_order_book(symbol) | ||
print('received:', | ||
exchange.iso8601(exchange.milliseconds()), | ||
'bid:', orderbook['bids'][0], | ||
'ask:', orderbook['asks'][0]) |