adicionada chamada 'exchange_volume_chart_by_id()'
This commit is contained in:
@ -1264,24 +1264,51 @@ def exchange_tickers_by_id(
|
||||
|
||||
|
||||
# debug (decomentar linhas seguintes para testar funcao)
|
||||
url, codigo, dados = exchange_tickers_by_id('binance', 'bitcoin,dogecoin')
|
||||
print(f'url: {url}')
|
||||
if codigo == 200:
|
||||
for item in dados:
|
||||
print(f'{item}: {dados[item]}')
|
||||
else:
|
||||
print(f'erro {codigo}: {dados}')
|
||||
|
||||
def exchange_colume_chart_by_id() -> tuple[str, int, dict]:
|
||||
pass
|
||||
|
||||
|
||||
# debug (decomentar linhas seguintes para testar funcao)
|
||||
# url, codigo, dados = <nome_chamada_api()>
|
||||
# url, codigo, dados = exchange_tickers_by_id('binance', 'bitcoin,dogecoin')
|
||||
# print(f'url: {url}')
|
||||
# if codigo == 200:
|
||||
# for item in dados:
|
||||
# print(item)
|
||||
# print(f'{item}: {dados[item]}')
|
||||
# else:
|
||||
# print(f'erro {codigo}: {dados}')
|
||||
|
||||
def exchange_volume_chart_by_id(
|
||||
id_exchange: str = '',
|
||||
days: str = ''
|
||||
) -> tuple[str, int, dict]:
|
||||
'''https://docs.coingecko.com/v3.0.1/reference/exchanges-id-volume-chart
|
||||
|
||||
este endpoint permite obter dados de volume historico grafico com tempo UNIX e
|
||||
volume de negociação em BTC a partir do id da correctora
|
||||
'''
|
||||
# dicionario de parametros
|
||||
api_parameters: dict = {
|
||||
'id': '',
|
||||
'days': '',
|
||||
}
|
||||
# validacao de parametros
|
||||
# id_exchanges (como 'id' é nome reservado, foi usado outro nome)
|
||||
if not isinstance(id_exchange, str):
|
||||
raise TypeError('\'id_exchange\' tem de ser do tipo \'str\'')
|
||||
if id_exchange == '':
|
||||
raise ValueError('\'id_exchange\' tem de ser definido')
|
||||
api_parameters['id'] = id_exchange
|
||||
# days
|
||||
if not isinstance(days, str):
|
||||
raise TypeError('\'days\' tem de ser do tipo \'str\'')
|
||||
if days == '':
|
||||
raise ValueError('\'days\' tem de ser definido')
|
||||
api_parameters['days'] = days
|
||||
|
||||
return API(f'exchanges/{api_parameters['id']}/volume_chart', api_parameters)
|
||||
|
||||
|
||||
# debug (decomentar linhas seguintes para testar funcao)
|
||||
# url, codigo, dados = exchange_volume_chart_by_id('binance','30')
|
||||
# print(f'url: {url}')
|
||||
# if codigo == 200:
|
||||
# for item in dados:
|
||||
# print(f'{item}')
|
||||
# else:
|
||||
# print(f'erro {codigo}: {dados}')
|
||||
|
||||
|
||||
Reference in New Issue
Block a user