Open power-edge opened 5 months ago
for i in range(int(request_volume / max_per_mssg) + 1):
provisional_start = start + timedelta(0, i * (self.granularity * max_per_mssg))
provisional_start = self._date_cleaner(provisional_start)
provisional_end = start + timedelta(0, (i + 1) * (self.granularity * max_per_mssg))
provisional_end = self._date_cleaner(provisional_end)
print("Provisional Start: {}".format(provisional_start))
print("Provisional End: {}".format(provisional_end))
response = requests.get(
"https://api.pro.coinbase.com/products/{0}/candles?start={1}&end={2}&granularity={3}".format(
self.ticker,
provisional_start,
provisional_end,
self.granularity))
if response.status_code in [200, 201, 202, 203, 204]:
if self.verbose:
print('Data for chunk {} of {} extracted'.format(i+1,
(int(request_volume / max_per_mssg) + 1)))
dataset = pd.DataFrame(json.loads(response.text))
if not dataset.empty:
print("Type of data:", type(data))
print("Type of dataset:", type(dataset))
print("Dataset content:", dataset)
if data.empty:
data = dataset
else:
data = pd.concat([data, dataset], ignore_index=True)
time.sleep(randint(0, 2))
else:
print("""CoinBase Pro API did not have available data for '{}' beginning at {}.
Trying a later date:'{}'""".format(self.ticker,
self.start_date,
provisional_start))
time.sleep(randint(0, 2))
elif response.status_code in [400, 401, 404]:
if self.verbose:
print(
"Status Code: {}, malformed request to the CoinBase Pro API.".format(response.status_code))
sys.exit()
elif response.status_code in [403, 500, 501]:
if self.verbose:
print(
"Status Code: {}, could not connect to the CoinBase Pro API.".format(response.status_code))
sys.exit()
else:
if self.verbose:
print("Status Code: {}, error in connecting to the CoinBase Pro API.".format(
response.status_code))
sys.exit()
this is the fix
opening PR for fix