Joseph38
Joseph38

Reputation: 19

Alpaca Trade API: endpoint not found?

I am trying to use the alpaca_trade_api to get some historical data. But when I do so I get the following error:

alpaca_trade_api.rest.APIError: endpoint not found

The code is:

import alpaca_trade_api as tradeapi  
import pandas as pd 

# keys
KEY = "XXX"
SECRET = "XXX"

# parameters
short_sma_period = 50 
long_sma_period = 200 

start_date = "2023-01-01"
end_date = "2023-05-01"
timeframe = '1D' # time frame for historical data 

asset = "USD/JPY"

# urls
data_url = "https://data.alpaca.markets"
paper_trade_url = "https://paper-api.alpaca.markets"

# initialize apis
data_api = tradeapi.REST(key_id=KEY,secret_key=SECRET,base_url=data_url, api_version="v2")
trade_api = tradeapi.REST(key_id=KEY,secret_key=SECRET,base_url=paper_trade_url)

# get historical data 
historical_data = data_api.get_bars(asset, timeframe, start=start_date, end=end_date)

Upvotes: 1

Views: 278

Answers (1)

Reto Höhener
Reto Höhener

Reputation: 5848

As of 2023, Alpaca Markets only supports US Stocks & ETFs, and Crypto. Use another broker to trade a currency pair like USD/JPY, referenced in your code.

Data API: https://alpaca.markets/docs/api-references/market-data-api/

Find out which assets (instruments, symbols) are supported by Alpaca:

Upvotes: 0

Related Questions