Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 6 additions & 5 deletions stock_indicators/_cslib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,11 +15,9 @@
load(runtime="coreclr")
import clr
except Exception as e:
raise ImportError(("fail to import clr.\n"
"Stock Indicators for Python has dependency on pythonnet, which uses CLR.\n"
"Check that you have CLR installed. It supports .NET 6.0 or above.\n"
".NET:\n\t"
"https://dotnet.microsoft.com/download/dotnet")) from e
e.add_note("Stock Indicators for Python has a dependency on CLR.\n"
"Install .NET SDK 6.0 (or newer) in your environment to add the required CLR capability.")
raise e

skender_stock_indicators_dll_path = os.path.join(
os.path.dirname(__file__),
Expand Down Expand Up @@ -54,3 +52,6 @@
from Skender.Stock.Indicators import PivotPointType as CsPivotPointType
from Skender.Stock.Indicators import PivotTrend as CsPivotTrend
from Skender.Stock.Indicators import Match as CsMatch

# Exceptions
from System import FormatException as CsFormatException
9 changes: 7 additions & 2 deletions stock_indicators/_cstypes/decimal.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
from decimal import Decimal as PyDecimal

from stock_indicators._cslib import CsDecimal

from stock_indicators._cslib import CsFormatException

class Decimal:
"""
Expand All @@ -18,7 +18,12 @@ class Decimal:
2.5
"""
def __new__(cls, decimal) -> CsDecimal:
return CsDecimal.Parse(str(decimal))
try:
return CsDecimal.Parse(str(decimal))
except CsFormatException as e:
e.add_note("You may be using numeric data that is incompatible with your locale environment settings.\n"
"For example, you may be using decimal points instead of commas.")
raise e


def to_pydecimal(cs_decimal):
Expand Down