3 Important Things About Metabolic Disorders Everyone Should Know

We usually think about metabolism when we can’t lose weight. But it’s not only about its speed. Metabolism is a much more complex process than it seems. This is a combination of physicochemical…

Smartphone

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




Designing a trading algorithm

It is assumed that trading in markets like Nifty, Sensex, etc, is carried out by individuals(human beings) with knowledge and required qualification. But with the advent of computers things have changed drastically.

Algorithmic trading is automated trading by computers that are programmed to take certain actions in response to varying market data.

Every day my algorithm will produce a trade sheet to decide on the stocks to buy and sell on that particular trading day. The trading strategy will generate the trade sheet based on the algorithm coded in python.

Each and every individual at some point in time will start earning money. The question of what to do with extra money i.e savings will surely come to their mind. Many will go for a fixed deposit or mutual fund etc. But the returns given by the above methods are not attractive enough and also the fact remains that in the above methods you are not in control of your own money. Algorithm trading may be a solution to the above problem. It is a better way to handle the savings and also more profitable if done right with extensive research.

Algorithm trading is generally done by HFTs and hedge funds. There are very few retail investors who do it.

Most of the algorithms which are open source are not profitable enough to invest upon. If I am able to minimize risk and maximize profit then I can open-source my algorithm for further improvement.

Even if I am not able to complete and test my algorithm in a given time period, the insights generated by me by analyzing historical data may prove to be valuable. It is difficult to innovate in this field as it requires a combination of logical decision making with a little bit of luck as part of the trial and error method. I need to generate multiple hypotheses based on a mathematical or a statistical model and work upon to prove my hypothesis right or wrong. Based on the results of the hypothesis testing I will make an informed decision of whether to use the given hypothesis in my algorithm.

I divide my approach into two phases:

The first model I applied was the LSTM model on Nifty data. Firstly, I started out by importing all the libraries and also the data in an IPython notebook. The data used was nifty data from the year 1997 to 2019. The format of the data was OHCLV. The frequency of the data was daily. The next thing I did was to divide the data into train and test data and perform scaling to make all the values between 0 to 1.Next is just running the model and getting the results. I used matplotlib to visualize the predictions. Here is the result of the LSTM model.

The second model I applied was the HMM model to detect a regime change. The main hypothesis is that the hidden state of the hidden Markov model will change its state whenever regime change is detected.

The process started in a similar way as the previous model, where I imported the data. The data used was again the Nifty index’s day to day price.

I used different input variables to get better results.

Finally, I used the previous two models to construct a trading algorithm.

2. Constructing a trading algorithm

Pseudocode for the trading algorithm:

The function which carries out transaction:

{

else

else

send new order at sellPrice

}

afterexecution

{

if buy execution happened in instr1

send sell order on instr2

else if sell execution happened on instr1

send buy order in instr2

}

The remaining work in the project is to take the algorithm live.

Add a comment

Related posts:

What Nobody Tells You About Entrepreneurship

The key truths that most people don't know about entrepreneurship and often end up finding out the hard way. We cover the good, the bad, and the ugly side of entrepreneurship that you will wish you had known before you started.

Top 10 JavaScript Coding Interview Questions and Answers

Not only is this surprising, but what makes this particularly gnarly is that func2() returns undefined without any error being thrown. The reason for this has to do with the fact that semicolons are…

Machines of Creativity

Artificial intelligence will displace 40% of jobs worldwide in the next 15 years. Creative jobs, however, require unorthodox thinking and imagination, concepts that are not fully understood by…