wip
This commit is contained in:
@@ -3,13 +3,14 @@
|
|||||||
namespace App\Interfaces\MarketData;
|
namespace App\Interfaces\MarketData;
|
||||||
|
|
||||||
use Illuminate\Support\Collection;
|
use Illuminate\Support\Collection;
|
||||||
|
use Scheb\YahooFinanceApi\ApiClient;
|
||||||
use Scheb\YahooFinanceApi\ApiClientFactory as YahooFinance;
|
use Scheb\YahooFinanceApi\ApiClientFactory as YahooFinance;
|
||||||
|
|
||||||
class YahooMarketData implements MarketDataInterface
|
class YahooMarketData implements MarketDataInterface
|
||||||
{
|
{
|
||||||
public function __construct(
|
public ApiClient $client;
|
||||||
public $client
|
|
||||||
) {
|
public function __construct() {
|
||||||
|
|
||||||
// create yahoo finance client factory
|
// create yahoo finance client factory
|
||||||
$this->client = YahooFinance::createApiClient();
|
$this->client = YahooFinance::createApiClient();
|
||||||
|
|||||||
@@ -28,6 +28,18 @@ class MarketData extends Model
|
|||||||
'dividend_yield'
|
'dividend_yield'
|
||||||
];
|
];
|
||||||
|
|
||||||
|
protected $casts = [
|
||||||
|
'last_dividend_date' => 'datetime',
|
||||||
|
'market_value' => 'float',
|
||||||
|
'fifty_two_week_high' => 'float',
|
||||||
|
'fifty_two_week_low' => 'float',
|
||||||
|
'forward_pe' => 'float',
|
||||||
|
'trailing_pe' => 'float',
|
||||||
|
'market_cap' => 'float',
|
||||||
|
'book_value' => 'float',
|
||||||
|
'dividend_yield' => 'float'
|
||||||
|
];
|
||||||
|
|
||||||
public function holdings()
|
public function holdings()
|
||||||
{
|
{
|
||||||
return $this->hasMany(Holding::class, 'symbol', 'symbol');
|
return $this->hasMany(Holding::class, 'symbol', 'symbol');
|
||||||
|
|||||||
@@ -18,7 +18,10 @@ class Spotlight
|
|||||||
return $results;
|
return $results;
|
||||||
}
|
}
|
||||||
|
|
||||||
$portfolios = $request->user()->portfolios()->where('title', 'LIKE', '%'.$request->input('search').'%')->limit(5)->get();
|
$portfolios = $request->user()->portfolios()
|
||||||
|
->where('title', 'LIKE', '%'.$request->input('search').'%')
|
||||||
|
->limit(5)
|
||||||
|
->get();
|
||||||
$portfolios->each(function($portfolio) use ($results) {
|
$portfolios->each(function($portfolio) use ($results) {
|
||||||
|
|
||||||
$results->push([
|
$results->push([
|
||||||
@@ -29,13 +32,20 @@ class Spotlight
|
|||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|
||||||
$holdings = $request->user()->holdings()->where('holdings.symbol', 'LIKE', '%'.$request->input('search').'%')->limit(5)->get();
|
$holdings = $request->user()->holdings()
|
||||||
|
->where('holdings.quantity', '>', 0)
|
||||||
|
->where(function ($query) use ($request) {
|
||||||
|
return $query->where('holdings.symbol', 'LIKE', '%'.$request->input('search').'%')
|
||||||
|
->orWhere('market_data.name', 'LIKE', '%'.$request->input('search').'%');
|
||||||
|
})
|
||||||
|
->limit(5)
|
||||||
|
->get();
|
||||||
$holdings->each(function($holding) use ($results) {
|
$holdings->each(function($holding) use ($results) {
|
||||||
|
|
||||||
$results->push([
|
$results->push([
|
||||||
'name' => 'Holding: '. $holding->symbol,
|
'name' => 'Holding: '.$holding->market_data->name.' ('.$holding->symbol.')',
|
||||||
'description' => $holding->portfolio->title,
|
'description' => $holding->portfolio->title,
|
||||||
'link' => route('portfolio.show', ['portfolio' => $holding->portfolio->id]),
|
'link' => route('holding.show', ['portfolio' => $holding->portfolio->id, 'symbol' => $holding->symbol]),
|
||||||
'avatar' => null
|
'avatar' => null
|
||||||
]);
|
]);
|
||||||
});
|
});
|
||||||
|
|||||||
@@ -143,6 +143,9 @@
|
|||||||
"Forward PE": "Forward PE",
|
"Forward PE": "Forward PE",
|
||||||
"Trailing PE": "Trailing PE",
|
"Trailing PE": "Trailing PE",
|
||||||
"Market Cap": "Market Cap",
|
"Market Cap": "Market Cap",
|
||||||
|
"Book Value": "Book Value",
|
||||||
|
"Dividend Yield": "Dividend Yield",
|
||||||
|
"Last Dividend Date": "Last Dividend Date",
|
||||||
"Number of Transactions": "Number of Transactions",
|
"Number of Transactions": "Number of Transactions",
|
||||||
"Market Data Age": "Market Data Age",
|
"Market Data Age": "Market Data Age",
|
||||||
"Portfolio updated": "Portfolio updated",
|
"Portfolio updated": "Portfolio updated",
|
||||||
|
|||||||
@@ -143,6 +143,9 @@
|
|||||||
"Forward PE": "PE a futuro",
|
"Forward PE": "PE a futuro",
|
||||||
"Trailing PE": "PE histórico",
|
"Trailing PE": "PE histórico",
|
||||||
"Market Cap": "Cap de mercado",
|
"Market Cap": "Cap de mercado",
|
||||||
|
"Book Value": "Valor contable",
|
||||||
|
"Dividend Yield": "Rendimiento por dividendo",
|
||||||
|
"Last Dividend Date": "Fecha del último dividendo",
|
||||||
"Number of Transactions": "Número de Transacciones",
|
"Number of Transactions": "Número de Transacciones",
|
||||||
"Market Data Age": "Antigüedad de los Datos del Mercado",
|
"Market Data Age": "Antigüedad de los Datos del Mercado",
|
||||||
"Portfolio updated": "Portafolio actualizado",
|
"Portfolio updated": "Portafolio actualizado",
|
||||||
|
|||||||
@@ -45,6 +45,11 @@
|
|||||||
|
|
||||||
<x-ib-card title="{{ __('Fundamentals') }}" class="md:col-span-4">
|
<x-ib-card title="{{ __('Fundamentals') }}" class="md:col-span-4">
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<span class="font-bold">{{ __('Market Cap') }}: </span>
|
||||||
|
${{ Number::forHumans($holding->market_data->market_cap ?? 0) }}
|
||||||
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<span class="font-bold">{{ __('Forward PE') }}: </span>
|
<span class="font-bold">{{ __('Forward PE') }}: </span>
|
||||||
{{ $holding->market_data->forward_pe }}
|
{{ $holding->market_data->forward_pe }}
|
||||||
@@ -56,8 +61,8 @@
|
|||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
<span class="font-bold">{{ __('Market Cap') }}: </span>
|
<span class="font-bold">{{ __('Book Value') }}: </span>
|
||||||
${{ Number::forHumans($holding->market_data->market_cap ?? 0) }}
|
{{ $holding->market_data->book_value }}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
<p>
|
<p>
|
||||||
@@ -68,7 +73,16 @@
|
|||||||
:high="$holding->market_data->fifty_two_week_high"
|
:high="$holding->market_data->fifty_two_week_high"
|
||||||
:current="$holding->market_data->market_value"
|
:current="$holding->market_data->market_value"
|
||||||
/>
|
/>
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<span class="font-bold">{{ __('Dividend Yield') }}: </span>
|
||||||
|
{{ $holding->market_data->dividend_yield }}
|
||||||
|
</p>
|
||||||
|
|
||||||
|
<p>
|
||||||
|
<span class="font-bold">{{ __('Last Dividend Date') }}: </span>
|
||||||
|
{{ $holding->market_data?->last_dividend_date?->format('F d, Y') ?? 'Never' }}
|
||||||
</p>
|
</p>
|
||||||
|
|
||||||
</x-ib-card>
|
</x-ib-card>
|
||||||
|
|||||||
@@ -18,33 +18,6 @@ Route::get('/', function () {
|
|||||||
|
|
||||||
Route::get('/test', function () {
|
Route::get('/test', function () {
|
||||||
//
|
//
|
||||||
|
|
||||||
|
|
||||||
return Alphavantage::fundamentals()->overview('TSLA');
|
|
||||||
|
|
||||||
$quote = Alphavantage::core()->quoteEndpoint('FFRHX');
|
|
||||||
|
|
||||||
$quote = Arr::get($quote, 'Global Quote', []);
|
|
||||||
|
|
||||||
|
|
||||||
return $quote;
|
|
||||||
|
|
||||||
$client = ApiClientFactory::createApiClient();
|
|
||||||
|
|
||||||
return $client->getQuote("IBM");
|
|
||||||
|
|
||||||
return $client->getHistoricalQuoteData(
|
|
||||||
"AAPL",
|
|
||||||
ApiClient::INTERVAL_1_DAY,
|
|
||||||
new \DateTime("-14 days"),
|
|
||||||
new \DateTime("today")
|
|
||||||
);
|
|
||||||
|
|
||||||
return $client->getHistoricalDividendData(
|
|
||||||
"AAPL",
|
|
||||||
new \DateTime("-5 years"),
|
|
||||||
new \DateTime("today")
|
|
||||||
);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Route::middleware(['auth:sanctum', config('jetstream.auth_session'), 'verified'])->group(function () {
|
Route::middleware(['auth:sanctum', config('jetstream.auth_session'), 'verified'])->group(function () {
|
||||||
|
|||||||
Reference in New Issue
Block a user