Correctly handle identical timerame merges
This commit is contained in:
@@ -28,7 +28,7 @@ def test_merge_informative_pair():
|
||||
data = generate_test_data('15m', 40)
|
||||
informative = generate_test_data('1h', 40)
|
||||
|
||||
result = merge_informative_pair(data, informative, '1h', ffill=True)
|
||||
result = merge_informative_pair(data, informative, '15m', '1h', ffill=True)
|
||||
assert isinstance(result, pd.DataFrame)
|
||||
assert len(result) == len(data)
|
||||
assert 'date' in result.columns
|
||||
@@ -59,3 +59,30 @@ def test_merge_informative_pair():
|
||||
assert result.iloc[7]['date_1h'] == result.iloc[0]['date']
|
||||
# Next 4 rows contain the next Hourly date original date row 4
|
||||
assert result.iloc[8]['date_1h'] == result.iloc[4]['date']
|
||||
|
||||
|
||||
def test_merge_informative_pair_same():
|
||||
data = generate_test_data('15m', 40)
|
||||
informative = generate_test_data('15m', 40)
|
||||
|
||||
result = merge_informative_pair(data, informative, '15m', '15m', ffill=True)
|
||||
assert isinstance(result, pd.DataFrame)
|
||||
assert len(result) == len(data)
|
||||
assert 'date' in result.columns
|
||||
assert result['date'].equals(data['date'])
|
||||
assert 'date_15m' in result.columns
|
||||
|
||||
assert 'open' in result.columns
|
||||
assert 'open_15m' in result.columns
|
||||
assert result['open'].equals(data['open'])
|
||||
|
||||
assert 'close' in result.columns
|
||||
assert 'close_15m' in result.columns
|
||||
assert result['close'].equals(data['close'])
|
||||
|
||||
assert 'volume' in result.columns
|
||||
assert 'volume_15m' in result.columns
|
||||
assert result['volume'].equals(data['volume'])
|
||||
|
||||
# Dates match 1:1
|
||||
assert result['date_15m'].equals(result['date'])
|
||||
|
Reference in New Issue
Block a user