Skip to content

Commit 989217a

Browse files
committed
FIX: Fix timestamp precision in DBNStore.to_json
1 parent afe85ee commit 989217a

File tree

3 files changed

+10
-8
lines changed

3 files changed

+10
-8
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#### Bug fixes
66
- Fixed an issue where the index column was not serialized with `DBNStore.to_json`
7+
- Fixed an issue where timestamps serialized by `DBNStore.to_json` had reduced precision
78

89
## 0.19.0 - 2023-08-25
910

databento/common/dbnstore.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1050,6 +1050,7 @@ def to_json(
10501050
frame.to_json(
10511051
json_path,
10521052
orient="records",
1053+
date_unit="ns",
10531054
lines=True,
10541055
)
10551056

tests/test_historical_bento.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -636,19 +636,19 @@ def test_mbo_to_json_with_all_options_writes_expected_file_to_disk(
636636
# Assert
637637
written = path.read_text()
638638
assert written.strip() == (
639-
'{"ts_recv":1609160400000,"ts_event":1609160400000,"rtype":160,"publisher_id":1,"instrument_id":5482,'
639+
'{"ts_recv":1609160400000704000,"ts_event":1609160400000429000,"rtype":160,"publisher_id":1,"instrument_id":5482,'
640640
'"action":"C","side":"A","price":3722.75,"size":1,"channel_id":0,"order_id":647784973705,"flags":128,'
641641
'"ts_in_delta":22993,"sequence":1170352,"symbol":"ESH1"}'
642642
"\n"
643-
'{"ts_recv":1609160400000,"ts_event":1609160400000,"rtype":160,"publisher_id":1,"instrument_id":5482,'
643+
'{"ts_recv":1609160400000711000,"ts_event":1609160400000431000,"rtype":160,"publisher_id":1,"instrument_id":5482,'
644644
'"action":"C","side":"A","price":3723.0,"size":1,"channel_id":0,"order_id":647784973631,"flags":128,'
645645
'"ts_in_delta":19621,"sequence":1170353,"symbol":"ESH1"}'
646646
"\n"
647-
'{"ts_recv":1609160400000,"ts_event":1609160400000,"rtype":160,"publisher_id":1,"instrument_id":5482,'
647+
'{"ts_recv":1609160400000728000,"ts_event":1609160400000433000,"rtype":160,"publisher_id":1,"instrument_id":5482,'
648648
'"action":"C","side":"A","price":3723.25,"size":1,"channel_id":0,"order_id":647784973427,"flags":128,'
649649
'"ts_in_delta":16979,"sequence":1170354,"symbol":"ESH1"}'
650650
"\n"
651-
'{"ts_recv":1609160400000,"ts_event":1609160400000,"rtype":160,"publisher_id":1,"instrument_id":5482,'
651+
'{"ts_recv":1609160400000740000,"ts_event":1609160400000434000,"rtype":160,"publisher_id":1,"instrument_id":5482,'
652652
'"action":"C","side":"A","price":3723.5,"size":1,"channel_id":0,"order_id":647784973094,"flags":128,'
653653
'"ts_in_delta":17883,"sequence":1170355,"symbol":"ESH1"}'
654654
)
@@ -716,22 +716,22 @@ def test_mbp_1_to_json_with_all_options_writes_expected_file_to_disk(
716716
# Assert
717717
written = path.read_text()
718718
assert written.strip() == (
719-
'{"ts_recv":1609160400006,"ts_event":1609160400006,"rtype":1,"publisher_id":1,"instrument_id":5482,'
719+
'{"ts_recv":1609160400006136000,"ts_event":1609160400006001000,"rtype":1,"publisher_id":1,"instrument_id":5482,'
720720
'"action":"A","side":"A","depth":0,"price":3720.5,"size":1,"flags":128,"ts_in_delta":17214,'
721721
'"sequence":1170362,"bid_px_00":3720.25,"ask_px_00":3720.5,"bid_sz_00":24,"ask_sz_00":11,'
722722
'"bid_ct_00":15,"ask_ct_00":9,"symbol":"ESH1"}'
723723
"\n"
724-
'{"ts_recv":1609160400006,"ts_event":1609160400006,"rtype":1,"publisher_id":1,"instrument_id":5482,'
724+
'{"ts_recv":1609160400006246000,"ts_event":1609160400006146000,"rtype":1,"publisher_id":1,"instrument_id":5482,'
725725
'"action":"A","side":"A","depth":0,"price":3720.5,"size":1,"flags":128,"ts_in_delta":18858,'
726726
'"sequence":1170364,"bid_px_00":3720.25,"ask_px_00":3720.5,"bid_sz_00":24,"ask_sz_00":12,'
727727
'"bid_ct_00":15,"ask_ct_00":10,"symbol":"ESH1"}'
728728
"\n"
729-
'{"ts_recv":1609160400007,"ts_event":1609160400007,"rtype":1,"publisher_id":1,"instrument_id":5482,'
729+
'{"ts_recv":1609160400007159000,"ts_event":1609160400007044000,"rtype":1,"publisher_id":1,"instrument_id":5482,'
730730
'"action":"A","side":"B","depth":0,"price":3720.25,"size":2,"flags":128,"ts_in_delta":18115,'
731731
'"sequence":1170365,"bid_px_00":3720.25,"ask_px_00":3720.5,"bid_sz_00":26,"ask_sz_00":12,'
732732
'"bid_ct_00":16,"ask_ct_00":10,"symbol":"ESH1"}'
733733
"\n"
734-
'{"ts_recv":1609160400007,"ts_event":1609160400007,"rtype":1,"publisher_id":1,"instrument_id":5482,'
734+
'{"ts_recv":1609160400007260000,"ts_event":1609160400007169000,"rtype":1,"publisher_id":1,"instrument_id":5482,'
735735
'"action":"C","side":"A","depth":0,"price":3720.5,"size":1,"flags":128,"ts_in_delta":17361,'
736736
'"sequence":1170366,"bid_px_00":3720.25,"ask_px_00":3720.5,"bid_sz_00":26,"ask_sz_00":11,'
737737
'"bid_ct_00":16,"ask_ct_00":9,"symbol":"ESH1"}'

0 commit comments

Comments
 (0)