-
Notifications
You must be signed in to change notification settings - Fork 59
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
9 changed files
with
142 additions
and
59 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1 +1 @@ | ||
2.1.2 | ||
2.2.0 |
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,38 @@ | ||
from typing import List, Any | ||
|
||
from talipp.indicator_util import has_valid_values | ||
from talipp.indicators.Indicator import Indicator, InputModifierType | ||
from talipp.input import SamplingPeriodType | ||
from talipp.ohlcv import OHLCV | ||
|
||
|
||
class IBS(Indicator): | ||
"""Internal Bar Strength. | ||
Input type: [OHLCV][talipp.ohlcv.OHLCV]` | ||
Output type: `float` | ||
Args: | ||
input_values: List of input values. | ||
input_indicator: Input indicator. | ||
input_modifier: Input modifier. | ||
input_sampling: Input sampling type. | ||
""" | ||
|
||
def __init__(self, | ||
input_values: List[OHLCV] = None, | ||
input_indicator: Indicator = None, | ||
input_modifier: InputModifierType = None, | ||
input_sampling: SamplingPeriodType = None): | ||
super().__init__(input_modifier=input_modifier, | ||
input_sampling=input_sampling) | ||
|
||
self.initialize(input_values, input_indicator) | ||
|
||
def _calculate_new_value(self) -> Any: | ||
if not has_valid_values(self.input_values): | ||
return None | ||
|
||
candle: OHLCV = self.input_values[-1] | ||
return (candle.close - candle.low) / (candle.high - candle.low) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
import unittest | ||
|
||
from talipp.indicators import IBS | ||
|
||
from TalippTest import TalippTest | ||
|
||
|
||
class Test(TalippTest): | ||
def setUp(self) -> None: | ||
self.input_values = list(TalippTest.OHLCV_TMPL) | ||
|
||
def test_init(self): | ||
ind = IBS(self.input_values) | ||
|
||
print(ind) | ||
|
||
self.assertAlmostEqual(ind[-3], 0.597014, places = 5) | ||
self.assertAlmostEqual(ind[-2], 0.129032, places = 5) | ||
self.assertAlmostEqual(ind[-1], 0.493506, places = 5) | ||
|
||
def test_update(self): | ||
self.assertIndicatorUpdate(IBS(self.input_values)) | ||
|
||
def test_delete(self): | ||
self.assertIndicatorDelete(IBS(self.input_values)) | ||
|
||
def test_purge_oldest(self): | ||
self.assertIndicatorPurgeOldest(IBS(self.input_values)) | ||
|
||
|
||
if __name__ == '__main__': | ||
unittest.main() |