• Home
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • User/Email: Password:
  • 1:34am
Menu
  • Forums
  • Trades
  • News
  • Calendar
  • Market
  • Brokers
  • Login
  • Join
  • 1:34am
Sister Sites
  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Options

Bookmark Thread

First Page First Unread Last Page Last Post

Print Thread

Similar Threads

Neural network (deep learning) EA & some manual trades 70 replies

Best deep learning school/mentor/method 14 replies

Learning at the speed of snail [Newbie Learning Journal] 9 replies

Idea/Strategies for Modular EA Architecture 7 replies

What's your dedicated server architecture? 18 replies

  • Trading Discussion
  • /
  • Reply to Thread
  • Subscribe
  • 4
Attachments: Deep learning prediction with DeepMind's Wavenet architecture
Exit Attachments

Deep learning prediction with DeepMind's Wavenet architecture

  • Last Post
  •  
  • Page 1 2
  • Page 1 2
  •  
  • Post #1
  • Quote
  • First Post: Edited Jun 8, 2020 2:24am Jun 6, 2020 2:43am | Edited Jun 8, 2020 2:24am
  •  sinusgamma
  • | Joined Nov 2016 | Status: Member | 46 Posts
Hello,

I built a deep learning model to predict forex prices. And it gave surprisingly good results at predicting the direction of the next bar mean compared to the last bar mean.

Deep learning models are able to find patterns in large datasets with multiple features. I not only gave the model the price but generated lots of features from the tick and economic news data.

The model description can be seen here:
https://medium.com/analytics-vidhya/...5ff2e0e2e966e5
The data preparation manual here:
https://github.com/sinusgamma/probab...preparation.md

If you have any questions, suggestions, please write.

I used different output forms, direct and probabilistic as well. The image below shows some probabilistic forecast steps:
(The blue and orange are forecasts of different models, and the red vertical line is the true JPY/USD (yes, not USD/JPY) price.)

https://miro.medium.com/max/618/1*GN...P3kp9Ikng.jpeg

Update:
As PipMeUp pointed out this prediction can be considered as a kind of indicator and not a trading strategy. I didn't want to state more. Building a strategy on it requires more work, and I can't claim that it will be a profitable strategy, as I didn't make one so far.
But I hope you find the approach and the "indicator" inspiring.

Thanks
Only my scepticism keep me from being an atheist. Be sceptic ever.
  • Post #2
  • Quote
  • Jun 6, 2020 3:36am Jun 6, 2020 3:36am
  •  andydoc1
  • | Joined Jun 2020 | Status: Junior Member | 1 Post
Quoting sinusgamma
Disliked
Hello, I built a deep learning model to predict forex prices.
Ignored
Hi - thank you for that inspiration

I am a seasoned though only occasionally successful trader, mostly due to trading mostly through years of relative wealth and therefore an absence of need as a driving force. That has changed.

I have a good understanding of maths and algebra and have a history of coding and learning new languages / platforms etc on the fly - PHP, python, CSS, MySQL, r etc.

Can you direct me to the fastest free route to gain a reasonable knowledge of deep learning/ai etc. I am in the process of downloading the whole of dukas tick data in preparation for... something lol.
 
 
  • Post #3
  • Quote
  • Jun 6, 2020 9:29am Jun 6, 2020 9:29am
  •  sinusgamma
  • | Joined Nov 2016 | Status: Member | 46 Posts
Hi, math, especially statistics and linear algebra are a good start. And python knowledge is very important, as most of today's machine learning / deep learning libraries are available in python. Probably you can skip most of the "must have before machine learning" part.

I read lots of books, made online courses, participated in projects.

There are fortunately free options, and I was in a fortunate situation to win some not free course at Udacity.

