Questions tagged [alpaca]

45 questions
0
votes
2 answers

Python package not found - Alpaca

I followed the guide from the official Alpaca-py Documentation - https://alpaca.markets/docs/python-sdk/getting_started.html#introduction I ran: pip install alpaca-py Then I created this file called alpaca.py: from alpaca.data.historical import…
pnkflydgr
  • 665
  • 3
  • 13
  • 22
0
votes
0 answers

Data sent with the requests.delete method is disregarded

While trying to connect to an API from Alpaca (a broker that accepts automated orders), I found that I was unable to send data with the requests.delete method. Here is some code: def close_position(symbol, percentage, api_key=api_key,…
0
votes
1 answer

Python TypeError: list indices must be integers or slices, not Bar when downloading stock prices in "Chunks" using Alpaca API

I am trying to download prices for chunks of tickers using Alpaca Markets API. chunk_size = 200 for i in range(0, len(symbols), chunk_size): symbol_chunk = symbols[i:i+chunk_size] barsets = api.get_bars(symbol_chunk, TimeFrame.Day,…
gabrsafwat
  • 108
  • 7
0
votes
0 answers

I'm trying to insert some stock prices into my database, I get error line 36 "for bar in bars[symbol]:

I'm trying to use the alpaca API to retrieve some stock prices and I get this error: for bar in bars[symbol]: TypeError: list indices must be integers or slices, not Bar My code: api = tradeapi.REST(config.API_KEY, config.SECRET_KEY, …
tommy
  • 1
  • 1
0
votes
0 answers

AttributeError: 'REST' object has no attribute '_key_id'

My code was working well and fine, but suddenly this error has appeared, I use Alpaca trading API.
Manny
  • 1
0
votes
1 answer

Alpaca API simple 5 min historical bar request returning null

I must be making very simple mistake which I haven't been able to figure out for hours. I am referencing Alpaca API Doc and trying to follow. The code is shown below trying to get the 5 min historical bar on the TSLA as the test purposes which I…
Dongyob
  • 87
  • 2
  • 8
0
votes
0 answers

How can I get recent market data using the Alpaca API

I'm trying to get market data concerning the closing time value of the last 20 hours using the alpaca API. My code works when the stock exchange is open and only provides the value of that particular day (so not the day before). I want the code to…
Yope
  • 43
  • 6
0
votes
1 answer

Alpaca /v2/calendar REST API Endpoint Doesn't Respect start and end Parameters

I am using the Alpaca Calendar API to try to see when the stock market is open on a given day. See - https://alpaca.markets/docs/api-references/trading-api/calendar/. However, the API endpoint doesn't appear to be respecting the start and end…
Treker
  • 386
  • 2
  • 9
0
votes
0 answers

Why do I get a value error when using multiprocessing on websocket streams validated with pydantic?

Why am I getting a missing value error when I try to run 2 websockets simultaneously using ProcessPoolExecutor. It's an issue I've been banging my head against for a week. I figured someone smarter than I may have an answer or insight readily…
0
votes
1 answer

How do I control an event loop?

I can't figure out how to handle an event loop such that I can run other code concurrently. I want to make it so when the handler receives data, it prints it without effecting anything else the program is doing. I have tried wrapping…
0
votes
0 answers

How do I use a function with a parameter not previously defined

I'm using Alpaca's API with websocket to get stock price data. I want to use the variable position outside the function on_message but message is not previously defined so I get an error when I run the code name message is not defined def…
Callum
  • 1
  • 3
0
votes
0 answers

Using shift without pandas? Getting the previous close for stocks OHLC

I'm using the Alpaca API to pull in daily OHLC data: chunk_size = 200 for i in range(0, len(symbols), chunk_size): symbol_chunk = symbols[i:i+chunk_size] barsets = api.get_bars_iter(symbol_chunk, TimeFrame.Day, "2022-07-25",…
a7dc
  • 3,323
  • 7
  • 32
  • 50
-1
votes
1 answer

AttributeError: 'tuple' object has no attribute 'symbol' when downloading stock prices in chunks using "alpaca-py" library into SQLite table

I am trying to download the historical stock prices from alpaca using the alpaca-py library and store this data into a sqlite table. When downloading the historical data symbol by symbol everything works fine. But when I try to download the data in…
mhiytham
  • 5
  • 3
1 2
3