[PYTHON] Modélisation de données point et figure

In the meantime, I found a source for PYTHON, and I decided to use it as a reference.

Reference Source https://medium.com/veltra-engineering/python-nikkei-quandl-api-2-2ae2002e361c

I decided to use the market data from the source I referred to before. https://www.alphavantage.co/

Testing We obtained the original sequence of P&Fs from the daily data of EURUSD. The reference number of blocks (cell height) was set to (MAX-MIN)/200 for the entire range. The data length was 5000 rows before compression, but the P&F sequence was 531.


eurusd_daily

date,1. open,2. high,3. low,4. close,5. volume
2001-09-20,0.9299,0.9308,0.9224,0.9257,0.0
2001-09-21,0.9258,0.9281,0.9088,0.913,0.0

....

2020-11-18,1.1862,1.1891,1.1847,1.1852,0.0
2020-11-19,1.1851,1.1852,1.1821,1.1823,0.0

(Pdb) len(histories)
531
[3, -11, 6, -6, 6, -11, 5, -4, 6, -4, 12, -4, 24, -5, 11, -8, 4, -9, 5, -4, 7, -7, 5, -5, 11, -6, 16, -4, 12, -3, 4, -4, 7, -11, 8, -6, 21, -4, 12, -5, 5, -5, 6, -10, 4, -10, 9, -17, 13, -3, 15, -4, 4, -10, 13, -4, 23, -10, 8, -6, 4, -6, 11, -8, 4, -12, 5, -4, 4, -8, 7, -10, 4, -9, 9, -10, 12, -7, 11, -11, 9, -10, 10, -5, 28, -5, 4, -4, 9, -16, 6, -14, 13, -4, 9, -17, 7, -26, 7, -7, 4, -7, 9, -5, 4, -4, 11, -8, 10, -14, 6, -5, 5, -11, 4, -4, 7, -5, 8, -3, 7, -11, 4, -4, 7, -6, 8, -5, 21, -5, 5, -9, 6, -6, 8, -4, 4, -8, 19, -6, 4, -9, 9, -4, 15, -9, 11, -4, 4, -8, 20, -4, 6, -3, 12, -4, 8, -6, 4, -11, 13, -9, 9, -10, 32, -7, 10, -6, 9, -15, 9, -9, 9, -10, 13, -4, 6, -29, 4, -23, 9, -5, 18, -33, 4, -6, 5, -20, 4, -10, 10, -8, 8, -10, 6, -8, 15, -10, 45, -12, 4, -13, 4, -15, 4, -9, 8, -10, 6, -6, 6, -12, 8, -7, 30, -12, 8, -8, 6, -11, 8, -6, 16, -4, 13, -4, 12, -11, 5, -3, 4, -8, 8, -4, 6, -7, 9, -5, 10, -8, 17, -5, 12, -7, 4, -4, 8, -4, 8, -22, 7, -22, 4, -4, 4, -6, 6, -11, 5, -5, 9, -13, 4, -17, 4, -15, 9, -10, 6, -11, 10, -5, 19, -5, 
14, -14, 4, -6, 6, -5, 35, -9, 6, -4, 11, -18, 5, -17, 10, -4, 4, -7, 7, -13, 21, -3, 5, -8, 12, -5, 10, -3, 10, -6, 14, -18, 5, -7, 17, -13, 6, -6, 9, -15, 7, -3, 11, -9, 5, -8, 6, -4, 6, -6, 8, -3, 5, -21, 5, -11, 4, -11, 17, -4, 11, -16, 4, -12, 6, -19, 12, -4, 5, -5, 9, -9, 4, -6, 9, -8, 4, -21, 6, -3, 6, -6, 5, -14, 5, -3, 24, -7, 4, -4, 6, -9, 9, -4, 7, -5, 14, -15, 4, -6, 4, -6, 10, -4, 4, -7, 13, -14, 15, -3, 4, -7, 17, -9, 9, -5, 4, -6, 11, -5, 5, -9, 4, -29, 7, -9, 4, -5, 6, -31, 6, -4, 4, -22, 6, -4, 8, -6, 6, -10, 18, -4, 7, -13, 9, -4, 7, -15, 7, -5, 7, -3, 15, -13, 7, -6, 7, -23, 11, -8, 5, -3, 13, -10, 11, -4, 5, -3, 7, -10, 7, -9, 4, -5, 7, -4, 6, -10, 7, -13, 5, -10, 9, -3, 4, -7, 8, -7, 11, -3, 11, -3, 16, -3, 7, -10, 8, -5, 9, -3, 14, -7, 7, -9, 6, -4, 5, -20, 6, -5, 4, -10, 9, -4, 6, -14, 5, -3, 4, -4, 6, -6, 4, -5, 4, -6, 5, -5, 4, -3, 5, -8, 4, -8, 7, -4, 5, -11, 17, -20, 13, -8, 5, -5, 5, -5, 5, -3, 12, -5, 17, -3, 5, -6, 5, -5, 6]

