BUG: looking a potential resampling issue

This commit is contained in:
fredfortier
2017-11-16 18:14:24 -05:00
parent 230b9c17eb
commit c260e188b0
2 changed files with 49 additions and 3 deletions
+37
View File
@@ -113,3 +113,40 @@ class TestExchangeDataPortal:
)
log.info('found history window: {}'.format(data))
def test_validate_resample(self):
symbol = ['eth_btc']
exchange_name = 'poloniex'
exchange = get_exchange(exchange_name, base_currency=symbol)
assets = exchange.get_assets(symbols=symbol)
date = rnd_history_date_days(
max_days=10,
last_dt=pd.to_datetime('2017-11-1', utc=True)
)
bar_count = rnd_bar_count(max_bars=10)
sample_minutes = 15
sample_data = self.data_portal_backtest.get_history_window(
assets=assets,
end_dt=date,
bar_count=bar_count,
frequency='{}T'.format(sample_minutes),
field='close',
data_frequency='daily'
)
minute_data = self.data_portal_backtest.get_history_window(
assets=assets,
end_dt=date,
bar_count=bar_count * sample_minutes,
frequency='1T',
field='close',
data_frequency='daily'
)
resampled_minute_data = minute_data.resample(
'{}T'.format(sample_minutes))
print(sample_data.tail(10))
print(resampled_minute_data.tail(10))
print(minute_data.tail(10))
pass
+12 -3
View File
@@ -4,11 +4,20 @@ from random import randint
import pandas as pd
def rnd_history_date_days(max_days=30):
now = pd.Timestamp.utcnow()
def rnd_history_date_days(max_days=30, last_dt=None):
if last_dt is None:
last_dt = pd.Timestamp.utcnow()
days = randint(0, max_days)
return now - timedelta(days=days)
return last_dt - timedelta(days=days)
def rnd_history_date_minutes(max_minutes=1440):
now = pd.Timestamp.utcnow()
days = randint(0, max_minutes)
return now - timedelta(minutes=days)
def rnd_bar_count(max_bars=21):