Data_Feed argument not supported

Hi folks, I got stuck when I was trying to initialize the Alpaca API client with “data_feed=‘iex’” as an argument. Plz see the code snippet below:

def __init__(self, api_key, secret_key):
        super().__init__()
        self.api_key = api_key
        self.secret_key = secret_key
        self.api = tradeapi.REST(self.api_key, self.secret_key, base_url='https://paper-api.alpaca.markets', api_version='v2', data_feed='iex')

When I run the above section in Python, I get an error message saying: "REST.init() got an unexpected keyword argument ‘data_feed’.

If I remove data_feed, I would get this error instead: “subscription does not permit querying recent SIP data”

It’s disastrous. Appreciate it if anyone could point out my mistake/the correct keyword to specify the data type for IEX (I’m only subscribed to free data for now). Thanks!

@MingHooi It appears you are using the alpaca-trade-api SDK? The issue is that the data feed is not specified in the api_client but rather in each data call. For example this is how one would fetch bars while specifying the data feed.

!pip install -q alpaca-trade-api
import alpaca_trade_api as tradeapi
import pandas as pd

# Alpaca keys etc
ALPACA_BASE_URL = 'https://paper-api.alpaca.markets'
ALPACA_API_KEY = 'xxxxx'
ALPACA_API_SECRET_KEY = 'xxxxx'

# Instantiate the REST object
api = tradeapi.REST(ALPACA_API_KEY, ALPACA_API_SECRET_KEY, ALPACA_BASE_URL)

symbols = 'AAPL'

# Set the begin and end times
start_time = pd.to_datetime('2024-07-22 12:00:00').tz_localize('America/New_York')
end_time = pd.to_datetime('2024-07-22 13:00:00').tz_localize('America/New_York')

# Fetch the bars
bars = api.get_bars(symbols,
                    timeframe='5Min',
                    start=start_time.isoformat(),
                    end=end_time.isoformat(),
                    feed='iex', # sip for SIP data
                    adjustment='all',
                    ).df.tz_convert('America/New_York')

Ahh thanks for pointing that out. It works. Just curious, is there any Alpaca API for trading indicators (EMA, Bollinger Bands, RSI, etc)? I’m building a bot to test different strategies.