New error this morning. I am live trading. This has worked every other day prior.
My code is python 3.9
I am using alpaca trade api 1.4.1
This morning get_barset is not working. It returned an HTTP error.
Here is the code snippet:
quote = conn_rest.get_barset(‘IVV’, limit=1, timeframe=‘minute’)
Here is the error message:
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://data.alpaca.markets/v1/bars/minute?symbols=IVV&limit=1
2 Likes
Hudson
March 17, 2022, 2:29pm
2
I’m seeing a similar error here: New Errors with no changes
Glad to see I’m not the only one. Must be a widespread issue.
Tekton
March 17, 2022, 2:34pm
3
I’m getting the same error.
Yeah I am experiencing the same issue.
I have the same error, it is not working .Python 3.8 ad Alpaca API 1.4.1
This is my code
base_url = ‘https://paper-api.alpaca.markets/ ’
api = alpaca.REST(api_key, api_secret, base_url, api_version=‘v2’)
pepe=api.get_barset(“AAPL”, ‘minute’, 1)
For any reason api_get_barset is calling v1
Raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://data.alpaca.markets/v1/bars/minute?symbols=AAPL&limit=1
Actually it was in the documentation, this works for me.
pepe=api.get_bars(“AAPL”, TimeFrame.Minute, limit=1,adjustment=‘raw’)
I see the same error today on get_barset!
I read on another forum that v1 has been deprecated as of March 17.
Cheers.
1 Like
same here … invalid endpoint for both v1 and v2
Ah, that could be it. I missed that. I’ll try v2 again and see if that works
It was the depreciation. Use .get_bars instead.
Working code is: conn_rest.get_bars(‘IVV’, ‘1Min’, limit=1)
1 Like
Hudson
March 17, 2022, 8:47pm
11
Hey Ryan! Appreciate you diving into this! The error I receive when trying to move my stuff to get_bars over get_barset is:
“invalid start”
Not sure what that means or how to fix an error such as that. Not giving me much information.
KD_A
March 17, 2022, 8:53pm
12
Thanks for that response. It worked.
Kyley
March 17, 2022, 8:55pm
13
I attempted to run your example and it required start and end points. After doing so it states that it needs a value instead of a string for timeframe. When i get rid of the quotes my python reader throws an error saying invalid syntax.
any help is appreciated.
KD_A
March 17, 2022, 8:57pm
14
In the definition of get_bars(), start is an argument. What you are passing is invalid for that argument.
Also, it is important to specify the limit argument as in the example “limit=1”.
def get_bars(self,
symbol: Union[str, List[str]],
timeframe: TimeFrame,
start: Optional[str] = None,
end: Optional[str] = None,
adjustment: str = ‘raw’,
limit: int = None,
) → BarsV2:
1 Like
This is probably it. Paste your code Hudson, if not.
KD_A
March 18, 2022, 4:08am
16
If you do not need to specify start and end points, don’t. Those arguments are optional.
Use Ryan’s code as close as possible.
Replace the symbol to what you want
Replace conn_rest with whatever is appropriate for your code.
Paste your code if you need further help
if we want to switch to get_bars the issue is timestamp is from 8 am to 23 which doesn’t make sense. And the market time is from 12:30 to 20
redac7
March 18, 2022, 1:28pm
18
I’m probably doing something dumb on my part, I’m still stuck this is what I’m seeing:
barset = api_v2.get_bars(‘AAPL’, “1Min”, limit=1)
Traceback (most recent call last):
File “”, line 1, in
TypeError: get_bars() missing 2 required positional arguments: ‘start’ and ‘end’
Is api_v2 your rest connection?
redac7
March 18, 2022, 1:52pm
20
yes:
api_v2 = tradeapi.REST(APCA_API_KEY_ID, APCA_API_SECRET_KEY, api_version=‘v2’)
does that look right? I’ll ask but I should also look this up as well any method I could run to verify I’m using the correct version like:
api_v2.show_version()