Download the PHP package swar8080/fast-stock-quotes without Composer
On this page you can find all versions of the php package swar8080/fast-stock-quotes. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Informations about the package fast-stock-quotes
FastStockQuotes Overview
This library provides efficient access to two free stock quote APIs: Alpha Vantage and IEX. IEX is fast but limited to US stocks only. Alpha Vantage supports most stocks in the world but requires a separate request for each quote and is limited to ~1 request per second. To make Alpha Vantage usable for a moderate number of stocks, caching using redis can optionally be enabled to limit API requests.
Installation
Install with the composer command: composer require swar8080/fast-stock-quotes
Prerequisites
- PHP Version 5.6+
- Claim your free Alpha Vantage API key for access to non-US quotes
- Optionally download and run a redis server to enable caching of stock quotes. Review the Predis library for options when connecting to your redis server from PHP.
Stock Exchange Support
The APIs used by this library support most stock exchanges in this world, however, stock exchanges must be configured before use.
Currently Configured Stock Exchanges:
- Australia
- Amsterdam
- Canada
- Germany
- Hong Kong
- Tokyo
- London
- New Zealand
- Norway
- France
- Shanghai (China)
- Shenzhen (China)
- Stockholm
- United States
Configuring support for a stock exchange is easy: add its exchange code to ExchangeCodes.php and an entry to the Exchanges
array in StockExchange.php. If you run into problems, feel free to open an issue on github.
Benefits of Using Caching
- If the quote is cached, a network call to the API can be avoided
- You can configure the number of seconds before the cached quote expires and is removed
- If the stock exchange is closed, the quote will be cached until it re-opens
The following table shows time spent making requests (in seconds) from different sources. The biggest time savings can come from caching non-US Alpha Vantage quotes.
Number of Stocks | IEX | Alpha Vantage | From Cache (redis) |
---|---|---|---|
1 Stock | 0.28 | 0.82 | 0.002 |
5 Stocks | 0.35 | 1.89 | 0.003 |
10 Stocks | 0.56 | 10.16 | 0.003 |