Block Reference Number and Data Compression

If we now consider the characteristics of P&F charts carefully, we realize that this is a way to compress the data. If you increase the number of reference feet in that case, the data length will probably be smaller.  In general, the granularity of data in a currency chart changes depending on the length of the reference foot, such as daily, weekly or monthly. However, the P&F chart is based on the concept of updating to the next leg only when the trend has turned, so the leg is not updated uniformly with the time update.

Multi-Time Frame Analysis

In addition, for general technical indicators, it is common to use multiple time scales for a reference foot to comprehensively determine the market's phase, and a technique called multi-time frame analysis exists.  Since varying the reference number of blocks has the characteristic of changing the data length, multi-block analysis, which is based on multiple reference number of blocks, is considered to be effective for the concept of multi-frame in P&F.

AI Algorithm

In addition, recurrent learning (recurrent networks), which takes into account the influence of past data, is used as a general theory for AI learning on general time series data, and it is considered effective for cyclical fluctuations such as market ranges. However, in the case of exchange rate fluctuations, it is considered to be most important to capture the trend changes by key technical signs (breakout as the starting point), and thus requires conditional judgments based on a combination of patterns rather than recurrent learning. We think it makes sense. (To begin with, we can assume that the RNN is computationally expensive compared to normal AI analysis.

In this article, I will try to tune the parameters by adding multiple block reference numbers to the factors that make up the various hyperparameters.

The model

Looking at the characteristics of PF, we can see the following

×The x's and z's are always repeated ×→In the change from x to 0, starting from one step down In the change from 0 to x, starting from one step up

This feature can be completely ignored.

For now, the following P&F chart will show ×If you replace the number of x's with positive numbers and the number of z's with negative numbers

This chart equals the following sequence of numbers.

Fig94.gif

12 , -7 , 7 , -5 , -5 , 5 , -3 , 12 , -5 , 5 , -5 , -5 , 6 , -6 , 3 , -6 , 2

Furthermore, taking the sum of the front and back 5 , 0 , 2 , 0 , 2 , 2 , 9 , 7 , 0 , 0 , 0 , 1 , 0 , -3 , -3 , -4 max = 9 , min = -4 , Range = 13

The dynamic range can be reduced, as in In AI, this is the direction of increasing the sensitivity of the learning machine.

By the way, it appears that doing it again is a no-no

5 , 2 , 2 , 2 , 11 , 16 , 7 , 0 , 1 , 1 , -3 , -6 , -7 max = 16 , min = -7 , Range = 23

And AI-wise, if you can predict the following numbers You can know the turning points of a trade position.

The best thing about P&F charts is that they In this way, every possible price movement in a string of numbers It's an interwoven point.

So, now that we've finished defining the model first, let's go to From the above sequence of numbers from the exchange data Coding shall be done.

http://1969681.blog66.fc2.com/blog-entry-592.html

Recommended Posts

Modélisation de données point et figure
Théorie et implémentation de PointNet (données de groupe de points)
Avec les types de données algébriques et FizzBuzz
Extraire les données csv et calculer
Mémo «Chapitre 5 - Dictionnaires et structuration des données»
Avec les types de données algébriques et la correspondance de modèles
Hashing de données en R et Python
À propos des données de séries chronologiques et du surentraînement
Avec les types de données algébriques et la programmation orientée objet
Les bases d'Open3D et la boxe de groupe
Extraire les données et les compétences de Pokemon GO Pokemon
Introduction à la modélisation statistique pour l'analyse des données Test de rapport de ressemblance GLM et asymétrie de test