Skip to content

Commit 41be050

Browse files
[pre-commit.ci] auto fixes from pre-commit.com hooks
for more information, see https://pre-commit.ci
1 parent f0b529f commit 41be050

File tree

1 file changed

+19
-2
lines changed

1 file changed

+19
-2
lines changed

financial/relative_strength_index.py

+19-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from typing import List
22

3+
34
def calculate_rsi(prices: List[float], period: int = 14) -> List[float]:
45
"""
56
Calculate the Relative Strength Index (RSI) for a given list of prices.
@@ -18,7 +19,7 @@ def calculate_rsi(prices: List[float], period: int = 14) -> List[float]:
1819
>>> rsi_values = calculate_rsi([44.0, 44.15, 44.09, 44.20, 44.30, 44.25, 44.40, 44.35, 44.50, 44.60, 44.55, 44.75, 44.80, 44.70, 44.85], 14)
1920
>>> print(rsi_values) # doctest: +ELLIPSIS
2021
[78.91..., 80.99...]
21-
22+
2223
Reference:
2324
https://en.wikipedia.org/wiki/Relative_strength_index
2425
"""
@@ -71,6 +72,22 @@ def calculate_rsi(prices: List[float], period: int = 14) -> List[float]:
7172

7273

7374
if __name__ == "__main__":
74-
prices = [44.0, 44.15, 44.09, 44.20, 44.30, 44.25, 44.40, 44.35, 44.50, 44.60, 44.55, 44.75, 44.80, 44.70, 44.85]
75+
prices = [
76+
44.0,
77+
44.15,
78+
44.09,
79+
44.20,
80+
44.30,
81+
44.25,
82+
44.40,
83+
44.35,
84+
44.50,
85+
44.60,
86+
44.55,
87+
44.75,
88+
44.80,
89+
44.70,
90+
44.85,
91+
]
7592
rsi = calculate_rsi(prices, 14)
7693
print("RSI Values:", rsi)

0 commit comments

Comments
 (0)