Hello there:
I tried to adress historical data from a particular ticker on march 23, 2015 using the method:
request_historical_data(context.security, '1 min','1 D', datetime(2015, 3, 23))
And I got this error:
broker_service_factory.BrokerService::request_historical_data: EXIT, endTime=2015-03-23 00:00:00 must have timezone.
Can anyone help me please??
Hi Ghery,
Sorry for the late reply. It looks like you haven't defined the time zone in the datetime object. Here is an example of how to define a datetime object with a specific time zone.
from datetime import datetime
import pytz
# defining datetime object with UTC time zone
datetime(2021, 11, 28, tzinfo=pytz.UTC)
I the example above pytz package was used to define the time zone. You can install this package using this command: pip install pytz
I hope you find this useful.
Thanks a lot