INNER CODE UNIT · Python
price_slice
RichardS0268/CNN-for-Trading · dataset.py:72
price_slice = price_slice.apply(lambda x: x*(25-1)+7).astype(int)
volume_slice = volume_slice.apply(lambda x: x*(6-1)).astype(int)
else:
price_slice = price_slice.apply(lambda x: x*(51-1)+13).astype(int)
volume_slice = volume_slice.apply(lambda x: x*(12-1)).astype(int)
image = np.zeros(image_size)
for i in range(len(price_slice)):
# draw candlelist
image[price_slice.loc[i]['open'], i*3] = 255.
image[price_slice.loc[i]['low']:price_slice.loc[i]['high']+1, i*3+1] = 255.
image[price_slice.loc[i]['close'], i*3+2] = 255.
# draw indicators
for ind in ind_names:
image[price_slice.loc[i][ind], i*3:i*3+2] = 255.
# draw volume bars
if show_volume:
image[:volume_slice.loc[i]['volume'], i*3+1] = 255.