arctic
arctic copied to clipboard
Timezone changes to local tz (when writing UTC) in TickStore
trafficstars
Arctic Version
Arctic 1.80.0
Arctic Store
TickStore
Platform and version
Arctic 1.80.0, Windows 10, Mongo Server 4.4, python 3.7
Description of problem and/or code sample that reproduces the issue
In TickStore, when I run the example from the docs and write a dataframe with datetime index in UTC, reading back the data returns the df with an index in 'Europe/Berlin', my pc's local timezone.
Is this a bug? Is there a way to return the data in the UTC timestamp?
Code example:
import pandas as pd
from datetime import datetime as dt
from arctic import Arctic, TICK_STORE
from arctic.date._mktz import mktz
db = Arctic('localhost')
db.delete_library('temp')
db.initialize_library('temp', lib_type=TICK_STORE)
tickstore_lib = db['temp']
data = [{'A': 120, 'D': 1}, {'A': 122, 'B': 2.0}, {'A': 3, 'B': 3.0, 'D': 1}]
tick_index = [dt(2013, 6, 1, 12, 00, tzinfo=mktz('UTC')),
dt(2013, 6, 1, 11, 00, tzinfo=mktz('UTC')), # Out-of-order
dt(2013, 6, 1, 13, 00, tzinfo=mktz('UTC'))]
data = pd.DataFrame(data, index=tick_index)
tickstore_lib._chunk_size = 3
tickstore_lib.write('SYM', data)
print(tickstore_lib.read('SYM', columns=None).index)
This outputs:
DatetimeIndex(['2013-06-01 13:00:00+02:00', '2013-06-01 14:00:00+02:00',
'2013-06-01 15:00:00+02:00'],
dtype='datetime64[ns, tzfile('Europe/Berlin')]', freq=None)
Punting this to @jamesblackburn and/or @reasto
Should be fixed as of https://github.com/man-group/arctic/commit/a1b8b31fec52a1f8deb52f699bd4f26c619cafd2