alpacahq / Alpaca-API

The Alpaca API is a developer interface for trading operations and market data reception through the Alpaca platform.
https://alpaca.markets/
141 stars 13 forks source link

timeframe parameter cannot be identified for crpto #205

Closed Zakk-Yang closed 2 years ago

Zakk-Yang commented 2 years ago

Describe the bug

TICK = "BTCUSD"

ALPACA_PARAMS = {
    "timeframe": "15Min",  # 1Min, 15Min, 1Hour, 1Day
    "limit": 10,
    'start': '2021-09-09',
}
BASE_URL = 'https://data.alpaca.markets/v1beta1/crypto'
BAR_URL = f'/{TICK}/trades'

r = requests.get(
    BASE_URL + BAR_URL,
    headers = ALPACA_HEADERS,
    params= ALPACA_PARAMS
)

print(r.json())

Error:

{'code': 40010000, 'message': 'unexpected parameter(s): timeframe'} Thank you.

noramehesz commented 2 years ago

Hello, you are using the wrong endpoint: BAR_URL = f'/{TICK}/trades', please use bars instead of trades.