Data.alpaca.markets does not return data for requested dates

Hi Alpaca Staff and @hitoshi,
This is similar to Data.alpaca.markets returns quotes from incorrect dates in the programming forum.

I’m using R’s httr:GET to request the following URL:
"https://data.alpaca.markets/v1/bars/5Min?symbols=FB,NFLX,AMZN,MSFT&limit=1000&start=2020-02-05T09:30:00-0500&end=2020-02-24T14:45:00-0500"
I’ve also tried the request with the URL encoded form of the request:
"https://data.alpaca.markets/v1/bars/5Min?symbols=FB%2CNFLX%2CAMZN%2CMSFT&limit=1000&start=2020-02-05T09%3A30%3A00-0500&end=2020-02-24T14%3A45%3A00-0500"
However, the data that I get back from either request is for the following date range:
"2020-03-02T09:50:00" to "2020-03-18T15:55:00"
Any ideas as to what’s going on here?

I posted a couple days ago of my bar data with incorrect timestamps. It appears that leap day may have caused some issues. Not sure if this is related to your issue.

Thanks @winser, yes I’ve noticed a few threads about people encountering issues with the lead year. That would seem like a high priority fix - I would wonder why they haven’t fixed it nearly three weeks out now?

Yeah, idk. Not sure if they’re not aware or if it’s not a high priority.

It’s bizarre because you would think that being able to access the appropriate data is a high priority. I’m submitting a support ticket about it.

I am having the same problem with the python sdk, I am trying a workaround with numpy and to removbe the outliers but this is really annoying

I have made a workaround for python, it will filter out the bad values from the v value, feel free to transpose it to other language.

import alpaca_trade_api as tradeapi
import time

from datetime import datetime

def price(stock):
API_KEY = “”
API_SECRET = “”
APCA_API_BASE_URL = “https://paper-api.alpaca.markets

api = tradeapi.REST(API_KEY, API_SECRET, APCA_API_BASE_URL, 'v2')
now = datetime.now()
dt_string = now.strftime("%d/%m/%Y %H:%M:%S")
# Get daily price data for AAPL over the last 5 trading days.
barset = api.get_barset(symbols=stock, timeframe='1Min', limit=1, start=dt_string)
aapl_bars = barset[stock]
print(barset)
if aapl_bars[0].v > 10000:
    while aapl_bars[0].v > 2000:
        barset = api.get_barset(symbols=stock, timeframe='1Min', limit=1, start=dt_string)
        aapl_bars = barset[stock]
        print(aapl_bars)
        time.sleep(1)
    else:
        current = aapl_bars[0].c

        return current

else:
    # See how much AAPL moved in that timeframe.
    #print(aapl_bars)
    current = aapl_bars[0].c

    return current

def get(stock):
first = price(stock)

return first

fff = get(“AAPL”)
print(fff)

@Ryan I mostly use R, but Python is somewhat readable for me. It appears to me that you’re filtering out outliers in volume with this script?
The issue I’m describing in this thread is that the API is not returning data for the requested dates, it returns an arbitrary date range.
Does api.get_barset actually use a v2 API? I’ve only found that v1 works for data.alpaca.markets.
Additionally, perhaps you could check to see if the date issue is reproducible?
You would just need to do something like:

from datetime import datetime

start = datetime.strptime('2020-02-05 09:30:00-0500', "%Y-%m-%d %H:%M:%S-%z")
end = datetime.strptime('2020-02-24 014:45:00-0500', "%Y-%m-%d %H:%M:%S-%z")
api.get_barset(symbols=stock, timeframe='5Min', limit=1000, start=start, end = end)

Which should return data between those dates. Does it?

Hi all,

Thanks for the report on the data integrity issue and we’ve looked at it over the weekend, and found one issue that has been fixed by now. It should be fine now but there could be still something after the market opens, so we will monitor it.

Awesome. Mine is working.

1 Like

Hi @hitoshi, thank you for the response!
I received a response on the ticket I submitted as well. I tested it again as of this morning using the following URL:
https://data.alpaca.markets/v1/bars/5Min?symbols=FB,NFLX,AMZN,MSFT&limit=1000&start=2020-02-11T09:30:00-0500&end=2020-02-28T14:45:00-0500
and the API is returning data for a range of slightly different dates:
2020-03-05 10:00:00 EST to 2020-03-23 15:55:00 EDT
but not the dates requested.
As far as I can tell the issue persists

The timestamp format for the parameters “start” and “end” need a colon for the time offset part. I know it’s a bit too strict but this way you can make it work.

1 Like

This did the trick! Thank you for spotting this!