27 lines
950 B
Python
27 lines
950 B
Python
"""Test helper functions."""
|
|
|
|
import pandas as pd
|
|
from datetime import datetime, timedelta
|
|
|
|
|
|
def create_sample_ohlcv(periods: int = 100) -> pd.DataFrame:
|
|
"""Create sample OHLCV data."""
|
|
dates = pd.date_range(start=datetime.now() - timedelta(hours=periods), periods=periods, freq='1H')
|
|
return pd.DataFrame({
|
|
'timestamp': dates,
|
|
'open': [100 + i * 0.1 for i in range(periods)],
|
|
'high': [101 + i * 0.1 for i in range(periods)],
|
|
'low': [99 + i * 0.1 for i in range(periods)],
|
|
'close': [100.5 + i * 0.1 for i in range(periods)],
|
|
'volume': [1000.0] * periods
|
|
})
|
|
|
|
|
|
def assert_decimal_equal(actual, expected, places=2):
|
|
"""Assert two decimals are equal within places."""
|
|
from decimal import Decimal
|
|
actual_decimal = Decimal(str(actual)).quantize(Decimal('0.01'))
|
|
expected_decimal = Decimal(str(expected)).quantize(Decimal('0.01'))
|
|
assert actual_decimal == expected_decimal
|
|
|