Charting Financial Data using APLX
Here's an example which demonstrates how to obtain some share price data from Google Finance, read it into an APL array and generate a simple chart of the results. It shows the use of the APLX system function ⎕IMPORT to read a file in CSV format, and ⎕CHART to display it.
The first step is to use a Web Browser to visit Google Finance and obtain the share price data. In this example we look up IBM's share price. Here's a screenshot:
Select the 'Download to spreadsheet' option to save the data to file in Comma-Separated Variable (CSV) format
It's very easy to read this file into an APLX array which we can then use to explore the data:
PRICES←⎕IMPORT 'C:\data\ibmdata.csv'
⍴PRICES
255 6
5 6↑PRICES
Date Open High Low Close Volume
30-Jan-09 92.23 93.48 91.25 91.65 9616963
29-Jan-09 93.58 94.58 92.02 92.51 9234105
28-Jan-09 92.7 94.94 91.91 94.82 13412453
27-Jan-09 91.77 91.97 90.5 91.66 8721601
⌈/1↓PRICES[;2]
129.83
Finally, we can put up a chart of the data using a single line of code. (More complex charts are also possible with a little more coding)
'seriesname=Open' 'seriesname=Close' ⎕CHART 1↓[1]PRICES[;2 5]
This causes a new window to open with the following chart:
APL Wiki