My tips:
1. First, on Coursera go through the Andrew Ng course for machine learning. You can do it free if you don't want a certificate. Unfortunately, this uses Matlab instead of python, but not a great effort to use it for some exercises. https://www.coursera.org/learn/machine-learning
2. After that you can go over the coursera deep learning course by Andrew Ng: https://www.coursera.org/specializations/deep-learning
3. The first steps gave you a good perspective about what is machine learning / deep learning and what are the important building blocks. I would suggest to read this book, this is awesome, and if you want practical approaches, I think the best: https://www.amazon.com/Hands-Machine...93SP7WWP73MH89
If you buy only one book, buy this.
(If you want a more theoretical book I suggest this: https://www.deeplearningbook.org/ which is free as online book.
4. Try to make some projects.

By this time you will have enough experience to find your new next steps.

If you can afford I would suggest to go through the deep learning course of Udacity, and because of the COVID situation that is free for a month: https://www.udacity.com/course/deep-...odegree--nd101 If you can make it in a month, then you have it

In deep learning you will have the choice to use Pytorch, or Tensorflow. First I used Pytorch, but since Tensorflow 2 came out I didn't use other libraries.
Tensorflow: https://www.tensorflow.org/learn

Of course there are other good books and courses, but these are very good options to start.
Only my scepticism keep me from being an atheist. Be sceptic ever.
 
1
  • Post #4
  • Quote
  • Jun 6, 2020 10:11am Jun 6, 2020 10:11am
  •  Weyk
  • Joined Feb 2017 | Status: Member | 65 Posts
So let me guess... You have a prediction in place but when you trade it - is a loss, isn't it?
 
2
  • Post #5
  • Quote
  • Jun 6, 2020 10:34am Jun 6, 2020 10:34am
  •  sinusgamma
  • | Joined Nov 2016 | Status: Member | 46 Posts
Quoting Weyk
Disliked
So let me guess... You have a prediction in place but when you trade it - is a loss, isn't it?
Ignored
No, I didn't trade it so far. This is only a prediction, and the outputs of the different models would need different strategies to build around them. The probabilistic output would need lots of thinking about how to find the best strategy for it. This is only a half-way. But the model wasn't bad on data it never has seen before.

So to make a good strategy around it I think it would require a similar amount of work as it is in the model building. But I have to learn another API as I used before, so much more work maybe from my part.

But I had different goals with this article: proving my skills in deep learning time series modeling.
Only my scepticism keep me from being an atheist. Be sceptic ever.
 
 
  • Post #6
  • Quote
  • Jun 7, 2020 12:06am Jun 7, 2020 12:06am
  •  HeyYou
  • Joined Apr 2015 | Status: Member | 1,745 Posts
looks very interesting. first question that comes to mind is : what hardware do you use ?

are you going to prove your kills with some actual results and what are your future plans ? thanks
 
 
  • Post #7
  • Quote
  • Jun 7, 2020 1:06am Jun 7, 2020 1:06am
  •  Yashir
  • | Joined Apr 2020 | Status: Member | 70 Posts
Quoting sinusgamma
Disliked
Hello, I built a deep learning model to predict forex prices. And it gave surprisingly good results at predicting the direction of the next bar mean compared to the last bar mean. Deep learning models are able to find patterns in large datasets with multiple features. I not only gave the model the price but generated lots of features from the tick and economic news data. The model description can be seen here: https://medium.com/analytics-vidhya/...5ff2e0e2e966e5...
Ignored

Hi. Good to see your Deep learning method. I am working in AI, GA, RBF, and Deep learning field. I will study your links and want to see your work and lets together improve the method.
Can you kindly share your data and flow chat/code? I will implement it in MATLAB and will share it with you for your comments.
 
 
  • Post #8
  • Quote
  • Jun 7, 2020 3:35am Jun 7, 2020 3:35am
  •  sinusgamma
  • | Joined Nov 2016 | Status: Member | 46 Posts
Quoting HeyYou
Disliked
looks very interesting. first question that comes to mind is : what hardware do you use ? are you going to prove your kills with some actual results and what are your future plans ? thanks
Ignored
I trained it on Google Cloud with a single Nvidia K80 GPU. Training a model was some hour, but I trained much more than in the notebook. Last week it became very hard to get google GPU because everybody sitting in home office started using the cloud. Trained some models on CPU, but that was very long.

This is a portfolio project. I would be happy to work with a professional group to develop systems based on deep learning models. If not, then I will try to implement other solutions for time series from natural language processing or computer vision on my own to learn. I have so many ideas.

So short answer: I will not develop a full strategy in the next months, maybe later.

But every model and input is available on Github. I just wanted to share here the opportunities of DL, and speak with people who are interested in machine learning based systems.
Only my scepticism keep me from being an atheist. Be sceptic ever.
 
 
  • Post #9
  • Quote
  • Jun 7, 2020 3:49am Jun 7, 2020 3:49am
  •  sinusgamma
  • | Joined Nov 2016 | Status: Member | 46 Posts
Quoting Yashir
Disliked
{quote} Hi. Good to see your Deep learning method. I am working in AI, GA, RBF, and Deep learning field. I will study your links and want to see your work and lets together improve the method. Can you kindly share your data and flow chat/code? I will implement it in MATLAB and will share it with you for your comments.
Ignored
Hello Yashir,

Every code is available on github, and the data processing manual explains the pipeline:
https://github.com/sinusgamma/probab...preparation.md.

So you have the code. Just checked, unfortunately, the data files didn't make it to github, are too large.

But the tick data is available on dukascopy, and you can easily download it with Tickstory: https://tickstory.com/

It isn't too much time to run them trough the data processing notebooks.
Only my scepticism keep me from being an atheist. Be sceptic ever.
 
 
  • Post #10
  • Quote
  • Jun 7, 2020 9:16am Jun 7, 2020 9:16am
  •  PipMeUp
  • Joined Aug 2011 | Status: Member | 1,305 Posts
Quoting sinusgamma
Disliked
So short answer: I will not develop a full strategy in the next months, maybe later.
Ignored
Perhaps you should start now, in parallel. I can see some reasons for this.

The first one is to avoid taking the problem by the wrong end. I mean you will end up with a NN which will provide some prediction. In the end of the day, that's just an indicator. A complex one but an indicator. Your risk is to end up with a tool and have to force yourself to figure out what to build with it.

A second reason is that the strategy about the position management will be more important than the prediction because of the high uncertainty.

Another reason is more technical and I see it as an opportunity. You create the predictor using DL then I think it makes sense to build the strategy in the same way. Building both at the same time allows you to feedback the predictor with trading results (they become part of the input). If your predictor becomes a trend estimator the strategy will probably converge to a trend follower and require the predictor to focus on better predicting the trend.

I read your blog and I would like to see two things on the pictures at the end (copied below).
1- The confidence interval around the prediction (on my own results it is HUGE)
2- Several consecutive predictions to see how variable it is.
=> I made a simple predictor and when I cherry pick the right one the prediction can be uncanny ;-) yet it often changes from bearing to strongly bullish in a single bar and change its mind again on the next!

