quantopian / zipline

Zipline, a Pythonic Algorithmic Trading Library
https://www.zipline.io
Apache License 2.0
17.28k stars 4.67k forks source link

Timezone issue with `data.history` #1454

Open iamkissg opened 7 years ago

iamkissg commented 7 years ago

Dear Zipline Maintainers,

I'm not sure whether the issue I am having is really a issue:

I notice that zipline uses Eastern Standard Time(EST) by default, then converts it to Coordinated Universal Time(UTC).

When I call data.history and print the results, it shows UTC instead of EST (or any other local time), is it right?

For example, I build the following algorithm on Quantopian with default setups:

def initialize(context):
    # AAPL, MSFT, and SPY
    context.assets = [sid(24), sid(5061), sid(8554)]

def handle_data(context, data):
    log.info(data.history(context.assets, "price", 20, "1d"))

Then in the log area, it shows:

2011-01-03 22:31 handle_data:6 INFO                            Equity(24 [AAPL])  Equity(5061 [MSFT])  \
2010-12-31 20:42:00+00:00            322.040               27.800   
2010-12-31 20:43:00+00:00            322.035               27.805   
......

I know that the UTC and EST format are the same time. And it doesn't produce any sides effects to the algorithm. However, may user want to see the local time directly. For example, I'm in Shanghai, it's strange to see the trading hours starts at 1:30 am, ends at 7:00 am.

Sincerely, kissg

ramesh8v commented 6 years ago

I'm having the same issue. Is it resolved?