Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: Remove unnecessary validations #395

Merged
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
3 changes: 0 additions & 3 deletions stock_indicators/_cslib/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,6 +51,3 @@
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
6 changes: 2 additions & 4 deletions stock_indicators/_cstypes/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,8 +20,7 @@ class DateTime:
3/26/2021 10:02:22 PM
"""
def __new__(cls, datetime) -> CsDateTime:
if isinstance(datetime, PyDateTime):
return CsDateTime.Parse(datetime.isoformat())
return CsDateTime.Parse(datetime.isoformat())


def to_pydatetime(cs_datetime):
Expand All @@ -31,5 +30,4 @@ def to_pydatetime(cs_datetime):
Parameter:
cs_datetime : `System.DateTime` of C#.
"""
if isinstance(cs_datetime, CsDateTime):
return PyDateTime.fromisoformat(cs_datetime.ToString("s", CsCultureInfo.InvariantCulture))
return PyDateTime.fromisoformat(cs_datetime.ToString("s", CsCultureInfo.InvariantCulture))
8 changes: 2 additions & 6 deletions stock_indicators/_cstypes/decimal.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from decimal import Decimal as PyDecimal

from stock_indicators._cslib import CsDecimal
from stock_indicators._cslib import CsFormatException
from stock_indicators._cslib import CsCultureInfo


class Decimal:
"""
Class for converting a number into C#'s `System.Decimal` class.
Expand All @@ -19,11 +19,7 @@ class Decimal:
2.5
"""
def __new__(cls, decimal) -> CsDecimal:
try:
return CsDecimal.Parse(str(decimal), CsCultureInfo.InvariantCulture)
except CsFormatException as e:
raise ValueError("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.") from e
return CsDecimal.Parse(str(decimal), CsCultureInfo.InvariantCulture)


def to_pydecimal(cs_decimal):
Expand Down
1 change: 0 additions & 1 deletion stock_indicators/indicators/common/candles.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def is_bearish(self) -> bool:

class CandleProperties(generate_cs_inherited_class(_CandleProperties, CsCandleProperties)):
"""An extended version of Quote that contains additional calculated properties."""
pass


class CandleResult(ResultBase):
Expand Down
2 changes: 1 addition & 1 deletion stock_indicators/indicators/vwap.py
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ def get_vwap(quotes, start = None, month = 1, day = 1, hour = 0, minute = 0):
if isinstance(start, int):
start = datetime(start, month, day, hour, minute)

results = CsIndicator.GetVwap[Quote](CsList(Quote, quotes), CsDateTime(start))
results = CsIndicator.GetVwap[Quote](CsList(Quote, quotes), CsDateTime(start) if start else None)
return VWAPResults(results, VWAPResult)


Expand Down
Loading