Skip to content

Commit

Permalink
feat: Declare quote wrappers as class for better linting (#356)
Browse files Browse the repository at this point in the history
  • Loading branch information
LeeDongGeon1996 authored Mar 7, 2024
1 parent e5f25cd commit 696b101
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 7 deletions.
8 changes: 3 additions & 5 deletions stock_indicators/indicators/common/candles.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,10 +23,6 @@ def condense(self) -> Self:


class _CandleProperties(_Quote):
"""
A wrapper class for `CsCandleProperties`, which is an extended version of `Quote`.
It contains additional calculated properties.
"""
@property
def size(self) -> Optional[Decimal]:
return to_pydecimal(self.high - self.low)
Expand Down Expand Up @@ -71,7 +67,9 @@ def is_bearish(self) -> bool:
return self.Close < self.Open


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


class CandleResult(ResultBase):
Expand Down
5 changes: 3 additions & 2 deletions stock_indicators/indicators/common/quote.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,6 @@ def _set_volume(quote, value):
quote.Volume = CsDecimal(value)

class _Quote:
"""A base wrapper class for a single unit of historical quotes."""
date = property(_get_date, _set_date)
open = property(_get_open, _set_open)
high = property(_get_high, _set_high)
Expand Down Expand Up @@ -86,4 +85,6 @@ def use(cls, quotes: Iterable["Quote"], candle_part: CandlePart):
return CsQuoteUtility.Use[Quote](CsList(Quote, quotes), candle_part.cs_value)


Quote = generate_cs_inherited_class(_Quote, CsQuote, "Quote")
class Quote(generate_cs_inherited_class(_Quote, CsQuote)):
"""A single dated quote containing OHLCV elements."""
pass

0 comments on commit 696b101

Please sign in to comment.