cast values to float

This commit is contained in:
hackerESQ
2024-09-18 20:42:13 -05:00
parent 02a3a1ea9f
commit 854fa1c7e9
4 changed files with 32 additions and 32 deletions
@@ -33,18 +33,18 @@ class AlphaVantageMarketData implements MarketDataInterface
return collect([
'name' => Arr::get($fundamental, 'Name'),
'symbol' => Arr::get($fundamental, 'Symbol'),
'market_value' => Arr::get($quote, '05. price'),
'fifty_two_week_high' => Arr::get($fundamental, '52WeekHigh'),
'fifty_two_week_low' => Arr::get($fundamental, '52WeekLow'),
'forward_pe' => Arr::get($fundamental, 'ForwardPE'),
'trailing_pe' => Arr::get($fundamental, 'TrailingPE'),
'market_cap' => Arr::get($fundamental, 'MarketCapitalization'),
'book_value' => Arr::get($fundamental, 'BookValue'),
'market_value' => (float) Arr::get($quote, '05. price'),
'fifty_two_week_high' => (float) Arr::get($fundamental, '52WeekHigh'),
'fifty_two_week_low' => (float) Arr::get($fundamental, '52WeekLow'),
'forward_pe' => (float) Arr::get($fundamental, 'ForwardPE'),
'trailing_pe' => (float) Arr::get($fundamental, 'TrailingPE'),
'market_cap' => (int) Arr::get($fundamental, 'MarketCapitalization'),
'book_value' => (float) Arr::get($fundamental, 'BookValue'),
'last_dividend_date' => Arr::get($fundamental, 'DividendDate') != 'None'
? Arr::get($fundamental, 'DividendDate')
: null,
'dividend_yield' => Arr::get($fundamental, 'DividendYield') != 'None'
? Arr::get($fundamental, 'DividendYield')
? (float) Arr::get($fundamental, 'DividendYield')
: null
]);
}
+8 -8
View File
@@ -19,15 +19,15 @@ class FakeMarketData implements MarketDataInterface
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,
'book_value' => 4.7,
'market_value' => (float) 230.19,
'fifty_two_week_high' => (float) 512.90,
'fifty_two_week_low' => (float) 341.20,
'forward_pe' => (float) 20.1,
'trailing_pe' => (float) 30.34,
'market_cap' => (int) 9800700600,
'book_value' => (float) 4.7,
'last_dividend_date' => now()->subDays(45),
'dividend_yield' => .033
'dividend_yield' => (float) 0.033
]);
}
@@ -43,15 +43,15 @@ class FinnhubMarketData implements MarketDataInterface
return collect([
'name' => Arr::get($fundamental, 'metric.name'),
'symbol' => $symbol,
'market_value' => Arr::get($quote, 'c'),
'fifty_two_week_high' => Arr::get($fundamental, 'metric.52WeekHigh'),
'fifty_two_week_low' => Arr::get($fundamental, 'metric.52WeekLow'),
'forward_pe' => Arr::get($fundamental, 'metric.forwardPE'), // confirm
'trailing_pe' => Arr::get($fundamental, 'metric.trailingPE'), // confirm
'market_cap' => Arr::get($fundamental, 'metric.marketCapitalization'), // confirm
'book_value' => Arr::get($fundamental, 'metric.bookValuePerShare'), // confirm
'market_value' => (float) Arr::get($quote, 'c'),
'fifty_two_week_high' => (float) Arr::get($fundamental, 'metric.52WeekHigh'),
'fifty_two_week_low' => (float) Arr::get($fundamental, 'metric.52WeekLow'),
'forward_pe' => (float) Arr::get($fundamental, 'metric.forwardPE'), // confirm
'trailing_pe' => (float) Arr::get($fundamental, 'metric.trailingPE'), // confirm
'market_cap' => (int) Arr::get($fundamental, 'metric.marketCapitalization'), // confirm
'book_value' => (float) Arr::get($fundamental, 'metric.bookValuePerShare'), // confirm
'last_dividend_date' => Arr::get($fundamental, 'metric.lastDivDate'), // confirm
'dividend_yield' => Arr::get($fundamental, 'metric.dividendYield'), // confirm
'dividend_yield' => (float) Arr::get($fundamental, 'metric.dividendYield'), // confirm
]);
}
@@ -32,15 +32,15 @@ class YahooMarketData implements MarketDataInterface
return collect([
'name' => $quote->getLongName() ?? $quote->getShortName(),
'symbol' => $quote->getSymbol(),
'market_value' => $quote->getRegularMarketPrice(),
'fifty_two_week_high' => $quote->getFiftyTwoWeekHigh(),
'fifty_two_week_low' => $quote->getFiftyTwoWeekLow(),
'forward_pe' => $quote->getForwardPE(),
'trailing_pe' => $quote->getTrailingPE(),
'market_cap' => $quote->getMarketCap(),
'book_value' => $quote->getBookValue(),
'market_value' => (float) $quote->getRegularMarketPrice(),
'fifty_two_week_high' => (float) $quote->getFiftyTwoWeekHigh(),
'fifty_two_week_low' => (float) $quote->getFiftyTwoWeekLow(),
'forward_pe' => (float) $quote->getForwardPE(),
'trailing_pe' => (float) $quote->getTrailingPE(),
'market_cap' => (int) $quote->getMarketCap(),
'book_value' => (float) $quote->getBookValue(),
'last_dividend_date' => $quote->getDividendDate(),
'dividend_yield' => $quote->getTrailingAnnualDividendYield() * 100
'dividend_yield' => (float) $quote->getTrailingAnnualDividendYield() * 100
]);
}