Join Curt Frye for an in-depth discussion in this video Displaying changes in a stock price over the past year, part of Mathematica 10: Advanced Analysis.
- Company stock prices vary significantly over time, but if you look at your data over a long period, such as a year or more, you might be able to identify patterns in that data. In this movie I will show you how to display changes in the stock price over periods of time. I'm working in a blank Mathematica notebook and what I want to do is to create a candlestick chart to display the values for a particular company. To display the values for a company, or a stock index, such as the S&P 500, you do need to know a company or index's stock ticker symbol.
That's usually a number of letters, such as two, three, or four, and they are an abbreviation that signal the name of the company or the name of the fund. In this case, I will pull up stock data for Microsoft and their abbreviation or stock symbol is MSFT. I want to crate a candlestick chart showing high, low, and close data, and to show the data from Microsoft I just type Candlestick, capital C, and then I'll use auto-complete by pressing tab to complete CandlestickChart, and then a left square bracket.
And now we need to enter the stock symbol, so I'll type a double quote and in all capital letters, I'll type MSFT, which again is Microsoft's ticker symbol or stock symbol. And then a second double quote to close the string, and a right square bracket and when I press shift, enter, Mathematica will accept the data and I can see it in the form of this candlestick chart. Now let's say that I want to display data over a set period of time. For that I can also use the CandlestickChart keyword, but I need to provide the starting and ending dates.
So I'll type CandlestickChart, then a left square bracket, and now we need to enter in a series of values, or a list. So I'll type a left curly bracket and again the stock symbol, so double quote, MSFT, double quote to close, then a comma, and now we need to enter in two dates, the starting date and the ending date. So I'll start by typing in the first date, so two left curly brackets, and then 2015 comma 1, comma 1, which is for January 1, 2015.
Right curly bracket and then a comma, left curly bracket and now the end date. So I'll do 2015, 8 for August, comma 14 for the 14th day. Now I need to close out all those arguments, so left curly bracket, or excuse me, two right curly brackets and I'm almost to the end. Another right curly bracket to close out the brackets around Microsoft and the list of dates, and then a right square bracket to end the list of arguments. Now when I press shift, enter Mathematica will accept the data and it shows me a chart of stock values starting on January 1, 2015 and going to August 14th of the same year.
Another way to visualize trading data for a particular stock is to use the TradingChart keyword. And that's slightly different from CandlestickChart, let me show you what it looks like. So I will go ahead and type in the command, that's TradingChart, and then I basically want to repeat what I did before. So that would be left square bracket, left curly bracket, then in double quotes MSFT for Microsoft, comma, and then the two dates, so I have left curly brackets, 2015, comma 1, comma 1, then a right curly bracket to close out that date, then a comma, then a left curly bracket to start the next date, and that's 2015, comma 8, comma 14.
Now we type one, two, three curly brackets to close out the list of lists, and then a right curly bracket to close, or excuse me, a right square bracket to close the TradingChart argument list. Now when I press shift, enter I get my chart, but instead of only having the candlestick data, or the candlestick visualization, you see that I also have another visualization bellow that that shows me what trading volume looks like on those particular days. So, as you can see, there are a lot of ways to display changes in stock price over time.
You can use candlestick charts to show the ups and downs, and you can create a trading chart to show both the data from the candlestick chart and your trading volume.
- Generating maps
- Displaying statistical data about countries and cities
- Displaying changes in stock prices
- Calculating exchange rates
- Counting links in a social network
- Calculating reciprocity
- Applying machine-learning algorithms
- Analyzing text data