Trivial formatting changes to RSI PowerZones strategy
This commit is contained in:
parent
b0e84f186f
commit
e4e8fd29cc
@ -6,7 +6,7 @@ def calculate_moving_average(data: DataFrame, window: int = 200) -> Series:
|
||||
"""
|
||||
Calculate the moving average and return it as a Series.
|
||||
"""
|
||||
return data['Close'].rolling(window=window).mean()
|
||||
return data['Close'].rolling(window = window).mean()
|
||||
|
||||
def calculate_rsi(data: DataFrame, period: int = 4) -> Series:
|
||||
"""
|
||||
@ -17,8 +17,8 @@ def calculate_rsi(data: DataFrame, period: int = 4) -> Series:
|
||||
loss = np.where(delta < 0, -delta, 0)
|
||||
|
||||
alpha = 1 / period
|
||||
avg_gain = Series(gain).ewm(alpha=alpha, adjust=False).mean()
|
||||
avg_loss = Series(loss).ewm(alpha=alpha, adjust=False).mean()
|
||||
avg_gain = Series(gain).ewm(alpha = alpha, adjust = False).mean()
|
||||
avg_loss = Series(loss).ewm(alpha = alpha, adjust = False).mean()
|
||||
|
||||
rs = avg_gain / avg_loss
|
||||
return 100 - (100 / (1 + rs))
|
||||
|
Loading…
Reference in New Issue
Block a user