Reputation: 185
I am modelling the minute prices of stocks and I obtain the data using the alpaca_trade_api
from Python:
api = tradeapi.REST(api_key, secret_key, 'https://paper-api.alpaca.markets')
data = api.get_barset('AAPL', 'minute', end=datetime.datetime(2020, 11, 5, 10, 00, 0, 0,
timezone('US/Eastern')).isoformat(), limit=1)
However, the data is not adjusted on splits or dividends, and it will screw up the models if the splits or dividends occur (i.e. stock prices will have a very sharp increase or decrease). Is there a good way to obtain the adjusted price automatically?
Upvotes: 2
Views: 1489
Reputation: 21
You can use the adjustment
parameter, refer into the doc:
api.get_bars("AAPL", "1D", "2021-06-08", "2021-06-08", adjustment='split')
Upvotes: 1
Reputation: 789
Add the adjustment="split"
to the api.get_barset
.
It should look like this
api = tradeapi.REST(api_key, secret_key, 'https://paper-api.alpaca.markets')
data = api.get_barset('AAPL', 'minute', end=datetime.datetime(2020, 11, 5, 10, 00, 0, 0,
timezone('US/Eastern')).isoformat(), limit=1, adjustment="split")
Upvotes: 0