Machine learning in trading: theory, models, practice and algo-trading - page 1344

 
sibirqk:

If it is not a secret, on what principles is the artificial series made? Is it just a roughly sine wave mixed in with the noise, or somehow more complicated?

If I have several questions for my post, I need to answer them all at once.

This is the forum for trading, automated trading systems and testing of trading strategies.

Theories and Practices of Machine Learning in Trading (Trading and Not Only)

Yuriy Asaulenko, 2019.02.17 21:01

Tried to train a neural network on Python. Package - scikit-learn, NS itself - sklearn.neural_network.MLPRegressor. Over 100 neurons, 7 hidden layers, 19 inputs, 1 output. The task is to predict a random process.

The task is artificial, made on noise generator, and so that theoretically this noise can be predicted. I tried it for several counts ahead.

Result of comparing forecast with real for 5 thousand randomly chosen points:

X is the forecast, Y is the real value. They all lie very close to a 45 degree straight line. That is, the prediction is almost perfect (on an artificial sample).

Learning is very fast, 24 epochs. Time is about 10 seconds.

I must say, I was very surprised. I tried very hard to hide the data. Surprised that she found it. In general, close to mysticism).

Conclusions: The NS sklearn.neural_network.MLPRegressor is quite usable. I haven't tried the classifier yet.

I have already tried something with the market, no results so far. It's not looking for it, it says there is nothing there, even though I have the same class as the artificially generated task.

I should say right away that I did not invent perpetual motion machine and did not play any tricks on it.

In the beginning, a little theory. Random processes can be predicted, including even flipping a coin. It all depends on the formulation of the prediction problem. Let us say that the forecast "It will rain tomorrow" is 90% correct. However, we do not say when it will rain - early in the morning, afternoon or late at night, or it may even pour all day, because this forecast will be unreliable.

Is it possible to predict time series - it is possible, under certain conditions. One of such possible conditions is a limited VR spectrum - the wider the spectrum, the smaller the forecast interval, the narrower - the longer the forecast interval.

The market time series has an infinite spectrum, so you can't really predict the price for 5 minutes or an hour in advance. I haven't set such a task for myself.

Now to prepare the data for training.

We obtain a series from the random number generator (RNG) and transform it into a form similar to the market one. Such a series has an unlimited spectrum and it is not realistic to predict its values.

2. we pass the series through low pass filter (LPF). You have received a random series with a limited spectrum and possibility to predict for n-counts ahead, however it is not very similar to the market series.

3. We generate series with M=0 by the RNG and add it to the series after the LPF, after some tambourine play. We again obtain a series close to the market one. We will use this series for training.

4. As the target function we take the series in step 2 passed through the LPF and shifted by N samples backward that corresponds to the forecast for N samples forward.

Then we feed input and target series to NS, train and check training results. Then repeat steps 1-4, fed series in step 3 to the NS and compare the output of the NS with a series shifted by N samples in step 4.

That's it. No miracles. You can do it all without the NS. What surprised me was that the NS did it in seconds, and in just 24 loop of training. And that's with a lot of noise, you can't even see the low frequency component there. That's amazing.

Why didn't it work with the market BP? Any LPF has significant delays, and its curve is shifted to the right relative to BP. That is, we have a delayed LF signal at every point in the series, and thus the prediction interval is larger than allowed, and the prediction becomes unrealistic. We can't even build a real target for training.

 

Yuriy Asaulenko:

The concept of spectrum is defined only for a stationary process. The price is not, at least because of the growth of dispersion with time.

 
Aleksey Nikolayev:

The notion of a spectrum is defined only for a stationary process. Price is not, if only because of the growth of dispersion with time.

This is from the cycle of "a little elder in a kitchen garden, but a little uncle in Kiev.
This is out of the question.
 
Yuriy Asaulenko:
This is from the cycle of the elderly in a garden, and the uncle in Kiev.
Out of the question.

Okay, I won't stop you from selling Stradivarius drums.

 
Aleksey Nikolayev:

Okay, I won't stop you from selling Stradivarius drums.

Well, okay, I'll take pity. )) Almost any radio signal is a non-stationary process, but has a spectrum. The concept of spectrum has nothing to do with stationarity.
You should go to the T.P. branch, to the fantasists.)
 

Getting prices in Python via socket almost instantly (50k records) in 10 lines of code

and on the mt5 side 20

I don't need these improvised libs for R. Why is it so hard to do it yourself? Thank you for native sockets in mt5.

i can add any functions very easily, whether it's signals to open trades or something else.

 
Maxim Dmitrievsky:

Getting prices in Python via socket almost instantly (50k records) in 10 lines of code

and on the mt5 side 20

I don't need these improvised libs for R. Why is it so hard to do it yourself? I'm thankful that native sockets work in mt5.

(Yes, it does.)

I see that they have switched to Spyder. That's right, it's better than fooling around in your notebook.

Just in case. The grid on the chart is done by plt.grid().

 
Yuriy Asaulenko:
Well, okay, I take pity. )) Almost any radio signal is a non-stationary process, but has a spectrum.
You should go to the branch of Tip, to the fantasists.)

Radio amateurs confuse a random process with its realization.

 
Aleksey Nikolayev:

Radio amateurs confuse a random process with its implementation.

I will not argue with trolls.

 
Yuriy Asaulenko:

That's for sure.)

I see you switched to Spyder. That's right, it's better than messing around in your notebook.

The grid on the graph is made by plt.grid().

i had to tinker with spyder to put it on bare python, without anaconda.

i had vscode before, but it drains the laptop battery very quickly, i have to reach for the socket

Reason: