#!/usr/bin/env python
# coding: utf-8
# #
Asynchronous Pymarketcap Interface
# > See also: [Synchronous Pymarketcap Interface](sync_live.ipynb)
# ## Asynchronous Pymarketcap
# The asynchronous interface includes other methods than synchronous interface, involving every single possible value passed to a method:
# - `every_currency()`
# - `every_markets()`
# - `every_historical()`
# - `every_exchange()`
# - `graphs.every_currency()`
# In[3]:
from pymarketcap import AsyncPymarketcap as AsyncPym
import asyncio
loop = asyncio.get_event_loop()
apym = AsyncPym()
print(apym.__doc__)
# You can access to a synchronous `Pymarketcap` instance with:
# In[4]:
apym.sync.listings()
# This interface stores in memory large amounts of data in the process of data retrieving. You can control the number of consumers and producers working simultaneously with the parameters `queue_size` and `consumers` (by default both are `10`):
# #### `every_currency([currencies=None, convert="USD"])`
# As default, gives you general data from all currencies in coinmarketcap.
# In[3]:
async def get_all_currencies():
async with AsyncPym() as apym:
async for currency in apym.every_currency():
print(currency)
loop.run_until_complete(get_all_currencies())
# You can pass a list of currencies as first parameter for limit searchs.
# In[1]:
async def get_some_currencies(currencies):
async with AsyncPym() as apym:
async for currency in apym.every_currency(currencies=currencies):
print(currency)
loop.run_until_complete(get_some_currencies(["BTC", "ETH", "steem", "lisk", 1, 2]))
# #### `every_markets([currencies=None, convert="USD"])`
# As default, gives you markets data from every currency in coinmarketcap.
# In[5]:
async def get_some_currency_markets(currencies):
async with AsyncPym() as apym:
async for currency in apym.every_markets(currencies=currencies):
print(currency)
loop.run_until_complete(get_some_currency_markets(["BTC", "ETH", "steem", "lisk"]))
# #### `every_historical([currencies=None, convert="USD"])`
# As default, gives you historical data from every currency in coinmarketcap.
# In[6]:
async def get_some_currency_historical(currencies):
async with AsyncPym() as apym:
async for currency in apym.every_historical(currencies=currencies):
print(currency)
loop.run_until_complete(get_some_currency_historical(["BTC", "ETH", "steem", "lisk"]))
# #### `every_exchange([exchanges=None, convert="USD"])`
# As default, gives you general data from every exchange in coinmarketcap.
# In[7]:
async def get_every_exchange():
async with AsyncPym() as apym:
async for currency in apym.every_exchange():
print(currency)
loop.run_until_complete(get_every_exchange())
# #### `graphs.every_currency([currencies=None, convert="USD"])`
# As default, gives you graphs data from every currency in coinmarketcap.
# In[8]:
async def get_every_graphs_currency():
async with AsyncPym() as apym:
async for currency in apym.graphs.every_currency():
print(currency)
loop.run_until_complete(get_every_graphs_currency())