# Using neural network for trading in stock exchange

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.

• Considering Geoff Hinton isn't a multibillionare, I'd say it won't work as well as you think it will. All kidding aside, you could use an existing architecture that maps into future values and feed it into an additional layer which does some classification like you propose. I think the idea behind those existing nets is that based on the prices, a savvy trader can make their own decision on whether, e.g., a short sell might be to their advantage in a particular state of the market. Dec 1, 2012 at 10:53
• I can understand that people want to use neural networks as decision helpers. I'll edit the post becuase it is indeed an important clarification that I want to go further and use neural networks for automated trading as well. Dec 1, 2012 at 11:12

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.

• I'm well aware of the risk management, thought I wasn't well aware how would risk management perform for this primitive task but I wasn't expecting miracles. And yes, I actually want to know neural networks well, that's the reason why I am building it myself. That's the advantage I'm seeking. Dec 1, 2012 at 13:06
• These are made by people who find it more profitable to sell software to confused day traders than to use their own systems That on its own would have been worth an upvote. Dec 1, 2012 at 13:48

A single human may never see this, but I'd still like to give my input as someone who has found themselves engrossed in both finance and computer science.

I will never say a neural network won't be successful in equity trading, but you need to think at the differences between how a human trades stocks and how a neural network will trade stocks. The average trader subconsciously takes into account hundreds of factors when making a simple buy, hold, sell decision.

• Recent news
• Recent earning/financials
• Economic indicators (interest rates, loan delinquencies, politics)
• Industry competitors

So on and so on, and I'm sure over half of people trading stocks don't beat the benchmarks. A neural network will really struggle to make a better decision than a human due to lack of inputs. Looking at someones face and saying "Oh that's Bobby John" is a lot easier than making and investment decision, and some networks struggle to pick out faces. Possibly 40+ 150 IQ nerds from Cal Tech at Renaissance Technology or DE Shaw & Co have figured out how to make neural networks trade stocks, but I wouldn't waste my time. Stick to getting programs to pick out basic trends or scrap financial data of of EDGAR.

i realise this is an old thread, but just in case anyone stumbles on it, what the OP needed to do was squish his desired field down into the 0 to 1 space. ie just remap -1 = 0.0, 0 = 0.5, and 1 = 1. Then you can just use the standard logistic sigmoid activation function.