Getting 1-min historical data (suds object) from BarChart API data into Pandas Dataframe

203 Views Asked by At

I've been searching around and haven't found what seems like an easy task to get historical data from the BarChart API into a Pandas dataframe with the index set as the time stamp. Here's a few records of 1-minute data. Anyone know an easy way to get this into a dataframe? Much appreciated.

Here is what is returned when doing a query on (3) records for ESZ20 (e-mini SP500 dec), I am using a wsdl suds client to get this data. When I print the type, I get this: <class 'suds.sudsobject.getHistoryArray'>

(getHistoryArray){
   getHistoryItem[] = 
      (getHistoryItem){
         symbol = "ESZ20"
         timestamp = 2020-12-03 23:57:00-06:00
         tradingDay = 2020-12-04
         open = 3674.0
         high = 3675.5
         low = 3674.0
         close = 3674.75
         volume = 357
      },
      (getHistoryItem){
         symbol = "ESZ20"
         timestamp = 2020-12-03 23:58:00-06:00
         tradingDay = 2020-12-04
         open = 3674.75
         high = 3674.75
         low = 3674.25
         close = 3674.25
         volume = 125
      },
      (getHistoryItem){
         symbol = "ESZ20"
         timestamp = 2020-12-03 23:59:00-06:00
         tradingDay = 2020-12-04
         open = 3674.25
         high = 3674.25
         low = 3674.0
         close = 3674.0
         volume = 189
      },
 }
1

There are 1 best solutions below

0
Jonathan Leon On

See this response to a similar question python api response to json object

I use barchart api calls like this, but if you need to use your current method refer to link provided for some guidance.

url = 'https://marketdata.websol.barchart.com/getHistory.json?\
apikey=apikeyhere&splits=True&symbol=AAPL&type=daily&\
startDate=20100101&maxRecords=5000&order=asc'

myResponse = requests.get(url)
data = json.loads(myResponse.text)
df = pd.DataFrame(data['results'])