Skip to content
All library documents

Interpreting Unix Timestamps in Yahoo Intraday Data

Article Quant Q&A · Author: Ryan Sheftel

Summary

This discussion concerns the timestamps attached to historical intraday equity data from Yahoo’s chart endpoint. The sample rows contain Unix epoch values, but converting them appears to produce times offset by varying seconds from the expected minute boundaries. The metadata also reports a timezone and UTC offset, making it important to distinguish epoch conversion from display in the market’s local time.

The replies point the reader toward standard Unix timestamp conversion references and an epoch conversion utility as ways to verify interpretation. An R example parses the row timestamps from the Unix epoch in GMT and then assigns a New York timezone to the series. These suggestions clarify common conversion steps, but the thread does not establish why individual sample times fall at irregular seconds, nor does it validate the historical endpoint’s aggregation or timestamp conventions. The example also depends on a legacy data source and library workflow.

Key ideas

  • The row timestamps are Unix epoch values measured in seconds.
  • Convert epoch values using the correct origin before displaying them in a local timezone.
  • The R example parses timestamps in GMT and then sets the series timezone to New York.
  • The thread does not explain the irregular seconds or verify the source’s bar-timestamp convention.

Tags

Full text
# Yahoo intraday historical download Timestamp


# Yahoo intraday historical download Timestamp












Yahoo offers an API to download historical intraday data, but I am unable to understand the timestamps on the data. The URL request is:

```
Format : http://chartapi.finance.yahoo.com/instrument/1.0/[TICKER]/chartdata;type=quote;range=[days]d/csv

Example: http://chartapi.finance.yahoo.com/instrument/1.0/GOOG/chartdata;type=quote;range=1d/csv
```

Which returns data like the following:

```
uri:/instrument/1.0/GOOG/chartdata;type=quote;range=1d/csv
ticker:goog
Company-Name:Alphabet Inc.
Exchange-Name:NMS
unit:MIN
timezone:EST
currency:USD
gmtoffset:-18000
previous_close:731.2300
Timestamp:1447425000,1447448400
labels:1447426800,1447430400,1447434000,1447437600,1447441200,1447444800,1447448400
values:Timestamp,close,high,low,open,volume
close:717.0000,730.7000
high:717.0000,731.1500
low:716.7300,729.7850
open:717.0000,731.0000
volume:0,104700
1447425030,727.2000,728.8550,727.2000,728.7500,48300
1447425096,727.8440,728.2200,727.8440,727.8850,0
1447425120,728.7300,729.0000,727.2900,728.4800,25100
1447425183,729.3100,729.8900,728.1550,729.2465,20000
1447425247,729.4500,731.1500,729.4500,730.4893,8900
1447425301,729.4500,730.4000,729.0600,729.3200,4500
1447425418,730.4250,730.7000,729.0200,730.0500,5100
```

The data it in each row is in the form: Timestamp, close, high, low, open, volume.

The timestamp appears to be a Unix timestamp (seconds since 1970). That is confirmed by this web post: https://www.daniweb.com/programming/software-development/threads/260694/how-to-process-timestamp-in-chartapi-finance-yahoo-com

My question is on the values I get when converting from Unix timestamps, they look very close to timestamps I would expect, every one minute, but are off by random amounts.

```
2015-11-13 09:30:58
2015-11-13 09:31:15
2015-11-13 09:32:06
2015-11-13 09:33:00
2015-11-13 09:34:03
```

My question is if anyone else has been successful in figuring how to properly convert the timestamps to the correct values.

-----------Update based on R code suggestion-------------------

I tried the R code below and got similar results of timestamps on odd non-even minutes. Here is the output using this getYahoo.intraday() function and GOOG ticker:

```
> p <- getYahoo.intraday('goog','1')
> head(p)
                       Open    High      Low   Close Volume
2015-11-13 09:31:02 728.410 728.420 727.1601 727.830  18300
2015-11-13 09:32:06 728.960 729.000 727.2900 728.450  11200
2015-11-13 09:33:00 729.240 729.890 728.1550 728.460  15300
2015-11-13 09:34:03 729.450 730.820 729.4500 729.846  15300
2015-11-13 09:35:14 729.450 729.588 729.0600 729.070   3900
2015-11-13 09:36:58 730.425 730.700 729.0200 730.050   5100
```

## Answer by Rohini Jayanthi (score 1)

https://quant.stackexchange.com/a/21752

Your answers seem to be slightly off. Here is a previous thread that answers your question;

https://stackoverflow.com/questions/3682748/converting-unix-timestamp-string-to-readable-date-in-python

Also, you can cross verify using this tool; http://www.epochconverter.com/

## Answer by tdazio (score 0)

https://quant.stackexchange.com/a/21758

with R (tiker: yahoo tiker, nDays: max 15):

```
getYahoo.intraday <- function(tiker,nDays){
url <- paste("http://chartapi.finance.yahoo.com/instrument/1.0/",tiker,"/chartdata;type=quote;range=",nDays,"d/csv",sep="")
nskip <- as.numeric(nDays)+17
data <- read.csv(url, skip=nskip, header=F, stringsAsFactors=F)
data.xts <- xts(data[,-1],as.POSIXct(data$V1,origin="1970-01-01",tz="GMT"))
indexTZ(data.xts) <- "America/New_York"
colnames(data.xts) <- c("Open", "High", "Low", "Close", "Volume")
options(warn=-1)
data.xts
}

library(quantmod)
p <- getYahoo.intraday("SPY","15")
tail(p)
```

Shown in full with attribution under the source's licence. Licence: CC BY-SA 4.0 (Stack Exchange)

This summary was written by Stratmill's research agent from the original; it is not a copy of the source.