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

 

What do you think, how do you work with recursion?

With lstm.

+import numpy as np
+from keras.preprocessing import sequence
+from keras.models import Sequential
+from keras.layers import Dense, Activation, Embedding
+from keras.layers import LSTM
+from keras.datasets import imdb
+
+# Устанавливаем seed для повторяемости результатов
+np.random.seed(42)
+# Максимальное количество слов (по частоте использования)
+max_features = 5000
+# Максимальная длина рецензии в словах
+maxlen = 80
+
+# Загружаем данные
+(X_train, y_train), (X_test, y_test) = imdb.load_data(nb_words=max_features)
+
+# Заполняем или обрезаем рецензии
+X_train = sequence.pad_sequences(X_train, maxlen=maxlen)
+X_test = sequence.pad_sequences(X_test, maxlen=maxlen)
+
+# Создаем сеть
+model = Sequential()

How to control the input, what to loop loop

 
+# Создаем сеть
+model = Sequential()
+# Слой для векторного представления слов
+model.add(Embedding(max_features, 32, dropout=0.2))
+# Слой долго-краткосрочной памяти
+model.add(LSTM(100, dropout_W=0.2, dropout_U=0.2))  # try using a GRU instead, for fun
+# Полносвязный слой
+model.add(Dense(1, activation="sigmoid"))
+
+# Копмилируем модель
+model.compile(loss='binary_crossentropy',
+              optimizer='adam',
+              metrics=['accuracy'])
+
+# Обучаем модель
+model.fit(X_train, y_train, batch_size=64, nb_epoch=7,
+          validation_data=(X_test, y_test), verbose=1)
+# Проверяем качество обучения на тестовых данных
+scores = model.evaluate(X_test, y_test,
+                        batch_size=64)
+print("Точность на тестовых данных: %.2f%%" % (scores[1] * 100))
 
Top2n:
Already tried everything

register athttp://ru.stackoverflow.com the resource is specially designed for asking questions on programming, on any language, at any time, and at the same time we will expand the base of correct answers in russian

Stack Overflow на русском
Stack Overflow на русском
  • ru.stackoverflow.com
Вот как это работает: Любой может задать вопрос Любой может ответить Лучшие ответы получают голоса и поднимаются наверх
 
Top2n:

What do you think, how do you work with recursion?

With lstm.

+import numpy as np
+from keras.preprocessing import sequence
+from keras.models import Sequential
+from keras.layers import Dense, Activation, Embedding
+from keras.layers import LSTM
+from keras.datasets import imdb
+
+# Устанавливаем seed для повторяемости результатов
+np.random.seed(42)
+# Максимальное количество слов (по частоте использования)
+max_features = 5000
+# Максимальная длина рецензии в словах
+maxlen = 80
+
+# Загружаем данные
+(X_train, y_train), (X_test, y_test) = imdb.load_data(nb_words=max_features)
+
+# Заполняем или обрезаем рецензии
+X_train = sequence.pad_sequences(X_train, maxlen=maxlen)
+X_test = sequence.pad_sequences(X_test, maxlen=maxlen)
+
+# Создаем сеть
+model = Sequential()

How to control the input, what to loop

Judging by these code snippets you want to investigate/solve the text prediction problem. Here are some questions:

  • What does this have to do with trading?
  • How do you expect to link the Python code to MT4/5?

Of course LSTM relates to machine learning models, but textMining to trading?

If you have experience and know-how in the subject, start a new thread, like: TextMiningPython. If there are enthusiasts, they will support you. I will follow the development with interest. But start with a more intelligible description of the input and target data, links to the sources where you get the data and the problem you want to solve. Since your post to understand what it's about can only be a very high-level psychic.

Good luck.

 

there is a service from google called google correlatehttps://www.google.com/trends/correlate

It can search for correlated user queries, queries are presented in the form of BP. The interesting service is that you can load your BP into it and it will search for such queries that correlate with the specified BP.

The idea is to load there the symbol price and see what it correlates with, it may be useful for searching new predictors, of course, I understand that correlation is a very crude way to find links, but it's still interesting ....

So, the problem is that I do not understand in what form the service should feed the data with the price of the instrument, maybe someone will figure it out and tell me how to prepare the data and in what form they should be

added...........

Here is another article, which will give you a deeper understanding of the service of googlehttp://forbes.net.ua/opinions/1336134-google-pomogaet-ustanovit-zhdut-li-ukraincy-krizisa

the article shows that a strong correlation has been found between the indicators ofthe dynamics of real industrial production

in Ukraine withthe search query ofthe word combination "consumer credit" in Ukraine

Google Correlate
  • www.google.com
Google Correlate finds search patterns which correspond with real-world trends.
 
mytarmailS:

there is a service from google called google correlatehttps://www.google.com/trends/correlate

It can search for correlated user queries, queries are presented in the form of BP. The interesting service is that you can load your BP into it and it will search for such queries that correlate with the specified BP.

The idea is to load there the symbol price and see what it correlates with, it may be useful for searching new predictors, of course, I understand that correlation is a very crude way to find links, but it's still interesting ....

So, the problem is that I do not understand in what form the service should feed the data with the price of the instrument, maybe someone will figure it out and tell me how to prepare the data and in what form they should be


The correlation is great, but I remember such indicators as entropy and something else I even do not remember, and here I suddenly wanted to raise the records...... Maybe something useful will come out of it....
 
mytarmailS:

there is such a service from google...

interesting, here's the code, but google didn't find anything correlative

library(lubridate)
library(rusquant) #install.packages("rusquant",  repos="http://R-Forge.R-project.org")


#для  недельных баров, сдвиг на одну дату назад ибо в сша первый день недели это воскресенье
getSymbols("EURUSD",src = "Finam", period="week", from = 0)
eurusdTime <- as.character(ymd(time(EURUSD))-days(1))


# #для  месячных баров
#  getSymbols("EURUSD",src = "Finam", period="month", from = 0) #месячные  бары вместо недельных
#  eurusdTime <- as.character(ymd(time(EURUSD))) #для  месячных баров



#либо  первый вариант, либо второй, зависит от того как в гугле данные относятся к дате - с отставанием или опережением. я не знаю.
eurusdOpen <- as.numeric(scale(c(diff(as.numeric(EURUSD$EURUSD.Open))[-1], 0, 0)))
#  eurusdOpen <- as.numeric(scale(c(diff(as.numeric(EURUSD$EURUSD.Open)), 0)))


write.table(matrix(c(eurusdTime,eurusdOpen), ncol=2), file="table.csv", sep=",", dec=".", row.names = FALSE, col.names = FALSE)

 
Dr.Trader:

interesting, here's the code, but google didn't find anything correlated

Thank you!!!

There is no need to differentiate there, it loses the structure of the series and the trend, you don't need to correlate either, correlation in calculations levels out the absolute values... The maximum you can do is to remove the trend in order to find some seasonal effects, but it's hard to know whether you need it...

Try it and it will work

library(lubridate)
library(rusquant) #install.packages("rusquant",  repos="http://R-Forge.R-project.org")


#для  недельных баров, сдвиг на одну дату назад ибо в сша первый день недели это воскресенье
getSymbols("EURUSD",src = "Finam", period="week", from = 0)
eurusdTime <- as.character(ymd(time(EURUSD))-days(1))


eurusdOpen <- as.numeric(EURUSD$EURUSD.Open)


DT <- matrix(c(eurusdTime,eurusdOpen), ncol=2)


write.table(DT,file="table.csv", sep=",", dec=".", row.names = FALSE, col.names = FALSE)

It's true, the connections are strange to say the least )) From hip-hop forums to inquiries about horses :)

The question is how to identify what is the real connection and what is just a coincidence

Документация по MQL5: Математические функции / MathAbs
Документация по MQL5: Математические функции / MathAbs
  • www.mql5.com
Математические функции / MathAbs - справочник по языку алгоритмического/автоматического трейдинга для MetaTrader 5
 
mytarmailS:

There is no need to differentiate there, you lose the structure of the series and the trend

Right, yes. Google can't do that, it only looks for correlation with other trends, not with their increases, sorry, it doesn't turn out as useful.

mytarmailS:

you don't need to scale either.


It needs to, according to the FAQ (mean=0, sd=1, just what scale does). Although judging by the trend graph, google itself does scale for you in case you forgot.

 
Скриншот
Скриншот
  • prnt.sc
Снято с помощью Lightshot