diff --git a/nautilus_core/model/src/types/money.rs b/nautilus_core/model/src/types/money.rs index 56b54a8f030b..fd0d5b90e8bb 100644 --- a/nautilus_core/model/src/types/money.rs +++ b/nautilus_core/model/src/types/money.rs @@ -102,6 +102,7 @@ impl FromStr for Money { // Parse amount let amount = parts[0] + .replace('_', "") .parse::() .map_err(|e| format!("Cannot parse amount '{}' as `f64`: {:?}", parts[0], e))?; @@ -388,6 +389,7 @@ mod tests { #[case("0 USD", Currency::USD(), dec!(0.00))] #[case("1.1 AUD", Currency::AUD(), dec!(1.10))] #[case("1.12345678 BTC", Currency::BTC(), dec!(1.12345678))] + #[case("10_000.10 USD", Currency::USD(), dec!(10000.10))] fn test_from_str_valid_input( #[case] input: &str, #[case] expected_currency: Currency, diff --git a/tests/unit_tests/model/objects/test_money.py b/tests/unit_tests/model/objects/test_money.py index 7594e0141259..64d2838b9753 100644 --- a/tests/unit_tests/model/objects/test_money.py +++ b/tests/unit_tests/model/objects/test_money.py @@ -200,6 +200,7 @@ def test_from_raw_given_valid_values_returns_expected_result( ["1.00 USDT", Money(1.00, USDT)], ["1.00 USD", Money(1.00, USD)], ["1.001 AUD", Money(1.00, AUD)], + ["10_001.01 AUD", Money(10001.01, AUD)], ], ) def test_from_str_given_valid_strings_returns_expected_result(