Skip to content

Commit

Permalink
bugfix: negative values bug
Browse files Browse the repository at this point in the history
  • Loading branch information
alexcamargos committed Oct 12, 2024
1 parent 1b09570 commit ea6b71b
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 7 deletions.
2 changes: 1 addition & 1 deletion fundamentus/_version.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,6 @@
# Package version.
MAJOR = 0
MINOR = 0
MICRO = 10
MICRO = 12

__version__ = f'{MAJOR}.{MINOR}.{MICRO}'
18 changes: 13 additions & 5 deletions fundamentus/stages/transformation/transform_raw_information.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@

# ------------------------------------------------------------------------------
# Name: transform_raw_information.py
# Version: 0.1.2
# Version: 0.1.3
#
# Summary: Python Fundamentus
# Python Fundamentus is a Python API that allows you to quickly
Expand Down Expand Up @@ -168,12 +168,20 @@ def __to_decimal(value: str) -> Decimal:
Decimal: The Decimal representation of the input string.
"""

if value.endswith('%'):
value = value[:-1].strip()
strip_value = value.strip()

return Decimal(value) / 100
if '-' == strip_value:
return Decimal(0)

return Decimal(value.strip()) if value is not None else None
if strip_value.endswith('%'):
strip_value = strip_value[:-1].strip()

if '-' == strip_value.strip():
return Decimal(0)

return Decimal(strip_value) / 100

return Decimal(strip_value) if strip_value is not None else None

@staticmethod
def __remove_currency_symbol(number: str) -> str:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[tool.poetry]
name = "pyfundamentus"
version = "0.0.10"
version = "0.0.12"
description = "Python Fundamentus is a Python API that allows you to quickly access the main fundamental indicators of the main stocks in the Brazilian market."
authors = ["Alexsander Lopes Camargos <[email protected]>"]
license = "MIT"
Expand Down

0 comments on commit ea6b71b

Please sign in to comment.