Why Intraday data from Alpha Advantage start at 4:00 am and finish at 20:00 pm?

Question:

This is my code to get 2 years intraday data from Alpha Vantage API.

from alpha_vantage.timeseries import TimeSeries
import csv
import time

API_key = 'XXXXXXXXXXXXXXXXX'
ticker = 'AAPL'
ts = TimeSeries(key=API_key, output_format='csv')

for yr in range(2):
    for mo in range(12):
        data = ts.get_intraday_extended(ticker, interval='15min', slice='year'+str(yr+1)+'month'+str(mo+1))

        with open(ticker+'.csv', 'a', newline='') as write_csvfile:
            writer = csv.writer(write_csvfile, dialect='excel')
            for row in data[0]:
                writer.writerow(row)

        time.sleep(15)

This is an example of what I get in the ‘AAPL.csv’ file.

no description

I dont think that the starting and finishing time is caused from my code. is it normal the interval time 4:00 am – 20:00 pm in the Stock Market Exchange?

Asked By: Yesid Fonseca V.

||

Answers:

This is documented at their site:

This API returns intraday time series of the equity specified, covering extended trading hours where applicable (e.g., 4:00am to 8:00pm Eastern Time for the US market).

I do not see a switch to limit to (core) market hours but you could subset to market hours yourself after the retrieval. I get the same from R (which I use more often) using one of the accessor packages:

> aapl <- av_get("AAPL", av_fun="TIME_SERIES_INTRADAY", interval="30min")
> head(aapl)
# A tibble: 6 x 6
  timestamp                   open  high   low close volume
  <dttm>                     <dbl> <dbl> <dbl> <dbl>  <dbl>
1 2021-03-23 18:30:00.000000  123.  123.  122.  122.  59481
2 2021-03-23 19:00:00.000000  122.  123.  122.  122. 170623
3 2021-03-23 19:30:00.000000  122.  122.  122.  122.  17079
4 2021-03-23 20:00:00.000000  122.  122.  122.  122.  53327
5 2021-03-24 04:30:00.000000  123.  123.  122.  123.  14399
6 2021-03-24 05:00:00.000000  123.  123.  123.  123.  12854
> 

The first half-hour is from 04:00 to 04:30 and summarized with 4:30 timestamp, the last one on the previous day is at 20:00h. Same at end of the data set (last Friday):

> tail(aapl)
# A tibble: 6 x 6
  timestamp                   open  high   low close volume
  <dttm>                     <dbl> <dbl> <dbl> <dbl>  <dbl>
1 2021-03-26 17:30:00.000000  121.  121.  121.  121.  61451
2 2021-03-26 18:00:00.000000  121.  121.  121.  121.  32491
3 2021-03-26 18:30:00.000000  121.  121.  121.  121.  45474
4 2021-03-26 19:00:00.000000  121.  121.  121.  121.  25208
5 2021-03-26 19:30:00.000000  121.  121.  121.  121.  37129
6 2021-03-26 20:00:00.000000  121.  121.  121.  121.  32174
> 
Answered By: Dirk Eddelbuettel

this got me confused to. I thought that market open at 9:30 am and 4:00 pm NY time.

Answered By: Glen Martin
Categories: questions Tags: , ,
Answers are sorted by their score. The answer accepted by the question owner as the best is marked with
at the top-right corner.