Skip to content

Commit 94b9c74

Browse files
committed
Fix Databento bars parsing
1 parent 775d79e commit 94b9c74

File tree

2 files changed

+13
-6
lines changed

2 files changed

+13
-6
lines changed

RELEASES.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@ Released on TBD (UTC).
2121
- Fixed `BacktestNode` streaming data management (was not clearing between chunks), thanks for the report @dpmabo
2222
- Fixed `RiskEngine` cumulative notional calculations for margin accounts (was incorrectly using base currency when selling)
2323
- Fixed selling `Equity` instruments with `CASH` account and `NETTING` OMS incorrectly rejecting (should be able to reduce position)
24+
- Fixed Databento bars decoding (was incorrectly applying display factor)
2425

2526
---
2627

nautilus_core/adapters/src/databento/decode.rs

Lines changed: 12 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,7 +20,7 @@ use std::{
2020
str::FromStr,
2121
};
2222

23-
use databento::dbn;
23+
use databento::dbn::{self};
2424
use nautilus_core::{datetime::NANOSECONDS_IN_SECOND, time::UnixNanos};
2525
use nautilus_model::{
2626
data::{
@@ -630,13 +630,19 @@ pub fn decode_ohlcv_msg(
630630
let ts_event = msg.hd.ts_event;
631631
let ts_init = cmp::max(ts_init, ts_event) + ts_event_adjustment;
632632

633+
// Adjust raw prices by a display factor
634+
let mut display_factor = 1;
635+
if instrument_id.venue.value == "GLBX" {
636+
display_factor = 100;
637+
};
638+
633639
let bar = Bar::new(
634640
bar_type,
635-
Price::from_raw(msg.open / 100, price_precision)?, // TODO: adjust for display factor
636-
Price::from_raw(msg.high / 100, price_precision)?, // TODO: adjust for display factor
637-
Price::from_raw(msg.low / 100, price_precision)?, // TODO: adjust for display factor
638-
Price::from_raw(msg.close / 100, price_precision)?, // TODO: adjust for display factor
639-
Quantity::from_raw(msg.volume * FIXED_SCALAR as u64, 0)?, // TODO: adjust for display factor
641+
Price::from_raw(msg.open / display_factor, price_precision)?,
642+
Price::from_raw(msg.high / display_factor, price_precision)?,
643+
Price::from_raw(msg.low / display_factor, price_precision)?,
644+
Price::from_raw(msg.close / display_factor, price_precision)?,
645+
Quantity::from_raw(msg.volume * FIXED_SCALAR as u64, 0)?,
640646
ts_event,
641647
ts_init,
642648
);

0 commit comments

Comments
 (0)