d1am0nd/alpha-vantage
Composer 安装命令:
composer require d1am0nd/alpha-vantage
包简介
Simplified Laravel Alpha Vantage API client
README 文档
README
This is a Laravel package for simplified fetching of finance data from Alpha Vantage API. It's an abstraction layer over Guzzle that aims to remove complexity in connecting it to Alpha Vantage API.
Docs
Demo
Getting historical data
// Daily historical data for Bitcoin to USD $res = \AlphaVantage\Api::digitalCurrency()->daily('BTC', 'USD'); /* Returns [ "Meta Data": [ "1. Information": "Daily Prices and Volumes for Digital Currency", ... ], "Time Series (Digital Currency Daily)": [ "2018-01-03": [ "1a. open (USD)": "14782.09572045", ... ], "2018-01-02": [ "1a. open (USD)": "13514.39967186", ... ], ... ], ] */
Installation
- Run composer
composer require d1am0nd/alpha-vantage - Add your Alpha Vantage API key to .env as
AV_KEY={your key}
Usage
API calls are grouped into 5 different groups:
Api::stock()- Stock Time SeriesApi::currency()- Foreign ExchangeApi::digitalCurrency()- Digital & Crypto CurrenciesApi::sector()- Sector PerformancesApi::general()- Technical Indicators & Other
Each function described below is called from their respective group as shown in examples.
Functions described below also take an additional parameter array $params = [], which can be used to pass any optional parameters if needed.
Stock Time Series
Documented - https://www.alphavantage.co/documentation/#currency-exchange
Example - Microsoft's historical monthly stock data
use AlphaVantage\Api; // ... public function monthlyData() { return Api::stock()->monthly('MSFT'); }
Methods available
intraday($symbol)- https://www.alphavantage.co/documentation/#intradaydaily($symbol)- https://www.alphavantage.co/documentation/#dailydailyAdjusted($symbol)- https://www.alphavantage.co/documentation/#dailyadjweekly($symbol)- https://www.alphavantage.co/documentation/#weeklyweeklyAdjusted($symbol)- https://www.alphavantage.co/documentation/#weeklyadjmonthly($symbol)- https://www.alphavantage.co/documentation/#monthlymonthlyAdjusted($symbol)- https://www.alphavantage.co/documentation/#monthlyadjbatchStockQuotes(array $symbols)- https://www.alphavantage.co/documentation/#batchquotesquote($symbol)- https://www.alphavantage.co/documentation/#latestpricesearch($keywords)- https://www.alphavantage.co/documentation/#symbolsearch
Foreign Exchange
Documented - https://www.alphavantage.co/documentation/#currency-exchange
Example - Euro to US Dollar
use AlphaVantage\Api; // ... public function currencyExchangeRate() { return Api::currency()->currencyExchangeRate('EUR', 'USD'); }
Methods available
currencyExchangeRate($from, $to)- https://www.alphavantage.co/documentation/#currency-exchangeintraday($from, $to, $interval)- https://www.alphavantage.co/documentation/#fx-intradaydaily($from, $to)- https://www.alphavantage.co/documentation/#fx-dailyweekly($from, $to)- https://www.alphavantage.co/documentation/#fx-weeklymonthly($from, $to)- https://www.alphavantage.co/documentation/#fx-monthly
Digital & Crypto Currencies
Documented - https://www.alphavantage.co/documentation/#digital-currency
Example - Bitcoin historical monthly stock data
use AlphaVantage\Api; // ... public function monthlyData() { return Api::digitalCurrency()->monthly('BTC', 'USD'); }
Methods available
intraday($symbol, $market)- https://www.alphavantage.co/documentation/#currency-intradaydaily($symbol, $market)- https://www.alphavantage.co/documentation/#currency-dailyweekly($symbol, $market)- https://www.alphavantage.co/documentation/#currency-weeklymonthly($symbol, $market)- https://www.alphavantage.co/documentation/#currency-monthly
Sector Performances
Documented - https://www.alphavantage.co/documentation/#sector-information
Example - Sector peformances
use AlphaVantage\Api; // ... public function sectorPerformances() { return Api::sector()->sectors(); }
Methods available
Technical Indicators & Other
Documented - https://www.alphavantage.co/documentation/#technical-indicators
Technical methods are not implemented as separate functions. There is a Api::general()->query($funcName, array $params) method which allows for custom queries.
Example - MACDEXT
This will query function 'MACDEXT' with additional parameters symbol, interval and series_type as described in the documentation https://www.alphavantage.co/documentation/#macdext
use AlphaVantage\Api; // ... public function technicalIndicators() { return Api::general()->query('MACDEXT', [ 'symbol' => 'MSFT', 'interval' => '15min', 'series_type' => 'high', ]); }
Methods available
query($functionName, array $parameters)
License
This project is licensed under the MIT License - see the LICENSE.md file for details
d1am0nd/alpha-vantage 适用场景与选型建议
d1am0nd/alpha-vantage 是一款 基于 PHP 开发的 Composer 扩展包,目前已累计 2.98k 次下载、GitHub Stars 达 10, 最近一次更新时间为 2018 年 01 月 04 日, 在 PHP 生态内属于活跃度较高的组件。
它主要适用于以下技术方向: 「api」 「laravel」 「alpha-vantage」 「alphavantage」 等业务场景。在实际项目中,围绕这些方向常见需要落地的问题包括:接口对接、性能调优、并发安全、与既有框架(Laravel / ThinkPHP / Yii / Webman 等)的兼容适配,以及生产环境的日志埋点与稳定性保障。
我们在过去多个企业项目中使用过 d1am0nd/alpha-vantage 或与其功能相近的方案,如果你在选型或落地过程中遇到问题,例如 版本兼容、二次改造、私有化封装、与内部系统对接、生产 BUG 排查,欢迎联系我们协助评估。
基于 d1am0nd/alpha-vantage 在你已有业务上做功能扩展、字段裁剪、UI 适配、与内部账号 / 权限 / 日志系统的深度对接。
线上偶发问题、内存泄漏、慢查询、并发异常等排查修复;针对高流量场景做缓存、队列、索引层面的调优。
承接完整的项目从需求 → 设计 → 开发 → 上线 → 长期运维;也可按月提供技术保姆服务。
与 d1am0nd/alpha-vantage 相关的其它包
同方向 / 同关键字的高下载量 PHP Composer 包推荐,方便对比选型:
Alpha Vantage API client
A PSR-7 compatible library for making CRUD API endpoints
Alfabank REST API integration
Laravel package for Accurate Online API integration.
A lightweight plain-PHP framework for database-backed CRUD APIs.
Shared RCX Laravel DataTables UI and configuration helpers.
统计信息
- 总下载量: 2.98k
- 月度下载量: 0
- 日度下载量: 0
- 收藏数: 10
- 点击次数: 25
- 依赖项目数: 0
- 推荐数: 0
其他信息
- 授权协议: MIT
- 更新时间: 2018-01-04