What was the first programming language you learned? Share yours in our annual Developer Skills Survey.

Tech talent hiring knowledge & best practices straight to your inbox!

Stock Prediction

The Stock Prediction Challenge was one of the vaguer challenges in the hackathon. Instead of having a set problem to solve, you needed to buy and sell stocks and try to earn the most money. While approximate challenges often involve trying out different approaches, this challenge especially did, since the future stock prices were unknown. However, a sample stock file was provided with the challenge that contained similar patterns to what was used in the actual contest. You could analyze this data (or use a program to analyze it) to detect the stock movement patterns. You could then write the actual program that would look for those patterns to buy and sell stocks.
Alexander did fairly well on this challenge using a very simple approach. Every day, he sold any stocks that had gone up in price and bought as many stocks as he could that had gone down by the highest percentage. He then worked on improving his approach. He started by selecting and sorting all the stocks that had gone down by at least 4% since the day before. He would then buy as many as possible from the stock that had gone down the most, which would often use up almost all the money. If there was leftover money, he would buy the next-most decreased stock that he could buy, and so on, until he used up his money. This simple strategy was enough to turn his $100 into $80,000 in a  few “years” of trading, and earned him 17th place on the back-to-school leaderboard. You can view Alexander’s code on Github.
The higher-ranking contestants were able to earn even more money by finding  more patterns in the data. While stocks often went up after going down and vice versa, this was not always true. Certain stocks fluctuated more, so it was worth buying more of those stocks when they went down then the less volatile stocks. Sometimes it might have been worth saving money from one turn to the next so you could buy a large number of cheap stocks. There was also another hidden pattern – certain stocks followed other stocks movements 30 days apart. If you realized such a pattern might exist, you could have stored the stock data from the previous 30 days, and then analyzed it to find out which stocks were following the movements of other stocks. This pattern was stronger than the simple up-and-down pattern, so you could have made more money by following it when possible. By using a more sophisticated analysis, you could have earned millions of dollars trading!
This challenge was somewhat “fuzzy” so it’s a bit more like the messy world than the clear-cut logic of some programming challenges. We may have more challenges like this in the future, perhaps with less clear-cut patterns. With enough of these challenges, people will soon be able to write their own algorithms to do real trading! (Note: Similar results are not guaranteed!)

Would you like to receive similar articles straight to your inbox?