I hope that you are having a good day.
I am working with the Binance api trough the Python-Binance. My bot runs fine most of the time but for some reason after a while it randomly stops and gives me this error message. "APIError(code=-1099): Not found, unauthenticated, or unauthorized". The error seems to happen at the same line of code everytime.
from binance.client import Client
import time
from datetime import datetime
import pandas as pd
class LastPrice():
def __init__(self, symbol):
self.symbol = symbol
self.api_key = "my key"
self.secret_key = "my secret"
def get_client(self):
try:
client = Client(self.api_key, self.secret_key)
except Exception as e:
print(e)
pass
return client
def get_last_price(self):
last_price_string = self.get_client().get_ticker(symbol=self.symbol)['lastPrice']
last_price = float(last_price_string)
return last_price_string
def get_last_price_and_time(self):
last_price_string = self.get_client().get_ticker(symbol=self.symbol)['lastPrice']
close_time = self.get_client().get_ticker(symbol=self.symbol)['closeTime']
last_price = float(last_price_string)
price_and_time = [close_time, last_price]
return price_and_time
I Have included a screenshot of my error message i get. Despite using the same code to generate the client everytime i only get the error in that specific code. My code stops because the client is referenced before assignement but I am looking for the cause of the precedent APIError.
Any idea what that error meassage means in the context of my code ? Thanks in advance !