Created
May 3, 2018 05:43
-
-
Save amitkot/ec9a353da57041aed5cc525f3a35fe36 to your computer and use it in GitHub Desktop.
testing ccxt huobi rate limits
This file contains hidden or 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
import asyncio | |
import time | |
import ccxt.async as ccxt | |
def minutes_ago_in_millis_since_epoch(minutes): | |
return int(round(time.time() * 1_000)) - 60_000 * minutes | |
async def async_main(): | |
huobi = ccxt.huobipro({ | |
'enableRateLimit': True, # this option enables the built-in rate limiter | |
}) | |
huobi_markets = await huobi.fetch_markets() | |
print(huobi_markets) | |
data = { | |
# key: await huobi.fetch_trades(key, limit=None, since=minutes_ago_in_millis_since_epoch(1)) | |
key: huobi.fetch_trades(key, limit=1) | |
for key in [market['symbol'] for market in huobi_markets[:15]] | |
} | |
results = await asyncio.gather(*data.values()) | |
a = dict(zip(data.keys(), results)) | |
print(a) | |
# print({ | |
# key: trades.result() | |
# for key, trades in data.items() | |
# }) | |
await huobi.close() | |
if __name__ == '__main__': | |
loop = asyncio.get_event_loop() | |
loop.run_until_complete(async_main()) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment