INNER CODE UNIT · Python
ImageDataSet
RichardS0268/CNN-for-Trading · dataset.py:103
class ImageDataSet():
def __init__(self, win_size, start_date, end_date, mode, label, indicators=[], show_volume=False, parallel_num=-1):
## Check whether inputs are valid
assert isinstance(start_date, int) and isinstance(end_date, int), f'Type Error: start_date & end_date shoule be int'
assert start_date < end_date, f'start date {start_date} cannnot be later than end date {end_date}'
assert win_size in [5, 20], f'Wrong look back days: {win_size}'
assert mode in ['train', 'test', 'inference'], f'Type Error: {mode}'
assert label in ['RET5', 'RET20'], f'Wrong Label: {label}'
assert indicators is None or len(indicators)%2 == 0, 'Config Error, length of indicators should be even'
if indicators:
for i in range(len(indicators)//2):
assert indicators[2*i].NAME in SUPPORTED_INDICATORS, f"Error: Calculation of {indicators[2*i].NAME} is not defined"
## Attributes of ImageDataSet
if win_size == 5:
self.image_size = (32, 15)
self.extra_dates = datetime.timedelta(days=40)
else: