mock and alphavantage data provider

This commit is contained in:
hackerESQ
2024-08-31 23:06:19 -05:00
parent 24b2aff828
commit d585153a0b
6 changed files with 215 additions and 5 deletions
+2
View File
@@ -56,6 +56,8 @@ MAIL_ENCRYPTION=null
MAIL_FROM_ADDRESS="hello@example.com"
MAIL_FROM_NAME="${APP_NAME}"
ALPHAVANTAGE_API_KEY=
AWS_ACCESS_KEY_ID=
AWS_SECRET_ACCESS_KEY=
AWS_DEFAULT_REGION=us-east-1
@@ -0,0 +1,63 @@
<?php
namespace App\Interfaces\MarketData;
use Illuminate\Support\Collection;
class FakeMarketData implements MarketDataInterface
{
public function exists(String $symbol): Bool
{
return true;
}
public function quote($symbol): Collection
{
return collect([
'name' => 'ACME Company Ltd',
'symbol' => $symbol,
'market_value' => 230.19,
'fifty_two_week_high' => 512.90,
'fifty_two_week_low' => 341.20,
'forward_pe' => 20.1,
'trailing_pe' => 30.34,
'market_cap' => 9800700600
]);
}
public function dividends($symbol, $startDate, $endDate): Collection
{
return collect([
[
'symbol' => $symbol,
'date' => now()->subMonths(3)->format('Y-m-d H:i:s'),
'dividend_amount' => 2.11,
],
[
'symbol' => $symbol,
'date' => now()->subMonths(6)->format('Y-m-d H:i:s'),
'dividend_amount' => 1.89,
],
[
'symbol' => $symbol,
'date' => now()->subMonths(9)->format('Y-m-d H:i:s'),
'dividend_amount' => 0.95,
],
]);
}
public function splits($symbol, $startDate, $endDate): Collection
{
return collect([
[
'symbol' => $symbol,
'date' => now()->subMonths(36)->format('Y-m-d H:i:s'),
'split_amount' => 10,
],
]);
}
}
@@ -7,9 +7,9 @@ use Scheb\YahooFinanceApi\ApiClientFactory as YahooFinance;
class YahooMarketData implements MarketDataInterface
{
public $client;
public function __construct() {
public function __construct(
public $client
) {
// create yahoo finance client factory
$this->client = YahooFinance::createApiClient();
+2 -1
View File
@@ -16,7 +16,8 @@
"predis/predis": "^2.2",
"robsontenorio/mary": "^1.35",
"scheb/yahoo-finance-api": "^4.10",
"staudenmeir/eloquent-has-many-deep": "^1.20"
"staudenmeir/eloquent-has-many-deep": "^1.20",
"tschucki/alphavantage-laravel": "^0.0.1"
},
"require-dev": {
"fakerphp/faker": "^1.23",
Generated
+140 -1
View File
@@ -4,7 +4,7 @@
"Read more about it at https://getcomposer.org/doc/01-basic-usage.md#installing-dependencies",
"This file is @generated automatically"
],
"content-hash": "3d6ea585015c0a9442f1faf0d5c9b141",
"content-hash": "47988869f65dbf94a6228627c7806e1f",
"packages": [
{
"name": "bacon/bacon-qr-code",
@@ -4846,6 +4846,66 @@
},
"time": "2024-06-09T11:50:56+00:00"
},
{
"name": "spatie/laravel-package-tools",
"version": "1.16.5",
"source": {
"type": "git",
"url": "https://github.com/spatie/laravel-package-tools.git",
"reference": "c7413972cf22ffdff97b68499c22baa04eddb6a2"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/spatie/laravel-package-tools/zipball/c7413972cf22ffdff97b68499c22baa04eddb6a2",
"reference": "c7413972cf22ffdff97b68499c22baa04eddb6a2",
"shasum": ""
},
"require": {
"illuminate/contracts": "^9.28|^10.0|^11.0",
"php": "^8.0"
},
"require-dev": {
"mockery/mockery": "^1.5",
"orchestra/testbench": "^7.7|^8.0",
"pestphp/pest": "^1.22",
"phpunit/phpunit": "^9.5.24",
"spatie/pest-plugin-test-time": "^1.1"
},
"type": "library",
"autoload": {
"psr-4": {
"Spatie\\LaravelPackageTools\\": "src"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Freek Van der Herten",
"email": "freek@spatie.be",
"role": "Developer"
}
],
"description": "Tools for creating Laravel packages",
"homepage": "https://github.com/spatie/laravel-package-tools",
"keywords": [
"laravel-package-tools",
"spatie"
],
"support": {
"issues": "https://github.com/spatie/laravel-package-tools/issues",
"source": "https://github.com/spatie/laravel-package-tools/tree/1.16.5"
},
"funding": [
{
"url": "https://github.com/spatie",
"type": "github"
}
],
"time": "2024-08-27T18:56:10+00:00"
},
{
"name": "staudenmeir/eloquent-has-many-deep",
"version": "v1.20.2",
@@ -7307,6 +7367,85 @@
},
"time": "2023-12-08T13:03:43+00:00"
},
{
"name": "tschucki/alphavantage-laravel",
"version": "0.0.1",
"source": {
"type": "git",
"url": "https://github.com/Tschucki/alphavantage-laravel.git",
"reference": "409c78c123ed40a150d8ea6ac095ab36dc077f82"
},
"dist": {
"type": "zip",
"url": "https://api.github.com/repos/Tschucki/alphavantage-laravel/zipball/409c78c123ed40a150d8ea6ac095ab36dc077f82",
"reference": "409c78c123ed40a150d8ea6ac095ab36dc077f82",
"shasum": ""
},
"require": {
"illuminate/contracts": "^10.0||^11.0",
"php": "^8.2",
"spatie/laravel-package-tools": "^1.16"
},
"require-dev": {
"larastan/larastan": "^2.9",
"laravel/pint": "^1.14",
"nunomaduro/collision": "^8.1.1||^7.10.0",
"orchestra/testbench": "^9.0.0||^8.22.0",
"pestphp/pest": "^2.34",
"pestphp/pest-plugin-arch": "^2.7",
"pestphp/pest-plugin-laravel": "^2.3",
"phpstan/extension-installer": "^1.3",
"phpstan/phpstan-deprecation-rules": "^1.1",
"phpstan/phpstan-phpunit": "^1.3",
"roave/security-advisories": "dev-latest"
},
"type": "library",
"extra": {
"laravel": {
"providers": [
"Tschucki\\Alphavantage\\AlphavantageServiceProvider"
],
"aliases": {
"Alphavantage": "Tschucki\\Alphavantage\\Facades\\Alphavantage"
}
}
},
"autoload": {
"psr-4": {
"Tschucki\\Alphavantage\\": "src/"
}
},
"notification-url": "https://packagist.org/downloads/",
"license": [
"MIT"
],
"authors": [
{
"name": "Marcel Wagner",
"email": "info@marcelwagner.dev",
"role": "Developer"
}
],
"description": "Laravel Wrapper for Alphavantage API",
"homepage": "https://github.com/tschucki/alphavantage-laravel",
"keywords": [
"Marcel Wagner",
"Tschucki",
"alphavantage-laravel",
"laravel"
],
"support": {
"issues": "https://github.com/Tschucki/alphavantage-laravel/issues",
"source": "https://github.com/Tschucki/alphavantage-laravel/tree/0.0.1"
},
"funding": [
{
"url": "https://github.com/Tschucki",
"type": "github"
}
],
"time": "2024-07-14T17:31:03+00:00"
},
{
"name": "vlucas/phpdotenv",
"version": "v5.6.1",
+5
View File
@@ -0,0 +1,5 @@
<?php
return [
'key' => env('ALPHAVANTAGE_API_KEY'),
];