Solved – Using neural network for trading in stock exchange

machine learningneural networks

I've dived into the field of neural networks and I became enthralled with them.

I have finally developed an application framework for testing trade systems in stock exchanges and now I'm going to implement my first neural network in it.
Very simple and primitive one, not intended for real trading, just for starters.

I only want to know if my approach is good approach.

And if you see I'm missing something (or I'm wrong about something) or you have an idea of what could help a begginer in a field of neural networks in market trading, that would just make me super-happy 🙂


I have 40 inputs, market values from the stock exchange (S&P e-mini but that's not important).

For these 40 inputs, I know 2 numbers.

  • How much money would I earn or lose with a buy order
  • How much money would I earn or lose with a sell order

Because of how stock exchanges work, both numbers can actually be negative/positive indicating that I can lose/earn money for either buy and sell (this is because a trade can have attached "loss limitting" or "targetting" orders like STOP, LIMIT etc. which behave differently).

But if that happens, it is an indication that I should not place an order at all, even if both buy&sell orders give positive numbers.

I imagine that the best activation function to use is the …sigmoid thing but with a range from -1 to 1 (I've found it's called many names on the internet…bipolar sigmoid, tanh, tangent something…I'm no profound mathematician).

With a back propagation learning I teach the network that for the 40 inputs, there is 1 output and this output is one of these numbers.

  • -1 which means sell order is going to earn money, buy is going to lose money
  • +1 which means buy order is going to earn money, sell is going to lose money
  • 0 which means buy and sell are both going to sell/lose money, best avoid trading

I'm imagining that after learning, the network output will be always some number close to -1, 1 or 0 and it's just up to me where I set the threshold for buying or selling.

Is this a right way to use a neural network?

Everywhere on the internet, the output for learning people are giving the back propagation learning machine are the future values of the market chart and not the expected money yield of a different trade entries (buy or sell). I consider that a bad approach because I'm not interested in the future chart values but in the money I want to earn.

Edit: I intend to build a neural network for automated trading, not for decision helping.

Best Answer

There are severe flaws with this approach.

First, there are many gambles which usually win, but which are bad gambles. Suppose you have the chance to win \$1 $90\%$ of the time and lose \$100 $10\%$ of the time. This has a negative expected value, but the way you are training the neural network would teach it to recommend such reverse lottery tickets.

Second, you are missing a big point of the stock exchange, which is to manage risk. What determines the price of an investment is not just its return, it is the return versus the risk which can't be hedged away. Investments with high returns and high risks are not necessarily better than investments with low returns and low risk. If you can invest risk-free at $6\%$ and borrow money at $5\%$, this is more valuable than finding a very risky investment with a return of $60\%$. An investment with a negative rate of return may still be valuable if it is strongly negatively correlated with a risky investment with a high rate of return. So, the rate of return is insufficient for evaluating investments.

Third, you should realize that you are competing with other people who also have access to neural networks. There are a lot of commercial programs aimed at day traders based on neural networks. (These are made by people who find it more profitable to sell software to confused day traders than to use their own systems.) There are many proprietary systems, some of which may involve neural networks. To find value they overlook, you need to have some advantage, and you haven't mentioned any.

I'm a big fan of neural networks, but I think typical users of neural networks in the stock market do not understand the basics and burn money.