utils
utils
¶
Functions¶
D
¶
D(value: int | float | str | Decimal) -> Decimal
Helper function to cast int, float, and str to Decimal.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
int | float | str | Decimal
|
The value to convert to Decimal |
required |
Returns:
| Type | Description |
|---|---|
Decimal
|
Decimal representation of the value |
Examples:
>>> D(0.1)
Decimal('0.1')
>>> D("123.456")
Decimal('123.456')
>>> D(42)
Decimal('42')
Source code in derive_client/data_types/utils.py
4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 | |