Attached Image (click to enlarge)
Click to Enlarge

Name: forecast.png
Size: 109 KB
No greed. No fear. Just maths.
 
2
  • Post #11
  • Quote
  • Jun 7, 2020 10:09am Jun 7, 2020 10:09am
  •  sinusgamma
  • | Joined Nov 2016 | Status: Member | 46 Posts
Thanks for the long post PipMeUp.

You have a very good point, this is only an indicator. And it predicts only the next 5-minute bar means, which makes the indicator harder to use than another predictor which predicts some value at a specific time. But this averaging decreased the volatility of the forecasted variable, and the model had an easier time to find some patterns.

For a strategy I should train other models, but not very different, than this. I wouldn't try to forecast open or close prices, because they are the hardest. But would try to forecast the high, low, first quartile, and third quartile of the bar as well. That would help a lot, with that indicators it would be easier to develop a strategy, find TP and SL levels . . . Building a model that predicts all these at once even can help better generalize, but that can't be known beforehand. So some days of GPU computing is needed.

And I should use the bid price as well, make the same features, and make up some promising cross features (spread, slippage, and others) from the bid and ask price. That should further help the model.

After that should come the strategy building. First I would go for a more conservative strategy, not DL based. Of course, reinforcement learning which gets the inputs would be nice, but that would be a very long time to develop, and maybe a not ML-based strategy would suffice.

