Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Wrong timezone for DataFactory #721

Open
ypxie opened this issue Feb 26, 2023 · 0 comments
Open

Wrong timezone for DataFactory #721

ypxie opened this issue Feb 26, 2023 · 0 comments

Comments

@ypxie
Copy link

ypxie commented Feb 26, 2023

data0 = DataFactory(dataname='SPY', 
    historical=True, 
    fromdate=datetime(2023, 2, 24, 9, 30, 0), 
    todate=datetime(2023, 2, 25, 16, 0, 0), 
    timeframe=bt.TimeFrame.Minutes,
    tz=global_tz,
    compression=5)

cerebro = bt.Cerebro()
cerebro.adddata(data0)
data0.getfeed()
data0.start()

def print_data(datafeed, num_print=10):
    dd = datafeed.next()
    while dd:
        dd = datafeed.next()
    
    print(len(datafeed))
    for d in datafeed:
        _open = datafeed.open.array
        _close = datafeed.close.array
        _datetime =  datafeed.datetime.array
        for idx, (this_open, this_close, this_dtime) in enumerate(zip(_open, _close, _datetime) ):
            print(this_open, this_close, num2date(this_dtime) )
            if idx > num_print:
                break

print_data(data0, 10000)

will have the following results:

`78
399.63 399.65 2023-02-24 09:30:00
399.67 399.67 2023-02-24 09:35:00
399.6 399.59 2023-02-24 09:40:00
399.58 399.47 2023-02-24 09:45:00
399.48 399.48 2023-02-24 09:50:00
399.41 399.42 2023-02-24 09:55:0

.....

393.89 394.1 2023-02-24 15:55:00`

It seems that DataFactory is confused by the utc timezone and NYC timezone. IT returned data with utc timezone, but still use NYV timezone 16:00:00 as end datetime. Please fix this.

For example,
399.63 399.65 2023-02-24 09:30:00 is utc timezone,
but it still truncate each data's data to 15:55:00 which is based on NYC timezone, this is wrong.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant