Financial API programming
Home


NOTE: Yahoo has removed its API that this module uses. Therefore, no stock functions are available. As soon as I can find a replacement, I will update this module. (JJB 2019-02-20)

I may change to this one: http://blog.intrinio.com/yahoo-finance-api-replacement/

Update
  • Mar 15 7:46 am
  • Prev Close
  • Open
  • Change Amt
  • Change Pct
  • Last Trade Price
  • Last Trade Time
  • Days Range
  • 52wk Range




Market Ticker
Mar 15 7:46 am




How it works

[Click to try it]




Yahoo deleted several of their APIs this year, so now the only part of this demo that still works is "SYMBOL LOOKUP". I may convert to a different API.





Yahoo Financials offers a pseudo-api that delivers market data and history in a CSV format when presented with a certain query string. (backlink)

Yahoo sponsors an aggregator service called Yahoo DataTables. This service can be programmed in E4X (Ecmascript for Xml). With E4X, one can build a service that queries remote dataservices, aggregates the results, and delivers an XML response. I programmed this service to validate requested symbols, and then aggregate history and current data on them. (backlink)

Yahoo offers a webservice-like query language named "Yahoo Query Language". It allows one to more easily query a Yahoo DataTable with a SQL-like syntax through an HTTP request. I programmed this service to connect to my Yahoo DataTable. (backlink)

The application performs a CURL request, presenting a YQL request over HTTP.

The application caches the results for some period of time. From here forward, we essentially have a Model-View-ViewModel design.

The application presents the results in an XML-HTTP response to the page.

The page updates a javascript ViewModel from the XML-HTTP response.

The ViewModel updates the graph of historical prices (highcharts.js) and the chart of current prices.



Subsequent requests are served from cache if possible. In general, symbol searches are cached for one month, history graphs for 1 day, and current prices for 15 minutes.



So, the data flow is:

Yahoo Financial API > Yahoo Datatables > Yahoo Query Language > PHP Server > Page > ViewModel > Highcharts Graph

or

Cache > PHP Server > Page > ViewModel > Highcharts Graph

Click to Run Unit Tests on the API