About confidence interval:
For the directional Relu method, I didn't show a confidence interval, you are right. An easy metric to determine some uncertainty is the mean average error itself. And we can fit a normal distribution to the validation errors, and get the inner 95 percent for a broad confidence interval.
For the last models with probabilistic outputs, we get distributions as forecast (we get the means and standard deviations of the subdistributions). So at every step, it is possible to calculate confidence interval with any level from the means and standard deviations forecasted for that specific time, and every timestep has its own confidence interval based on the input parameters. From the picture I inserted above https://miro.medium.com/max/618/1*GN...P3kp9Ikng.jpeg is hard to get these confidence levels, should have indicate the 50 and 95 percent levels for better judgment.

Yes, I should find some time to further improve the models, thanks.
Only my scepticism keep me from being an atheist. Be sceptic ever.
 
 
  • Post #12
  • Quote
  • Jun 7, 2020 3:56pm Jun 7, 2020 3:56pm
  •  FXEZ
  • Joined Jan 2007 | Status: developing... | 970 Posts
Thanks for posting this thread. There have been some interesting articles on medium lately. I followed a different one through recently for R that used tensorflow but after implementing it had no idea what to make of it. Maybe this thread will give me the motivation to finally make the full jump into Python as that seems to be where all the best new packages are coming from.

Thanks for the book recommendation. Hopefully I can get up to speed by running through the examples in it as I follow along with your progress. Are you working solely in Python? Most of my development is now in C# - I have a nifty interface for R but will need something like that to transfer data to/from Python. I know Visual Studio has some nice features for Python - not sure how easy it is to interface from C# to Python though.

I changed computers and so basically need to install Python from scratch. Do you suggest Anaconda or other method to get most of the necessary packages?
 
 
  • Post #13
  • Quote
  • Jun 7, 2020 3:59pm Jun 7, 2020 3:59pm
  •  kodakwhite
  • | Joined Sep 2016 | Status: Member | 166 Posts
That the level of trading I like to see, I'm think this is the first thread that I can approve.
 
1
  • Post #14
  • Quote
  • Jun 7, 2020 5:12pm Jun 7, 2020 5:12pm
  •  sinusgamma
  • | Joined Nov 2016 | Status: Member | 46 Posts
FXEZ, I was in a similar situation as you are. Had some experience with C#, made excel data analysis with VB, and used Java. I didn't like Python at all. I was searching for options to use C# or Java for these kinds of things, and I found some, like https://deeplearning4j.org/. But with these languages, I found too many compromises. And Python was everywhere. So I started to code in Python. They say that this is easier than lots of other languages, but I think after more strict, more OOP languages it can seem a mess. Now, that I start to forget Java and C# (didn't use them for a long time), I start liking python, but I would change for another more elegant and effective language if it had the libraries and community. My knowledge isn't on the level of a python software developer, but in ML/DL I have enough experience to make things done.

