-
Notifications
You must be signed in to change notification settings - Fork 646
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
Implement high-precision 128-bit value types #2072
Conversation
Fix databento decoder logic
nautilus_trader/model/objects.pyx
Outdated
@@ -67,8 +73,10 @@ PRICE_MIN = RUST_PRICE_MIN | |||
MONEY_MAX = RUST_MONEY_MAX | |||
MONEY_MIN = RUST_MONEY_MIN | |||
|
|||
FIXED_PRECISION = RUST_FIXED_PRECISION | |||
FIXED_SCALAR = RUST_FIXED_SCALAR | |||
HIGH_PRECISION = PRECISION == 16 |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It'll be a safer option to load this from the cdef HIGH_PRECISION value defined in model.pxd. Just in case the digits of precision change for high precision it'll very difficult to track down why this is failing.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Also had a similar thought, had to add another constant generated at compile time, as HIGH_PRECISION
was already occupied with the DEF, but now achieving what we were after:
HIGH_PRECISION = RUST_HIGH_PRECISION_MODE
Codecov ReportAttention: Patch coverage is 📢 Thoughts on this report? Let us know! |
@@ -191,8 +186,9 @@ mod tests { | |||
types::{Price, Quantity}, | |||
}; | |||
|
|||
#[cfg(feature = "high-precision")] // TODO: Add 64-bit precision version of test |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We'll do another sweep of the tests once merged.
); | ||
// TODO: Revisit calculations |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was outputting an unscaled raw quantity, we probably want the scaled quantity.
@@ -15,7 +15,7 @@ | |||
|
|||
//! Represents a medium of exchange in a specified denomination with a fixed decimal precision. | |||
//! | |||
//! Handles up to 9 decimals of precision. | |||
//! Handles up to 16 decimals of precision. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Will need to tidy up the docs some more depending on precision mode.
@@ -1201,13 +1200,13 @@ class PyCondition: | |||
Condition.positive(value, param, ex_type) | |||
|
|||
@staticmethod | |||
def positive_int(int64_t value, str param, ex_type = None): | |||
def positive_int(value: int, str param, ex_type = None): |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Relaxed all of these C types, as they're coming from Python in non-performance critical function calls.
Avoids having to name the specific integer types in C.
Pull Request
high-precision
feature flag to switch between lower and higher precision.See RFC.