Wednesday, October 18, 2017

Counting Stock Trend With Numpy Array

Just shot a video to help me memorize how to do trend count with Numpy array:

a = np.array([0,0,0,1,1,1,0,0,1,0,1,1,0])

value_to_count = 1
value_to_reset = 0

no_reset = (a == value_to_count).cumsum()

reset = (a == value_to_reset)

excess = np.maximum.accumulate(no_reset*reset)

result = no_reset - access



No comments:

Post a Comment