Skip to content

Commit

Permalink
Merge branch 'main' into docs/update-docs-1.3.1
Browse files Browse the repository at this point in the history
  • Loading branch information
DaveSkender authored Aug 16, 2024
2 parents a7ac378 + 5d788de commit d2ad135
Show file tree
Hide file tree
Showing 3 changed files with 15 additions and 11 deletions.
4 changes: 2 additions & 2 deletions stock_indicators/_cstypes/datetime.py
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ class DateTime:
>>> cs_now
3/26/2021 10:02:22 PM
"""
def __new__(cls, datetime) -> CsDateTime:
def __new__(cls, datetime: PyDateTime) -> CsDateTime:
return CsDateTime.Parse(datetime.isoformat())


def to_pydatetime(cs_datetime):
def to_pydatetime(cs_datetime: CsDateTime) -> PyDateTime:
"""
Converts C#'s `System.DateTime` struct to a native Python datetime object.
Expand Down
4 changes: 2 additions & 2 deletions stock_indicators/_cstypes/decimal.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ class Decimal:
Class for converting a number into C#'s `System.Decimal` class.
Parameters:
decimal : `int`, `float` or any `object` that can be represented as a number.
decimal : `int`, `float` or any `object` that can be represented as a number string.
Example:
Constructing `System.Decimal` from `float` of Python.
Expand All @@ -22,7 +22,7 @@ def __new__(cls, decimal) -> CsDecimal:
return CsDecimal.Parse(str(decimal), CsCultureInfo.InvariantCulture)


def to_pydecimal(cs_decimal):
def to_pydecimal(cs_decimal: CsDecimal) -> PyDecimal:
"""
Converts an object to a native Python decimal object.
Expand Down
18 changes: 11 additions & 7 deletions stock_indicators/indicators/common/quote.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,12 @@
from datetime import datetime
from decimal import Decimal
from typing import Iterable
from typing import Any, Iterable, Optional

from stock_indicators._cslib import CsQuote
from stock_indicators._cslib import CsQuoteUtility
from stock_indicators._cslib import CsQuote, CsQuoteUtility
from stock_indicators._cstypes import List as CsList
from stock_indicators._cstypes import DateTime as CsDateTime
from stock_indicators._cstypes import Decimal as CsDecimal
from stock_indicators._cstypes.datetime import to_pydatetime
from stock_indicators._cstypes.decimal import to_pydecimal
from stock_indicators._cstypes import to_pydatetime, to_pydecimal
from stock_indicators.indicators.common.enums import CandlePart
from stock_indicators.indicators.common._contrib.type_resolver import generate_cs_inherited_class

Expand Down Expand Up @@ -56,7 +55,9 @@ class _Quote:
close = property(_get_close, _set_close)
volume = property(_get_volume, _set_volume)

def __init__(self, date, open = None, high = None, low = None, close = None, volume = None):
def __init__(self, date: datetime, open: Optional[Any] = None,
high: Optional[Any] = None, low: Optional[Any] = None,
close: Optional[Any] = None, volume: Optional[Any] = None):
self.date = date
self.open: Decimal = open if open else 0
self.high: Decimal = high if high else 0
Expand Down Expand Up @@ -86,4 +87,7 @@ def use(cls, quotes: Iterable["Quote"], candle_part: CandlePart):


class Quote(generate_cs_inherited_class(_Quote, CsQuote)):
"""A single dated quote containing OHLCV elements."""
"""
A single dated quote containing OHLCV elements.
OHLCV values can be given as any object that can be represented as a number string.
"""

0 comments on commit d2ad135

Please sign in to comment.