question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Get Bars does not return data

See original GitHub issue

Hi, perhaps this is because of v2 being in beta, if so makes sense. Although, I have confirmed the same issue on the v1 endpoint.

BASE_URL = URL('https://api.alpaca.markets')
ALPACA_API_KEY = 'xx'
ALPACA_SECRET_KEY ='xx'

api = alpaca.REST(key_id=ALPACA_API_KEY,
                  secret_key=ALPACA_SECRET_KEY,
                  base_url=BASE_URL)
now = pd.Timestamp.now(tz='America/New_York').floor('1min')
yesterday = (now - pd.Timedelta('1day')).strftime('%Y-%m-%d')
today = now.strftime('%Y-%m-%d')
tomorrow = (now + pd.Timedelta('1day')).strftime('%Y-%m-%d')

data = api.get_bars(symbol, TimeFrame.Hour, yesterday, today, adjustment='raw').df
print(f'{yesterday} - {today}')
print(data)
❯ python test.py
2021-03-17 - 2021-03-18
Empty DataFrame
Columns: []
Index: []

get_bars returns an empty dataframe, I have tried various days and have tired different time frames and have the same issue. Some older random time intervals with some random time frames do occasionally work.

I did see this photo in the docs V2 api: https://alpaca.markets/docs/api-documentation/api-v2/market-data/alpaca-data-api-v2/historical/ Screen Shot 2021-03-18 at 1 33 18 PM

Is this regarding V1 api as well? I tested this feature with the v1 endpoint using

BASE_URL = 'https://data.alpaca.markets/v1'

Same output.

Issue Analytics

  • State:closed
  • Created 3 years ago
  • Comments:8 (3 by maintainers)

github_iconTop GitHub Comments

6reactions
ElliotVilhelmcommented, Oct 4, 2021

I am no longer using Alpaca.

1reaction
AbhayPrajapati195commented, Oct 6, 2022

get_bars is returning an empty array.

With which parameters?

my bad, got the timeframe parameter wrong.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Get_crypto_bars method not returning correct number of bars
I want to get the past day of minute bars. return self.api.get_crypto_bars( symbol = self.symbol, timeframe = alpaca_trade_api.TimeFrame.
Read more >
d3 does not show bars with repeated data - Stack Overflow
I kindof see the fix as part of your answer itself. Look at the code you wrote here: function(d, i) { return "translate(0,"...
Read more >
Bar chart not displaying output from DB - Ignition
Hello all, I am experiencing difficulties when trying to display result from SQL query from database (result of the query is on image...
Read more >
Use data bars, color scales, and icon sets to highlight data
Format cells by using color scales. Color scales can help you understand data distribution and variation, such as investment returns over time. Cells...
Read more >
Does TradingView's close variable return close price? · Kodify
That seems obvious and logical. But these bar variables have one counterintuitive feature: they don't always return the bar's final value. So ...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found