def assert_types(res): map_types = { "id": int, "name": str, "symbol": str, "rank": int, "quotes": dict, "website_slug": str, "circulating_supply": (float, int, type(None)), "total_supply": (float, int, type(None)), "max_supply": (float, int, type(None)), "last_updated": (int, type(None)) } quotes_map_types = { "market_cap": (float, int, type(None)), "percent_change_1h": (float, type(None)), "percent_change_24h": (float, type(None)), "percent_change_7d": (float, type(None)), "price": (float, type(None)), "volume_24h": (float, type(None)), } assert isinstance(res, dict) for key, value in res.items(): if key == "quotes": for _key, _value in value.items(): for __key, __value in _value.items(): type_test(quotes_map_types, __key, __value) type_test(map_types, key, value)
def assert_types(res): """Type assertions for ``exchange()`` methods attribute.""" map_types = { "currency": str, "pair": str, "volume_24h": (float, type(None)), "price": float, "percent_volume": float, "updated": bool, "name": str, "slug": str } assert isinstance(res, dict) assert isinstance(res["name"], str) assert isinstance(res["web"], (str, type(None))) assert isinstance(res["volume"], (float, type(None))) assert isinstance(res["social"], dict) for key, fields in res["social"].items(): assert isinstance(key, str) for field, data in fields.items(): assert isinstance(field, str) assert isinstance(data, (str, type(None))) for market in res["markets"]: assert isinstance(market, dict) for key, value in market.items(): type_test(map_types, key, value)
def assert_types(res): map_types = { "id": str, "name": str, "symbol": str, "rank": int, "price_usd": (float, type(None)), "price_btc": (float, type(None)), "24h_volume_usd": (float, type(None)), "market_cap_usd": (float, int, type(None)), "available_supply": (float, int, type(None)), "total_supply": (float, int, type(None)), "max_supply": (float, int, type(None)), "percent_change_1h": (float, type(None)), "percent_change_24h": (float, type(None)), "percent_change_7d": (float, type(None)), "last_updated": (int, type(None)) } assert isinstance(res, (list, dict)) for key, value in res.items(): if key in map_types: type_test(map_types, key, value) else: assert isinstance(value, (float, int, type(None)))
def assert_types(data): map_types = { "name": str, "symbol": str, "platform": (str, type(None)), "market_cap": (float, type(None)), "price": (float, type(None)), "circulating_supply": (float, type(None)), "volume_24h": (float, type(None)) } for currency in data: for key, value in currency.items(): type_test(map_types, key, value)
def assert_types(res): map_types = { "name": str, "symbol": str, "added": str, "market_cap": str, "price": str, "circulating_supply": str, "volume_24h": str, "percent_change": str } assert isinstance(res, list) for currency in res: assert isinstance(currency, dict) for key, value in currency.items(): type_test(map_types, key, value)
def assert_types(res): map_types = { "source": str, "pair": str, "volume_24h": float, "price": float, "percent_volume": float, "updated": bool, } assert isinstance(res["markets"], list) assert isinstance(res["symbol"], str) assert isinstance(res["slug"], str) for source in res["markets"]: assert isinstance(source, dict) for key, value in source.items(): type_test(map_types, key, value)
def assert_types(res): map_types = { "name": str, "web": str, "pair": str, "volume": (float, type(None)), "price": float, "percent_volume": float } assert isinstance(res, list) for exc in res: assert isinstance(exc, dict) assert isinstance(exc["name"], str) assert isinstance(exc["markets"], list) for market in exc["markets"]: for key, value in market.items(): type_test(map_types, key, value)
def assert_types(res): map_types = { "source": str, "pair": str, "volume_24h": float, "price": float, "percent_volume": float, "updated": bool, "markets": list, "symbol": str, "website_slug": str, "id": int } for source in res["markets"]: assert isinstance(source, dict) for key, value in source.items(): type_test(map_types, key, value)
def assert_types(res): map_types = { "date": datetime, "open": float, "high": float, "low": float, "close": (float, type(None)), "volume": (float, type(None)), "market_cap": (float, type(None)), "name": str } assert isinstance(res["history"], list) assert isinstance(res["symbol"], str) assert isinstance(res["slug"], str) for tick in res["history"]: assert isinstance(tick, dict) for key, value in tick.items(): type_test(map_types, key, value)
def assert_types(data): map_types = { "name": str, "symbol": str, "volume_24h": float, "price": float, "percent_change": float, } assert isinstance(data, dict) for rank, rdata in data.items(): assert isinstance(rank, str) assert isinstance(rdata, dict) for period, pdata in rdata.items(): assert isinstance(period, str) assert isinstance(pdata, list) for currency in pdata: assert isinstance(currency, dict) for key, value in currency.items(): type_test(map_types, key, value)
def assert_types(res): map_types = { "symbol": str, "slug": str, "source_code": (str, type(None)), "announcement": (str, type(None)), "explorers": list, "markets_volume_24h": (float, type(None)), "price": (float, type(None)), "rank": int, "markets_cap": (float, type(None)), "chats": list, "message_boards": list, "circulating_supply": (float, type(None)), "total_supply": (float, type(None)), "max_supply": (float, type(None)), "mineable": bool, "webs": list, "name": str } assert isinstance(res, dict) for key, value in res.items(): type_test(map_types, key, value)
def assert_types(res, convert=None): map_types = { "active_cryptocurrencies": int, "active_markets": int, "bitcoin_percentage_of_market_cap": float, "quotes": dict, "last_updated": int, } quotes_map_types = {"total_market_cap": float, "total_volume_24h": float} assert isinstance(res, dict) for key, value in res.items(): type_test(map_types, key, value) for key, value in res["quotes"]["USD"].items(): type_test(quotes_map_types, key, value) if convert: for key, value in res["quotes"][convert].items(): type_test(quotes_map_types, key, value)