Skip to content

Commit

Permalink
Merge pull request #44 from joshyattridge/correct_unit_tests_for_time…
Browse files Browse the repository at this point in the history
…_index_indicators

Correct unit tests for time index indicators and fixed previous_high_low function
  • Loading branch information
joshyattridge authored May 25, 2024
2 parents eb9d9f0 + c534e53 commit df24ffb
Show file tree
Hide file tree
Showing 13 changed files with 86,576 additions and 86,568 deletions.
8 changes: 6 additions & 2 deletions smartmoneyconcepts/smc.py
Original file line number Diff line number Diff line change
Expand Up @@ -724,15 +724,19 @@ def previous_high_low(cls, ohlc: DataFrame, time_frame: str = "1D") -> Series:
currently_broken_low = False
last_broken_time = None
for i in range(len(ohlc)):
# remove rows with nan values (ignoring weekends)
resampled_previous_index = np.where(
resampled_ohlc.index < ohlc.index[i]
)[0]
if len(resampled_previous_index) <= 1:
previous_high[i] = np.nan
previous_low[i] = np.nan
continue
resampled_previous_index = resampled_previous_index[-1]
resampled_previous_index = resampled_previous_index[-2]

if last_broken_time != resampled_previous_index:
currently_broken_high = False
currently_broken_low = False
last_broken_time = resampled_previous_index

previous_high[i] = resampled_ohlc["high"].iloc[resampled_previous_index]
previous_low[i] = resampled_ohlc["low"].iloc[resampled_previous_index]
Expand Down
6 changes: 4 additions & 2 deletions tests/conftest.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,12 @@
def df():
test_instrument = "EURUSD"
instrument_data = f"{test_instrument}_15M.csv"
return pd.read_csv(
df = pd.read_csv(
os.path.join("tests/test_data", test_instrument, instrument_data)
)

df = df.set_index("Date")
df.index = pd.to_datetime(df.index)
return df

@pytest.fixture
def fvg_result_data():
Expand Down
Binary file modified tests/test.gif
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading

0 comments on commit df24ffb

Please sign in to comment.