Problem
We do not have a proper mechanism to handle stock history. We returned entire history of the stock last year, but that's a terrible thing to do.
How other sites solve it
Most stock sites provide you to specify the ranges of the stock history (1day, 5day, 1month, 3month, 6month, 1yr, 2yr, 5yr, Max - these are standard ranges, some offer lesser, some more). We'll follow the same. However, our game will be of only 10-14 days (mostly 10) and will run for 5-6 hours a day, so people won't be using most of the ranges except for looking at how the company did in the past. So maybe we should change our ranges to something more relevant (like have more short term ranges starting from 1 hour). We'll still need long-term ranges for completeness and for giving the gameplay some story factor.
Also, for each range the granularity/interval (we'll call it interval from now on) will be pre-decided. For example, in 1day range, stock prices of every minute will be shown. In 5day range, stock prices of every 5min interval will be shown, etc.
To get a feel of these, checkout any site - yahoo finance is pretty good, or http://gdax.com/trade/ETH-USD
Candlesticks business
Also, we'll be showing price candlesticks on the frontend. These require 4 things - Open, High, Low, Close prices for each interval. Open is the price at the start of the interval, High is the highest price during the interval, Low is the Lowest price during the interval. Close is the price at the close of the interval (this will coincide with the Open price of the next interval). Look up stock candlesticks if you're still confused.
And, I'd like the trade volume to be stored as well. But that'll be part of another PR.
Parts of the problem
-
First part of this feature would be to figure out what ranges & corresponding intervals we want to support.
-
Second part would be to figure out how we'd be querying the data.
-
Third part will be the actual coding. It'll affect models and proto and gRPC API.
enhancement High Priority