Let’s try to create a trading algorithm using a supervised learning approach. We can try for example, to use supervised learning to teach a computer to predict stock prices within a given timeframe. Being able to predict stock prices however, will not guarantee that we will make money. There are many reasons for this. One of them is network latencies. Network latencies result in delays between the time an order is placed and the time the order is delivered over a network. Therefore, even if your algorithm can accurately predict the price of a particular stock, at a specific time, by the time the order is delivered over the network and executed, the stock price might have change. The net result is that the orders that you place will be executed at a different price than the one predicted by the algorithm. Another problem you will see is trading fees. Trading fees are associated with each transaction and can vary greatly ultimately affecting the price per share. These factors and many others are uncertain and vary with each transaction making them very hard to predict. Consequently, training a supervised learning algorithm to take all of these uncertainties into account will be extremely difficult. But even if we manage to train our system to accurately predict stock prices and take all the uncertainties into account, that wouldn’t be enough. We also need a trading strategy. A trading strategy is a set of rules that determine when to buy, hold or sell a stock. For example, suppose the price of a stock goes up for awhile and then begins to drop. What will you do? Will you sell or will you keep the stock and hope that it goes up again in the future? Having a trading strategy will allow the computer to automatically decide, what the best action should be. The trading strategy could also include rules that determine the amount of shares to sell or buy in a particular transaction. Training a supervised learning algorithm to learn a trading strategy can be challenging for a couple of reasons. One reason is that trading strategies can vary greatly depending on market conditions. This means that supervised learning algorithm has to learn not just one trading strategy, but many in order to be robust to varying market conditions. Another reason is that, it’s often not clear what the best strategy should be. Consequently, training a supervised learning algorithm can be very difficult, since it’s not always clear what strategy we should optimize for. In the next lesson, we’ll learn how reinforcement learning can get around many of these problems.