Hi ,
I am trying to calculate ema(55) using hourly market data. But I couldn’t get the last 55 hourly bar. Is there any one help me? I am using market data v2.
Thanks ,
Omer
Hi ,
I am trying to calculate ema(55) using hourly market data. But I couldn’t get the last 55 hourly bar. Is there any one help me? I am using market data v2.
Thanks ,
Omer
Hi @ofyzero - Are you getting any particular error message or code?
It would help if you could post your request and response so I can troubleshoot.
Thanks!
hi, sorry for the late response. Here is my code:
import alpaca_trade_api as tradeapi
from alpaca_trade_api.rest import REST, TimeFrame
import datetime
import pytz
APCA_API_KEY_ID = ‘’
APCA_API_SECRET_KEY = ‘’
APCA_API_BASE_URL = ‘https://paper-api.alpaca.markets’
api = REST(APCA_API_KEY_ID,APCA_API_SECRET_KEY,APCA_API_BASE_URL)
UTC = pytz.timezone(‘UTC’)
curr = datetime.datetime.now(tz=UTC)
curr = curr - datetime.timedelta(days=8)
aweek = curr - datetime.timedelta(minutes=15)
curr_date = str(curr.year) + “-” + ‘{:02d}’.format(curr.month) + “-” + ‘{:02d}’.format(curr.day)
aweek_date = str(aweek.year) + “-” + ‘{:02d}’.format(aweek.month ) + “-” + ‘{:02d}’.format(aweek.day)
print(curr_date, aweek_date)
barset = api.get_bars(‘AAPL’, TimeFrame.Minute,aweek_date,curr_date, limit=100,adjustment=“raw”)
print(barset)
aapl_bars = barset[‘AAPL’]
print(aapl_bars)