atepam/laravel-alphavantage-client

Laravel的AlphaVantage客户端

0.1.5 2024-07-19 14:12 UTC

This package is auto-updated.

Last update: 2024-09-19 14:26:44 UTC


README

安装

composer require atepam/laravel-alphavantage-client

配置

php artisan vendor:publish --provider="Atepam\AlphavantageClient\Providers\LatestPriceClientProvider" --tag="config"

服务

最新价格

https://www.alphavantage.co/documentation/#latestprice

用法

通过外观

    $data = AVLatestPrice::getLatestPrice('IBM');

或者通过DI容器

<?php

namespace App;

use Atepam\AlphavantageClient\Services\LatestPrice;

class ThisIsTheClass
{
    public function __construct(
        public readonly LatestPrice $avLatestPrice,
    )
    {
      //
    }

    public function getLatestPrice(string $symbol): array
    {
        return $this->avLatestPrice->getLatestPrice($symbol);
    }
}

或者实例化

use Atepam\AlphavantageClient\Services\LatestPrice;

$client = app(LatestPrice::class);
$data = $client->getLatestPrice('IBM');