Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Refactor smc.py to use iloc instead of indexing for high and low values #45

Merged
merged 1 commit into from
May 25, 2024
Merged
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
8 changes: 4 additions & 4 deletions smartmoneyconcepts/smc.py
Original file line number Diff line number Diff line change
Expand Up @@ -848,9 +848,9 @@ def sessions(
and (start_time <= current_time or current_time <= end_time)
):
active[i] = 1
high[i] = max(ohlc["high"][i], high[i - 1] if i > 0 else 0)
high[i] = max(ohlc["high"].iloc[i], high[i - 1] if i > 0 else 0)
low[i] = min(
ohlc["low"][i],
ohlc["low"].iloc[i],
low[i - 1] if i > 0 and low[i - 1] != 0 else float("inf"),
)

Expand Down Expand Up @@ -897,7 +897,7 @@ def retracements(cls, ohlc: DataFrame, swing_highs_lows: DataFrame) -> Series:

if direction[i - 1] == 1:
current_retracement[i] = round(
100 - (((ohlc["low"][i] - bottom) / (top - bottom)) * 100), 1
100 - (((ohlc["low"].iloc[i] - bottom) / (top - bottom)) * 100), 1
)
deepest_retracement[i] = max(
(
Expand All @@ -909,7 +909,7 @@ def retracements(cls, ohlc: DataFrame, swing_highs_lows: DataFrame) -> Series:
)
if direction[i] == -1:
current_retracement[i] = round(
100 - ((ohlc["high"][i] - top) / (bottom - top)) * 100, 1
100 - ((ohlc["high"].iloc[i] - top) / (bottom - top)) * 100, 1
)
deepest_retracement[i] = max(
(
Expand Down
Loading