# Future Prediction of Call and Put Prices using Deep Learning by generating data

# Introduction:

Stock market prediction has been one of the most widely used applications of Deep Learning next to computer vision. These will be used in various hedge funds to generate maximum returns on investments. The problem we are addressing is that the lack of data for future dates i.e we will not have the real time data for future dates. We will be generating predictions for future dates for which we don't have data. This can be implemented for any of the stock prices given we give related industries as our inputs.

In this blog, I will demonstrate the prediction for AMD by taking few other company stock price data. Please note that for future dates we will not get any data related to news polarity(.i.e fundamental data) we will only make predictions by using technical data.

# Data:

We consider training data from 01/01/2010 to 05/31/2020, all the data has been acquired from Tingo API. Please consider the as of date is 05/31/2020. This is because as of writing this blog we could get the data till 10/11/2020, but we want some ground truth data to compare with.

Let's look at the data from 2010.

We can see as usual the stock has been on since 2007 financial crisis and since 2017 its been improved by quite a lot due to the announcement of Ryzen line up of CPUs. For this model, we are going to consider various other company data as well. We can't consider that AMD is the only company, in the financial world all companies are related to each other.

Ex: AMD and Intel are rival companies and most the days the movements are inversely proportional.

So we will consider the stock closing price for companies like Intel(INTC), Nvidia(NVDA), Microsoft(MSFT), Qualcomm(QCOM), TSMC(TSM), S&P ETF(SPY).

# Objective:

We will predict the AMD stock price for the next 10 days i.e from 06/01/2020 to 06/12/2020 without looking at the future data.

**Technical Features:**

By using the closing prices of the target company, we add few financial technical indicator features.**7 day Moving Average:** It's a rolling 7 day moving average. It's a feature that is a lot closer to the actual stock price.**21 day Moving Average:** It's the same as 7 day Moving Average but the window width is larger of 21 days.**Moving Average Convergence and Divergence:** It's a trend momentum indicator that shows a relationship between two moving averages of stock prices.

The MACD is calculated by subtracting the 26-period Exponential Moving Average (EMA) from the 12-period EMA.**Bollinger Bands:** These are two maximum and minimum indicators that shows that is 2 Standard Deviations away from 20 day simple moving average.

**Fourier Transform:**

Fourier Transform is a statistical function that outputs a series of sine waves that are approximations of the actual function. It works by de noising the actual function the resultant function is approximation function. We will add two aspects of Fourier Transform, **angle** and **absolute**(**magnitude**)

**Related Companies:**

Now we will add other company closing prices for the same period. This will be like, when we want AMD as our target we will take the rest of the companies closing prices as independent variables.

**Ex:**

1) When AMD is our target variable, rest of the companies like Intel(INTC), Nvidia(NVDA), Microsoft(MSFT), Qualcomm(QCOM), TSMC(TSM), S&P ETF(SPY) will be our dependent variables.

2) When Intel is our target variable, rest of the companies like AMD(AMD), Nvidia(NVDA), Microsoft(MSFT), Qualcomm(QCOM), TSMC(TSM), S&P ETF(SPY) will be our dependent variables.

**Methodology:**

The objective is to make predictions when we don't have data provided. So we have to run a loop which holds the value the number of days we need to make predictions for. For each loop we need to get the predictions for all the companies in our data sets. With the current available data we can get the predictions for June 1st 2020 but for the upcoming days we don't have data. Here comes the use of predictions, we know that we can get the predictions for AMD using rest of the companies and technical features data. The same way we can get the predictions for the rest of the companies, this way we get the predicted closing prices for June 1st 2020 for all companies in our dataset.

We include our predictions of June 1st 2020 to our actual dataset and the same process will carry on till the loop ends. Please note when predicting for future data with unknown data we will not able to capture any fundamental news related data which is resultant in making micro adjustments.

For generating the predictions we need a model. We use a basic **LSTM **network with 500 unit. And the input for this model will be a 70-day historical data.

The data would look like **t-70**, **t-69**, **t-68** …. **t**. And the target for this particular observation would be the price of the target company at time **t**.

**Option Pricing:**

Its is a way to buy assets at a particular future fixed price by paying a premium and still have an option to exercise it. This strategy will work when we know the price of a stock in future usually at the end of the month.

If we are certain of the range of the stock price at the end of the month, we could buy a call option and exercise it at the end of the month for price less than the market price.

I have used the predicted prices to calculate Call and Put Prices using Black Scholes Pricing Model.

**Black Scholes Pricing Model:**The Black Scholes model, also known as the Black-Scholes-Merton (BSM) model, is a mathematical model for pricing an options contract. In particular, the model estimates the variation over time of financial instruments. It assumes these instruments (such as stocks or futures) will have a log-normal distribution of prices. Using this assumption and factoring in other important variables, the equation derives the price of a call option.(source: https://www.investopedia.com/terms/b/blackscholes.asp)

Strike Price: The price set to buy/sell a stock on maturity date

Call Price: An option to buy a stock at Strike Price on maturity regardless of the actual market price of stock

Put Price: An option to sell a stock at Strike Price on maturity regardless of the actual market price of stock

**Future Work:**

With the recent advancement of **Generative Adversarial Networks** we could generate data that almost looks like the actual data. GANs are very popular among computer vision applications to generate fake pictures of humans(deep fake).

When you look at the data of colour image. We will have an array of numbers. So the GAN would generate new arrays which are not available in our dataset.

GAN contains two networks 1) Generator and 2) Discriminator. All the actual data will be labelled with 1 and fake data from generator will be labelled with 0. We update the weights in Generator and Discriminator alternatively. We keep training these models until the loss in Discriminator is very high and it can’t determine the difference between a fake and actual sample.

So the same approach can be implemented in our application as well, we could provide 10 days to actual data to the discriminator and produce a sample that would be data for the next day. But since GANs are probabilistic model the results won't be the same every time and also need to take the time complexity into consideration. GANs are very hard to train and most often the generated data is not reliable. Just think of an investment firm productionizing GANs and the data is not reliable, it could cost millions.

I have also tried GANs but the generated data is not representative of the actual data. This will be an area of research that will continue in the future.(will post if anything has been achieved)

**References:**

Boris B:

I have learnt a lot from his work, learnt how to apply GANs, a computer vision application applied on stock market. And also some of the technical indicators that are used in my blog.

Jason Brownlee:

I was able to understand the LSTMs and data preparation that is required for LSTMs, it helped me to develop a basic LSTM network that is good enough to get very accurate predictions.

This helped me in identifying the source of data. All my data are acquired from the sources listed in this research paper.

LinkedIn: Harsha Vardhan Maagalam