For IDE Visual Studio is ok if you really know its features (what I don't). But if you want something only for python PyCharm is more focused. But my favorite is Visual Studio Code. It is much smaller than visual studio, and VSC has notebook like features, which are very convenient if you are experimenting with datasets, models and parameters, and you are jumping from one part to the other in the code. More here: https://code.visualstudio.com/docs/p...ience-tutorial and https://code.visualstudio.com/docs/p...upyter-support(Here I have to admit, that I liked Java for building software where you know what exactly are you building, but for experimenting python and the notebook structure is easier, and a good place to forget every elegant pattern )

I suggest Anaconda, and the Anaconda navigator as well. With the navigator, it is very easy to manage the environments. Pip can be also ok. I mostly use anaconda, maybe doesn't really matter which.
Only my scepticism keep me from being an atheist. Be sceptic ever.
 
1
  • Post #15
  • Quote
  • Jun 7, 2020 5:50pm Jun 7, 2020 5:50pm
  •  MathTrader7
  • Joined Aug 2014 | Status: Trading | 2,142 Posts
Quoting sinusgamma
Disliked
Hello, I built a deep learning model to predict forex prices. And it gave surprisingly good results at predicting the direction of the next bar mean compared to the last bar mean. Deep learning models are able to find patterns in large datasets with multiple features. I not only gave the model the price but generated lots of features from the tick and economic news data. The model description can be seen here: https://medium.com/analytics-vidhya/...5ff2e0e2e966e5...
Ignored
As a person who has spent a lot of time and effort to employ Machine Learning (ML) paradigms in live trading Forex and stock markets, I can surely say that any ML based prediction without an actual trading strategy that can be back-tested won't reflect on the profitability of the predictions. Just my 2 cents.

Best,
Matt
Trading is the hardest way to make easy money...
 
 
  • Post #16
  • Quote
  • Jun 7, 2020 8:54pm Jun 7, 2020 8:54pm
  •  jobushi
  • | Joined Jan 2019 | Status: Member | 5 Posts
First of all, the price action of forex is a random walk. Using machine learning to predict forex price is like predicting a random number.

My 2 cents: Maybe we can try reinforcement learning (RL), let the computer automatically search for a set of EA strategies that can make a long-term profit according to the principle of maximizing profits, but the calculation would be very huge, and it may need to run several Months or even years on ordinary computers.
 
 
  • Post #17
  • Quote
  • Jun 8, 2020 12:49am Jun 8, 2020 12:49am
  •  kodakwhite
  • | Joined Sep 2016 | Status: Member | 166 Posts
Quoting jobushi
Disliked
First of all, the price action of forex is a random walk. Using machine learning to predict forex price is like predicting a random number. My 2 cents: Maybe we can try reinforcement learning (RL), let the computer automatically search for a set of EA strategies that can make a long-term profit according to the principle of maximizing profits, but the calculation would be very huge, and it may need to run several Months or even years on ordinary computers.
Ignored

It's not random boya and there is no such thing at random anywhere
 
1
  • Post #18
  • Quote
  • Jun 8, 2020 2:29am Jun 8, 2020 2:29am
  •  sinusgamma
  • | Joined Nov 2016 | Status: Member | 46 Posts
MathTrader7, I agree with you. The article shows a technique, which can be used with very different datasets and outputs. I hope it is inspiring for the reader. This isn't a strategy, closer to an indicator. Just updated the main post to avoid misunderstanding.
Only my scepticism keep me from being an atheist. Be sceptic ever.
 
1
  • Post #19
  • Quote
  • Jun 8, 2020 2:40am Jun 8, 2020 2:40am
  •  sinusgamma
  • | Joined Nov 2016 | Status: Member | 46 Posts
Jobushy, if it were a pure random walk the price wouldn't react to the events of the world. From the view of an uninformed observer, it can seem randomish, but even without any information about politics, economy, disasters the price movement has more robust patterns than a random walk (which doesn't have).

If you aren't tossing a fair dice to decide trading action, then you are trying to find these patterns, even if you don't think about your actions this way.

This article has some nice charts to compare random walk to forex: https://www.dukascopy.com/fxcomm/fx-...15&language=en
Only my scepticism keep me from being an atheist. Be sceptic ever.
 
1
  • Post #20
  • Quote
  • Jun 8, 2020 4:31am Jun 8, 2020 4:31am
  •  BlackGear
  • | Joined Apr 2016 | Status: Junior Member | 1 Post
Nice work, I have done similar thing with DL to predict the market direction for the next minute and I achieved accuracy of 60%. But unfortunately this isn't tradable and I couldn't get good results for higher time frame. Overall, No the market is not random.
 
1
  • Trading Discussion
  • /
  • Deep learning prediction with DeepMind's Wavenet architecture
  • Reply to Thread
    • Page 1 2
    • Page 1 2
0 traders viewing now
  • More
Top of Page
Forex Factory Blog Updated: Alerting All Members
  • Facebook
  • Twitter
About FF
  • Mission
  • Products
  • User Guide
  • Media Kit
  • Blog
  • Contact
FF Products
  • Forums
  • Trades
  • Calendar
  • News
  • Market
  • Brokers
  • Trade Explorer
FF Website
  • Homepage
  • Search
  • Members
  • Report a Bug
Follow FF
  • Facebook
  • Twitter

FF Sister Sites:

  • Metals Mine
  • Energy EXCH
  • Crypto Craft

Forex Factory® is a brand of Fair Economy, Inc.

Terms of Service / ©2022