there are my imports:
from alpaca.data.timeframe import TimeFrame, TimeFrameUnit # Ensure this exact import
from alpaca.data.models import BarSet
from alpaca.data import StockHistoricalDataClient
from alpaca.data.requests import StockBarsRequest
from alpaca.data.timeframe import TimeFrame, TimeFrameUnit
from alpaca.data.enums import DataFeed, Adjustment
import alpaca_trade_api as alpacaapi
from alpaca.data.historical import StockHistoricalDataClient
from alpaca.data.requests import StockBarsRequest, StockLatestTradeRequest
import requests
API_KEY = os.getenv(“ALPACA_API_KEY”)
API_SECRET = os.getenv(“ALPACA_API_SECRET_KEY”)
BASE_URL = “https://paper-api.alpaca.markets”
data_client = StockHistoricalDataClient(API_KEY, API_SECRET)
#data_client = StockHistoricalDataClient(API_KEY, API_SECRET, feed=“iex”)
api = REST(API_KEY, API_SECRET, base_url=BASE_URL)
logger = logging.getLogger(name)
timeframe=TimeFrame(5, TimeFrameUnit.Minute) # if you’re using new Alpaca SDK and this format
trying to use indicators in my get indicators function and it it throwing error:
my class in get indicators:
request = StockBarsRequest(
symbol_or_symbols=symbol,
#timeframe=TimeFrame(5, TimeFrame.Unit.Minute), # ← FIX HERE
#timeframe=TimeFrame(“5Min”),
timeframe=TimeFrame(5, TimeFrameUnit.Minute),
start=start,
end=end,
feed=“iex”
)
bars = data_client.get_stock_bars(request).df
server is throwing this error:
WARNING:root:Failed to get indicators for OMEX: 1 validation error for StockBarsRequest
timeframe
Input should be an instance of TimeFrame [type=is_instance_of, input_value=<alpaca_trade_api.rest.Ti…e object at 0x10557a8d0>, input_type=TimeFrame]
For further information visit Redirecting...
WARNING:root:Failed to get indicators for PAVMZ: 1 validation error for StockBarsRequest
timeframe
I am trying to dynamically get top mover from the alpaca top mover and iterate through it for automated tradingf: WORKED fabuluslously woohoo!
now i need to include an indicator strategy for precise entry and exit signals all the code in for indicators but, timeframe error is blocking my trades PLEASE HELP me. i am almost there