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
2 changes: 1 addition & 1 deletion benchmarks/test_benchmark_indicators.py
Original file line number Diff line number Diff line change
Expand Up @@ -179,7 +179,7 @@ def test_benchmark_smma(benchmark, quotes):
benchmark(indicators.get_smma, quotes, 20)

def test_benchmark_starc_bands(benchmark, quotes):
benchmark(indicators.get_starc_bands, quotes)
benchmark(indicators.get_starc_bands, quotes, 10)

def test_benchmark_stc(benchmark, quotes):
benchmark(indicators.get_stc, quotes)
Expand Down
9 changes: 7 additions & 2 deletions stock_indicators/indicators/starc_bands.py
Original file line number Diff line number Diff line change
@@ -1,4 +1,5 @@
from typing import Iterable, Optional, TypeVar
from warnings import warn

from stock_indicators._cslib import CsIndicator
from stock_indicators._cstypes import List as CsList
Expand All @@ -7,7 +8,7 @@
from stock_indicators.indicators.common.quote import Quote


def get_starc_bands(quotes: Iterable[Quote], sma_periods: int = 20,
def get_starc_bands(quotes: Iterable[Quote], sma_periods: int = None,
multiplier: float = 2, atr_periods: int = 10):
"""Get STARC Bands calculated.

Expand All @@ -18,7 +19,7 @@ def get_starc_bands(quotes: Iterable[Quote], sma_periods: int = 20,
`quotes` : Iterable[Quote]
Historical price quotes.

`sma_periods` : int, defaults 20
`sma_periods` : int
Number of periods for the centerline SMA.

`multiplier` : float, defaults 2
Expand All @@ -35,6 +36,10 @@ def get_starc_bands(quotes: Iterable[Quote], sma_periods: int = 20,
- [STARC Bands Reference](https://python.stockindicators.dev/indicators/StarcBands/#content)
- [Helper Methods](https://python.stockindicators.dev/utilities/#content)
"""
if sma_periods is None:
warn('The default value of sma_periods will be removed in the next version. Pass sma_periods explicitly.', DeprecationWarning, stacklevel=2)
sma_periods = 20

results = CsIndicator.GetStarcBands[Quote](CsList(Quote, quotes), sma_periods,
multiplier, atr_periods)
return STARCBandsResults(results, STARCBandsResult)
Expand Down
4 changes: 2 additions & 2 deletions tests/test_starc_bands.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,10 +46,10 @@ def test_bad_data(self, bad_quotes):
assert 502 == len(r)

def test_no_quotes(self, quotes):
r = indicators.get_starc_bands([])
r = indicators.get_starc_bands([], 10)
assert 0 == len(r)

r = indicators.get_starc_bands(quotes[:1])
r = indicators.get_starc_bands(quotes[:1], 10)
assert 1 == len(r)

def test_removed(self, quotes):
Expand Down