diff --git a/src/Dto/Fundamentals/Statistics.php b/src/Dto/Fundamentals/Statistics.php index bb6b216..d95da77 100644 --- a/src/Dto/Fundamentals/Statistics.php +++ b/src/Dto/Fundamentals/Statistics.php @@ -143,9 +143,9 @@ public static function fromJson(string $json): self * quarterly_earnings_growth_yoy: float|null, * }, * balance_sheet: array{ - * total_cash_mrq: int, + * total_cash_mrq: int|null, * total_cash_per_share_mrq: float|null, - * total_debt_mrq: int, + * total_debt_mrq: int|null, * total_debt_to_equity_mrq: float|null, * current_ratio_mrq: float|null, * book_value_per_share_mrq: float|null, diff --git a/src/Dto/Fundamentals/StatisticsBalanceSheet.php b/src/Dto/Fundamentals/StatisticsBalanceSheet.php index 10a2883..9edd2d1 100644 --- a/src/Dto/Fundamentals/StatisticsBalanceSheet.php +++ b/src/Dto/Fundamentals/StatisticsBalanceSheet.php @@ -7,9 +7,9 @@ readonly class StatisticsBalanceSheet { public function __construct( - public int $totalCashMrq, + public ?int $totalCashMrq, public ?float $totalCashPerShareMrq, - public int $totalDebtMrq, + public ?int $totalDebtMrq, public ?float $totalDebtToEquityMrq, public ?float $currentRatioMrq, public ?float $bookValuePerShareMrq, @@ -18,9 +18,9 @@ public function __construct( /** * @param array{ - * total_cash_mrq: int, + * total_cash_mrq: int|null, * total_cash_per_share_mrq: float|null, - * total_debt_mrq: int, + * total_debt_mrq: int|null, * total_debt_to_equity_mrq: float|null, * current_ratio_mrq: float|null, * book_value_per_share_mrq: float|null, diff --git a/src/Dto/Fundamentals/StatisticsFinancials.php b/src/Dto/Fundamentals/StatisticsFinancials.php index f061d85..c1050ee 100644 --- a/src/Dto/Fundamentals/StatisticsFinancials.php +++ b/src/Dto/Fundamentals/StatisticsFinancials.php @@ -40,9 +40,9 @@ public function __construct( * quarterly_earnings_growth_yoy: float|null, * }, * balance_sheet: array{ - * total_cash_mrq: int, + * total_cash_mrq: int|null, * total_cash_per_share_mrq: float|null, - * total_debt_mrq: int, + * total_debt_mrq: int|null, * total_debt_to_equity_mrq: float|null, * current_ratio_mrq: float|null, * book_value_per_share_mrq: float|null, diff --git a/src/Dto/Fundamentals/StatisticsStatistics.php b/src/Dto/Fundamentals/StatisticsStatistics.php index 9aac20e..c80c19b 100644 --- a/src/Dto/Fundamentals/StatisticsStatistics.php +++ b/src/Dto/Fundamentals/StatisticsStatistics.php @@ -46,9 +46,9 @@ public function __construct( * quarterly_earnings_growth_yoy: float|null, * }, * balance_sheet: array{ - * total_cash_mrq: int, + * total_cash_mrq: int|null, * total_cash_per_share_mrq: float|null, - * total_debt_mrq: int, + * total_debt_mrq: int|null, * total_debt_to_equity_mrq: float|null, * current_ratio_mrq: float|null, * book_value_per_share_mrq: float|null, diff --git a/tests/Api/FundamentalsTest.php b/tests/Api/FundamentalsTest.php index 7926837..550540a 100644 --- a/tests/Api/FundamentalsTest.php +++ b/tests/Api/FundamentalsTest.php @@ -167,11 +167,11 @@ public function testEarnings(): void public function testStatistics(): void { - $fundamentals = new Fundamentals(ClientFixture::createDemo()); + $fundamentals = new Fundamentals(ClientFixture::createWithResponse('statistics.json')); $this->assertInstanceOf( Statistics::class, - $fundamentals->statistics('AAPL'), + $fundamentals->statistics('TSM'), ); } diff --git a/tests/Fixtures/Response/statistics.json b/tests/Fixtures/Response/statistics.json new file mode 100644 index 0000000..4e65cab --- /dev/null +++ b/tests/Fixtures/Response/statistics.json @@ -0,0 +1 @@ +{"meta":{"symbol":"TSM","name":"Taiwan Semiconductor Manufacturing Co Ltd","currency":"USD","exchange":"NYSE","mic_code":"XNYS","exchange_timezone":"America/New_York"},"statistics":{"valuations_metrics":{"market_capitalization":953495257088,"enterprise_value":112485253434,"trailing_pe":29.55627,"forward_pe":22.752476,"peg_ratio":22.752476,"price_to_sales_ttm":0.35962284,"price_to_book_mrq":1.194635,"enterprise_to_revenue":1.37,"enterprise_to_ebitda":2.02},"financials":{"fiscal_year_ends":"2023-12-31","most_recent_quarter":"2024-09-30","gross_margin":0.5783198980639522,"profit_margin":0.39123002,"operating_margin":0.47487998,"return_on_assets_ttm":0.12409,"return_on_equity_ttm":0.28027,"income_statement":{"revenue_ttm":2161735800000,"revenue_per_share_ttm":63.906876,"quarterly_revenue_growth":0.39,"gross_profit_ttm":1175110600000,"ebitda":1693781958000,"net_income_to_common_ttm":851740000000,"diluted_eps_ttm":6.22,"quarterly_earnings_growth_yoy":0.542},"balance_sheet":{"total_cash_mrq":null,"total_cash_per_share_mrq":83.601,"total_debt_mrq":null,"total_debt_to_equity_mrq":24.081,"current_ratio_mrq":2.567,"book_value_per_share_mrq":153.888},"cash_flow":{"operating_cash_flow_ttm":1465315400000,"levered_free_cash_flow_ttm":851740000000}},"stock_statistics":{"shares_outstanding":5186549760,"float_shares":23355164560,"avg_10_volume":12553421,"avg_90_volume":15353140,"shares_short":28225792,"short_ratio":1.83,"short_percent_of_shares_outstanding":0.0055,"percent_held_by_insiders":0.000010000001,"percent_held_by_institutions":0.16420001},"stock_price_summary":{"fifty_two_week_low":95.25,"fifty_two_week_high":212.6,"fifty_two_week_change":45.61,"beta":1.232,"day_50_ma":188.256,"day_200_ma":162.83266},"dividends_and_splits":{"forward_annual_dividend_rate":2.463356,"forward_annual_dividend_yield":0.013503390434425106,"trailing_annual_dividend_rate":15.5,"trailing_annual_dividend_yield":0.083747566,"5_year_average_dividend_yield":2.06,"payout_ratio":0.344,"dividend_date":"2025-04-10","ex_dividend_date":"2024-12-12","last_split_factor":"1005-for-1000 split","last_split_date":"2009-07-15"}}}