Motorcycle Week

I grew up in rural NH which plays host each summer to a weeklong event known as Motorcycle Week. Thousands of rotund bikers with their particular lady partners descend upon the region like a swarm of…

Smartphone

独家优惠奖金 100% 高达 1 BTC + 180 免费旋转




Predicting the Stocks using Machine Learning and Deep Learning

Stocks or shares are those into which the ownership of the cooperation is divided. A single stock represents fractional ownership of the cooperation and there will be digital ownership, not physical ownership.

The challenge is to predict the return of a stock, given the history of the past few days. let’s be honest we are just predicting the future stocks so As per the given data we try to predict whether the stock goes up or down. There may be several external factors that play a role in real-time but we try to make it as similar to real-time as possible.

How these returns are calculated is defined by Winton, and will not to be revealed to us in this competition. We will have previous 2 days (D-2, D-1) stock values and current day 120 returns for a minute in the current day we need to predict the next 60 returns and D+1, D+2 returns.

Stock Market Returns are the returns that the investors generate out of the stock market. This return could be in the form of profit through trading or in the form of dividends given by the company to its shareholders from time-to-time. In this competition, there are 2 types of returns which are Intraday and Daily return.

Submissions to this competition are judged on the basis of weighted mean absolute error between predicted stock values and actual stock values.

The file should contain a header and have the following format:

Submission file format

As we can see the given data is a time-series data and the given data has a lot of empty values so fill them with mean of the particular columns.

Here in the train data for one particular row, we have 211 features in training data.

Target Variables:

NaN Value Count vs 211 features

2. Most of the return values are in between 0.01 and -0.01. Which we can see in the below images which are the plot of the first 16 return values of the given data.

3. We have plotted the Fourier transforms in the below image and we can see that there are very few peaks only in some returns.

Fourier transform plots of first 9 return values

4. Plotting the Histogram of Intraday returns and Daily returns. A histogram shows the frequency on the vertical axis and the horizontal axis is another dimension.

Here I tried below ML algorithms:

2. Linear regression: It is the simplest algorithm that took very less time to train and MSE is also less but not as much as XGboost. From the below image we can interpret the variance of predicted value and actual value.

Linear regression failed to predict extreme changes.

A plot between the predicted and actual value of intraday returns

3. RBF kernel SVR : Below is the RBF hyper tuning of the graph in which has less MSE value when C is 10e2 and compared to the above models RBF kernel performed poorly after hyperparameter tuning.

The plot between c-value and MSE error

As the given data is a time-series data I tried feature engineering with Fourier transforms with the above mentioned models but the performance metric didn’t improve so I moved to the Deep learning algorithms.

As this is a sequence data, RNN works better but recently in many competitions LSTM as outperformed many RNN algorithms.

2. LSTM with 2 Hidden layers :

3. LSTM with 4 Hidden layers :

4. LSTM with 4 Hidden layers and batch normal layers :

Out of 852 teams that used this data, only 370 (43%) did better than predicting 0 for every stock price.

For Daily Returns, XGboost has less MSE and LSTM’s worked well for sequence data. But After multiple submissions LSTM with masking layer as a much better score than the rest of the models.

Add a comment

Related posts:

Introducing our new filters

At Task Analytics we’re all about making sense of your data. That can often mean digging down to open up new insights. With the new filters, examining your data is quicker, easier and more powerful…

Setting Realistic Expectations With Your Chosen SEO Company

Regardless of your business’s size or industry, working with a third-party SEO company can be incredibly rewarding. You save a significant amount of time, money, and effort by letting professionals…

Lessons from Zelenskyy Deepfake

Some of you have probably seen the emergence of news articles covering the take down of Ukranian President Volodymyr Zelenskyy’s deepfake, a minute long video where he was asking the Ukranian…