huseinzol05 / Stock-Prediction-Models

Gathers machine learning and deep learning models for Stock forecasting including trading bots and simulations
Apache License 2.0
7.95k stars 2.81k forks source link

How to understand the code in realtime-evolution-strategy? #109

Open ppalantir opened 3 years ago

ppalantir commented 3 years ago

def get_state(parameters, t, window_size = 20): outside = [] d = t - window_size + 1 for parameter in parameters: block = ( parameter[d : t + 1] if d >= 0 else -d * [parameter[0]] + parameter[0 : t + 1] ) res = [] for i in range(window_size - 1): res.append(block[i + 1] - block[i]) for i in range(1, window_size, 1): res.append(block[i] - block[0]) outside.append(res) return np.array(outside).reshape((1, -1))

my question is why define state as this format? is there any reference for helping understanding this?