# OHLC Data Fetch History Start Time Inconsistent

**URL:** <https://forum.alpaca.markets/t/ohlc-data-fetch-history-start-time-inconsistent/4050>\
**Category:** Alpaca Market Data\
**Created:** [January 25, 2021, 12:59am UTC](https://forum.alpaca.markets/t/ohlc-data-fetch-history-start-time-inconsistent/4050 "2021-01-25T00:59:52Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![blake\_8](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/blake_8/32/1892_2.png) [@blake\_8](https://forum.alpaca.markets/u/blake_8)\
**Post date:** [January 25, 2021, 12:59am UTC](https://forum.alpaca.markets/t/ohlc-data-fetch-history-start-time-inconsistent/4050/1 "2021-01-25T00:59:52Z")

</div>

Greetings,

I signed up two days ago and tried to use the python API to fetch data using `get_barset`.  
For symbol like **SPY** I was able to fetch **1min** bar data since **2015-01-20** up to **now** when I just signed up. But when I tried the same query to fetch data today (Jan 24 2020) I can only get data since 2021-01-22. Please let me know why there is a such big inconsistencies in terms of data fetch. Thank you  
here is the code available:

```auto
fetch_ticker = 'SPY'
fetch_start = pd.Timestamp('2010-01-01 00:00', tz=NY)
fetch_end = pd.Timestamp('2022-01-01 00:00', tz=NY)
bardata = api.get_barset([fetch_ticker], 'minute', start=fetch_start, end=fetch_end)

```

---

<div class="post-metadata">

**Author:** ![Dan\_Whitnable\_Alpaca](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/dan_whitnable_alpaca/32/1658_2.png) [@Dan\_Whitnable\_Alpaca](https://forum.alpaca.markets/u/Dan_Whitnable_Alpaca)\
**Post date:** [January 25, 2021, 7:29pm UTC](https://forum.alpaca.markets/t/ohlc-data-fetch-history-start-time-inconsistent/4050/2 "2021-01-25T19:29:42Z")

</div>

The `get_barset` API is quite particular about the formatting of the date. It’s a good practice to use the `isoformat()` method to do the formatting for you. That may have been the issue? The following fetches all available minute data which you saw originally.

```
import pandas as pd
import pytz

NY_TIMEZONE = pytz.timezone('America/New_York')

fetch_ticker = 'SPY'
fetch_start = pd.Timestamp('2010-01-01 00:00', tz=NY_TIMEZONE).isoformat()
fetch_end = pd.Timestamp('2022-01-01 00:00', tz=NY_TIMEZONE).isoformat()

bardata = api.get_barset([fetch_ticker], 'minute', start=fetch_start, end=fetch_end)

```

One unfortunate (IMHO) aspect of the `get_barset` API is that it fails silently on a bad date format and then simply uses the default dates. In this case, it defaulted to the most current date and then used the default limit of 100 rows. There is a bit more on a similar issue [in this post](https://forum.alpaca.markets/t/get-barset-ignore-start-and-end-dates/2961/2).

---

<div class="post-metadata">

**Author:** ![blake\_8](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/blake_8/32/1892_2.png) [@blake\_8](https://forum.alpaca.markets/u/blake_8)\
**Post date:** [January 26, 2021, 2:09am UTC](https://forum.alpaca.markets/t/ohlc-data-fetch-history-start-time-inconsistent/4050/3 "2021-01-26T02:09:39Z")

</div>

Appreciate the prompt reply. Yes you are right. Once I got the data to the right format the fetch result included the 2015 data. Thanks a lot.

---

<div class="post-metadata">

**Author:** ![Maged](https://avatars.discourse-cdn.com/v4/letter/m/51bf81/32.png) [@Maged](https://forum.alpaca.markets/u/Maged)\
**Post date:** [January 30, 2021, 3:49pm UTC](https://forum.alpaca.markets/t/ohlc-data-fetch-history-start-time-inconsistent/4050/4 "2021-01-30T15:49:40Z")

</div>

Could I know the maximum history that I could fetch for any NYSE symbol as 1 minute data?  
i.e. What is the start date that you have for 1 min historical data?

---

<div class="post-metadata">

**Author:** ![Dan\_Whitnable\_Alpaca](https://sea2.discourse-cdn.com/flex020/user_avatar/forum.alpaca.markets/dan_whitnable_alpaca/32/1658_2.png) [@Dan\_Whitnable\_Alpaca](https://forum.alpaca.markets/u/Dan_Whitnable_Alpaca)\
**Post date:** [January 30, 2021, 8:19pm UTC](https://forum.alpaca.markets/t/ohlc-data-fetch-history-start-time-inconsistent/4050/5 "2021-01-30T20:19:08Z")

</div>

There are two data providers which Alpaca currently provides data for. IEX data is provided for both paper and live accounts. Their historical 1 minute data goes back to 2015. Polygon data is provided free of charge for users with a live funded account. Their minute data goes back to 2004 for most securities.
