mschindler83/alpha-vantage

Alpha Vantage API 包装器

v1.0.0 2020-03-09 13:44 UTC

This package is auto-updated.

Last update: 2024-09-19 22:56:39 UTC


README

Build Status Latest Stable Version Scrutinizer Code Quality Code Coverage Code Intelligence Status Monthly Downloads

Alpha Vantage API 的包装库 需要 PHP >= 7.4

安装

composer require mschindler83/alpha-vantage

特性

  • 获取外汇汇率
  • 搜索符号
  • 获取全球报价
  • [...] 更多功能即将推出

使用示例

获取客户端实例

$alphaVantage = \Mschindler83\AlphaVantage\Client::instance($apiKey)

获取外汇汇率

$request = ForexExchangeRateRequest::convert('EUR', 'USD');
$exchangeRate = $alphaVantage->forexExchangeRate($request);

echo $exchangeRate->exchangeRate();

搜索符号

$request = SearchRequest::queryString('MSCI World');
$searchResults = $alphaVantage->search($request);

$allResultsArray = $searchResults->items();
echo $allResultsArray[0]->symbol();

获取全球报价

$request = GlobalQuoteRequest::symbol('IWDA.LON');
$globalQuote = $alphaVantage->globalQuote($request);

echo $globalQuote->open();
echo $globalQuote->high();
echo $globalQuote->low();
[...]