0

There are a few public methods on Poloniex, all of which take HTTP GET requests and return output in JSON format. I am using Python to asking the chart data of the most current 5-min-periods. I get the response and can work with it, but sometimes it contains null values. Does anybody know why?

Does anybody know a more stable method to do this task? My method is useless if the returned data is null sometimes. Here is my code:

from calendar import timegm
import datetime
import requests
current_time = datetime.datetime.utcnow()                  
current_unix_time = timegm(current_time.timetuple())        
r = requests.get('https://poloniex.com/public?command=returnChartData&currencyPair=USDT_BTC&start=' + str(current_unix_time - 300) + '&end=' + str(current_unix_time) + '&period=300')
print(r.json())

Appreciate any help. Thanks in advance.

sunwarr10r
  • 4,420
  • 8
  • 54
  • 109

1 Answers1

0

I have found the problem. Poloniex is updating the returnChartData method every 5 minutes. And everytime I am running my task on a fully five minute period (e.g.: 13:00, 13:05, 13:10, 13:15 etc.) it responds with null values if you are asking for the last five minute period. Probably because Poloniex is making the data available at this time.

The solution was not to ask for the last five minute peroiod, but instead for the second last five minute period.

sunwarr10r
  • 4,420
  • 8
  • 54
  • 109