diff --git a/nautilus_trader/model/instruments/base.pyx b/nautilus_trader/model/instruments/base.pyx index 030a54fa19fe..c528a42d66ea 100644 --- a/nautilus_trader/model/instruments/base.pyx +++ b/nautilus_trader/model/instruments/base.pyx @@ -318,8 +318,8 @@ cdef class Instrument(Data): "lot_size": str(obj.lot_size) if obj.lot_size is not None else None, "max_quantity": str(obj.max_quantity) if obj.max_quantity is not None else None, "min_quantity": str(obj.min_quantity) if obj.min_quantity is not None else None, - "max_notional": obj.max_notional.to_str() if obj.max_notional is not None else None, - "min_notional": obj.min_notional.to_str() if obj.min_notional is not None else None, + "max_notional": obj.max_notional.to_raw_str() if obj.max_notional is not None else None, + "min_notional": obj.min_notional.to_raw_str() if obj.min_notional is not None else None, "max_price": str(obj.max_price) if obj.max_price is not None else None, "min_price": str(obj.min_price) if obj.min_price is not None else None, "margin_init": str(obj.margin_init), diff --git a/nautilus_trader/model/instruments/cfd.pyx b/nautilus_trader/model/instruments/cfd.pyx index ba9a8d5ab304..1143c62544ee 100644 --- a/nautilus_trader/model/instruments/cfd.pyx +++ b/nautilus_trader/model/instruments/cfd.pyx @@ -236,8 +236,8 @@ cdef class Cfd(Instrument): "lot_size": str(obj.lot_size) if obj.lot_size is not None else None, "max_quantity": str(obj.max_quantity) if obj.max_quantity is not None else None, "min_quantity": str(obj.min_quantity) if obj.min_quantity is not None else None, - "max_notional": obj.max_notional.to_str() if obj.max_notional is not None else None, - "min_notional": obj.min_notional.to_str() if obj.min_notional is not None else None, + "max_notional": obj.max_notional.to_raw_str() if obj.max_notional is not None else None, + "min_notional": obj.min_notional.to_raw_str() if obj.min_notional is not None else None, "max_price": str(obj.max_price) if obj.max_price is not None else None, "min_price": str(obj.min_price) if obj.min_price is not None else None, "margin_init": str(obj.margin_init), diff --git a/nautilus_trader/model/instruments/commodity.pyx b/nautilus_trader/model/instruments/commodity.pyx index 5f2f4b312ed3..29f10e10a80b 100644 --- a/nautilus_trader/model/instruments/commodity.pyx +++ b/nautilus_trader/model/instruments/commodity.pyx @@ -225,8 +225,8 @@ cdef class Commodity(Instrument): "lot_size": str(obj.lot_size) if obj.lot_size is not None else None, "max_quantity": str(obj.max_quantity) if obj.max_quantity is not None else None, "min_quantity": str(obj.min_quantity) if obj.min_quantity is not None else None, - "max_notional": obj.max_notional.to_str() if obj.max_notional is not None else None, - "min_notional": obj.min_notional.to_str() if obj.min_notional is not None else None, + "max_notional": obj.max_notional.to_raw_str() if obj.max_notional is not None else None, + "min_notional": obj.min_notional.to_raw_str() if obj.min_notional is not None else None, "max_price": str(obj.max_price) if obj.max_price is not None else None, "min_price": str(obj.min_price) if obj.min_price is not None else None, "margin_init": str(obj.margin_init), diff --git a/nautilus_trader/model/instruments/crypto_future.pyx b/nautilus_trader/model/instruments/crypto_future.pyx index 35775231c4f7..f569732732d6 100644 --- a/nautilus_trader/model/instruments/crypto_future.pyx +++ b/nautilus_trader/model/instruments/crypto_future.pyx @@ -311,8 +311,8 @@ cdef class CryptoFuture(Instrument): "lot_size": str(obj.lot_size), "max_quantity": str(obj.max_quantity) if obj.max_quantity is not None else None, "min_quantity": str(obj.min_quantity) if obj.min_quantity is not None else None, - "max_notional": obj.max_notional.to_str() if obj.max_notional is not None else None, - "min_notional": obj.min_notional.to_str() if obj.min_notional is not None else None, + "max_notional": obj.max_notional.to_raw_str() if obj.max_notional is not None else None, + "min_notional": obj.min_notional.to_raw_str() if obj.min_notional is not None else None, "max_price": str(obj.max_price) if obj.max_price is not None else None, "min_price": str(obj.min_price) if obj.min_price is not None else None, "margin_init": str(obj.margin_init), diff --git a/nautilus_trader/model/instruments/crypto_perpetual.pyx b/nautilus_trader/model/instruments/crypto_perpetual.pyx index 5becf9eed4d6..1b1d2c40ef2c 100644 --- a/nautilus_trader/model/instruments/crypto_perpetual.pyx +++ b/nautilus_trader/model/instruments/crypto_perpetual.pyx @@ -238,8 +238,8 @@ cdef class CryptoPerpetual(Instrument): "lot_size": str(obj.lot_size), "max_quantity": str(obj.max_quantity) if obj.max_quantity is not None else None, "min_quantity": str(obj.min_quantity) if obj.min_quantity is not None else None, - "max_notional": obj.max_notional.to_str() if obj.max_notional is not None else None, - "min_notional": obj.min_notional.to_str() if obj.min_notional is not None else None, + "max_notional": obj.max_notional.to_raw_str() if obj.max_notional is not None else None, + "min_notional": obj.min_notional.to_raw_str() if obj.min_notional is not None else None, "max_price": str(obj.max_price) if obj.max_price is not None else None, "min_price": str(obj.min_price) if obj.min_price is not None else None, "margin_init": str(obj.margin_init), diff --git a/nautilus_trader/model/instruments/currency_pair.pyx b/nautilus_trader/model/instruments/currency_pair.pyx index ca4199d26269..9e4ab3f828ff 100644 --- a/nautilus_trader/model/instruments/currency_pair.pyx +++ b/nautilus_trader/model/instruments/currency_pair.pyx @@ -244,8 +244,8 @@ cdef class CurrencyPair(Instrument): "lot_size": str(obj.lot_size) if obj.lot_size is not None else None, "max_quantity": str(obj.max_quantity) if obj.max_quantity is not None else None, "min_quantity": str(obj.min_quantity) if obj.min_quantity is not None else None, - "max_notional": obj.max_notional.to_str() if obj.max_notional is not None else None, - "min_notional": obj.min_notional.to_str() if obj.min_notional is not None else None, + "max_notional": obj.max_notional.to_raw_str() if obj.max_notional is not None else None, + "min_notional": obj.min_notional.to_raw_str() if obj.min_notional is not None else None, "max_price": str(obj.max_price) if obj.max_price is not None else None, "min_price": str(obj.min_price) if obj.min_price is not None else None, "margin_init": str(obj.margin_init), diff --git a/nautilus_trader/model/objects.pxd b/nautilus_trader/model/objects.pxd index 82974f36dbd9..d6370c09d40b 100644 --- a/nautilus_trader/model/objects.pxd +++ b/nautilus_trader/model/objects.pxd @@ -147,6 +147,7 @@ cdef class Money: cdef void sub_assign(self, Money other) cpdef str to_str(self) + cpdef str to_raw_str(self) cpdef object as_decimal(self) cpdef double as_double(self) diff --git a/nautilus_trader/model/objects.pyx b/nautilus_trader/model/objects.pyx index 7cb0e8d55470..7f6a4f4caa8c 100644 --- a/nautilus_trader/model/objects.pyx +++ b/nautilus_trader/model/objects.pyx @@ -1234,6 +1234,17 @@ cdef class Money: """ return f"{self.as_f64_c():,.{self._mem.currency.precision}f} {self.currency_code_c()}".replace(",", "_") + cpdef str to_raw_str(self): + """ + Return the raw string representation of the money. + + Returns + ------- + str + + """ + return f"{self.as_f64_c():.{self._mem.currency.precision}f} {self.currency_code_c()}" + cdef class Currency: """ diff --git a/tests/unit_tests/model/test_instrument.py b/tests/unit_tests/model/test_instrument.py index 7dd6723e787d..f62b935a0997 100644 --- a/tests/unit_tests/model/test_instrument.py +++ b/tests/unit_tests/model/test_instrument.py @@ -175,7 +175,7 @@ def test_crypto_perpetual_instrument_to_dict(self): "size_increment": "1", "max_quantity": None, "min_quantity": None, - "max_notional": "10_000_000.00 USD", + "max_notional": "10000000.00 USD", "min_notional": "1.00 USD", "max_price": "1000000.0", "min_price": "0.5",