[fix] #1: erro ao introduzir chave API
correção do erro indicado em #1: introdução da chave API é feita antes de chamada do contexto 'with'
This commit is contained in:
@ -8,8 +8,8 @@ import mplfinance as mpf
|
|||||||
# se não houver ficheiro 'modulos/constantes.py' criar ficheiro com
|
# se não houver ficheiro 'modulos/constantes.py' criar ficheiro com
|
||||||
# a chave da API 'CHAVE_API_DEMO'
|
# a chave da API 'CHAVE_API_DEMO'
|
||||||
if not os.path.exists('modulos/constantes.py'):
|
if not os.path.exists('modulos/constantes.py'):
|
||||||
|
chave_api = input('Introduza a chave da API Demo de CoinGecko: ')
|
||||||
with open('modulos/constantes.py', 'w') as f:
|
with open('modulos/constantes.py', 'w') as f:
|
||||||
chave_api = input('Introduza a chave da API Demo de CoinGecko: ')
|
|
||||||
f.write(f'CHAVE_API_DEMO = \'{chave_api}\'\n')
|
f.write(f'CHAVE_API_DEMO = \'{chave_api}\'\n')
|
||||||
|
|
||||||
import modulos.coingecko_api as cgapi
|
import modulos.coingecko_api as cgapi
|
||||||
@ -65,7 +65,7 @@ url, codigo, dados_ohlc = cgapi.coin_ohlc_chart_by_id(criptomoeda, vs_currency,
|
|||||||
|
|
||||||
# processar dados coigecko
|
# processar dados coigecko
|
||||||
if codigo == 200:
|
if codigo == 200:
|
||||||
#print(len(dados_ohlc))
|
# print(len(dados_ohlc))
|
||||||
lista_dados_coingecko: list = []
|
lista_dados_coingecko: list = []
|
||||||
for index in range(0, len(dados_ohlc)):
|
for index in range(0, len(dados_ohlc)):
|
||||||
data = time.gmtime(dados_ohlc[index][0]/1000)
|
data = time.gmtime(dados_ohlc[index][0]/1000)
|
||||||
@ -112,7 +112,7 @@ dados = aux.carregar_dados_ficheiro_csv(
|
|||||||
print(f'{len(dados)} dados carregados')
|
print(f'{len(dados)} dados carregados')
|
||||||
|
|
||||||
# preparar dados para plotar
|
# preparar dados para plotar
|
||||||
dados = dados[1:] # remover cabecalho
|
dados = dados[1:] # remover cabecalho
|
||||||
for item in dados:
|
for item in dados:
|
||||||
item[cabecalho[0]] = pd.to_datetime(int(item[cabecalho[0]]), unit='ms')
|
item[cabecalho[0]] = pd.to_datetime(int(item[cabecalho[0]]), unit='ms')
|
||||||
item[cabecalho[3]] = float(item[cabecalho[3]])
|
item[cabecalho[3]] = float(item[cabecalho[3]])
|
||||||
|
|||||||
Reference in New Issue
Block a user