scheb / yahoo-finance-api

PHP client for Yahoo Finance API đŸ“ˆ
MIT License
280 stars 56 forks source link

Fatal error in ResultDecoder.php #57

Open mapelo opened 4 hours ago

mapelo commented 4 hours ago

Package version: 4.x-dev

Fatal error: Uncaught Scheb\YahooFinanceApi\Exception\ApiException: Not a number in column "open": open in [...]/vendor/scheb/yahoo-finance-api/src/ResultDecoder.php:232 Stack trace: #0 [...]/vendor/scheb/yahoo-finance-api/src/ResultDecoder.php(214): Scheb\YahooFinanceApi\ResultDecoder->createHistoricalData() #1 [...]/vendor/scheb/yahoo-finance-api/src/ApiClient.php(107): Scheb\YahooFinanceApi\ResultDecoder->transformHistoricalDataResult() #2 [...]/myfile.php(271): Scheb\YahooFinanceApi\ApiClient->getHistoricalQuoteData() #3 {main} thrown in [...]/vendor/scheb/yahoo-finance-api/src/ResultDecoder.php on line 232

inside that expection code (line 232, ResultDecoder.php), I added the print_r($json) command, and this was the result:


Array
(
    [meta] => Array
        (
            [currency] => EUR
            [symbol] => 0P00011HBL.F
            [exchangeName] => FRA
            [fullExchangeName] => Frankfurt
            [instrumentType] => MUTUALFUND
            [firstTradeDate] => 1514876400
            [regularMarketTime] => 1730836800
            [hasPrePostMarketData] => 
            [gmtoffset] => 3600
            [timezone] => CET
            [exchangeTimezoneName] => Europe/Berlin
            [regularMarketPrice] => 216.493
            [fiftyTwoWeekHigh] => 224.07
            [fiftyTwoWeekLow] => 183.489
            [longName] => Vanguard €pean Stk Idx Ins Pl € Acc
            [shortName] => Vanguard European Stock Index F
            [chartPreviousClose] => 220.671
            [priceHint] => 2
            [currentTradingPeriod] => Array
                (
                    [pre] => Array
                        (
                            [timezone] => CET
                            [start] => 1730962800
                            [end] => 1730962800
                            [gmtoffset] => 3600
                        )

                    [regular] => Array
                        (
                            [timezone] => CET
                            [start] => 1730962800
                            [end] => 1731013200
                            [gmtoffset] => 3600
                        )

                    [post] => Array
                        (
                            [timezone] => CET
                            [start] => 1731013200
                            [end] => 1731013200
                            [gmtoffset] => 3600
                        )

                )

            [dataGranularity] => 1d
            [range] => 
            [validRanges] => Array
                (
                    [0] => 1mo
                    [1] => 3mo
                    [2] => 6mo
                    [3] => ytd
                    [4] => 1y
                    [5] => 2y
                    [6] => 5y
                    [7] => 10y
                    [8] => max
                )

        )

    [timestamp] => Array
        (
            [0] => 1728280800
            [1] => 1728367200
            [2] => 1728453600
            [3] => 1728540000
            [4] => 1728626400
            [5] => 1728885600
            [6] => 1728972000
            [7] => 1729058400
            [8] => 1729144800
            [9] => 1729231200
            [10] => 1729490400
            [11] => 1729576800
            [12] => 1729663200
            [13] => 1729749600
            [14] => 1729836000
            [15] => 1730098800
            [16] => 1730185200
            [17] => 1730271600
            [18] => 1730358000
            [19] => 1730444400
            [20] => 1730703600
            [21] => 1730790000
            [22] => 1730876400
        )

    [indicators] => Array
        (
            [quote] => Array
                (
                    [0] => Array
                        (
                            [high] => Array
                                (
                                    [0] => 220.67080688477
                                    [1] => 219.48930358887
                                    [2] => 221.36250305176
                                    [3] => 220.58219909668
                                    [4] => 221.78930664062
                                    [5] => 223.0233001709
                                    [6] => 221.07339477539
                                    [7] => 220.63319396973
                                    [8] => 222.47700500488
                                    [9] => 223.01440429688
                                    [10] => 221.58279418945
                                    [11] => 221.10940551758
                                    [12] => 220.44529724121
                                    [13] => 220.54530334473
                                    [14] => 220.48010253906
                                    [15] => 221.29820251465
                                    [16] => 220.07150268555
                                    [17] => 217.28030395508
                                    [18] => 214.73820495605
                                    [19] => 217.10479736328
                                    [20] => 216.34620666504
                                    [21] => 216.49270629883
                                    [22] => 
                                )

                            [low] => Array
                                (
                                    [0] => 220.67080688477
                                    [1] => 219.48930358887
                                    [2] => 221.36250305176
                                    [3] => 220.58219909668
                                    [4] => 221.78930664062
                                    [5] => 223.0233001709
                                    [6] => 221.07339477539
                                    [7] => 220.63319396973
                                    [8] => 222.47700500488
                                    [9] => 223.01440429688
                                    [10] => 221.58279418945
                                    [11] => 221.10940551758
                                    [12] => 220.44529724121
                                    [13] => 220.54530334473
                                    [14] => 220.48010253906
                                    [15] => 221.29820251465
                                    [16] => 220.07150268555
                                    [17] => 217.28030395508
                                    [18] => 214.73820495605
                                    [19] => 217.10479736328
                                    [20] => 216.34620666504
                                    [21] => 216.49270629883
                                    [22] => 
                                )

                            [volume] => Array
                                (
                                    [0] => 0
                                    [1] => 0
                                    [2] => 0
                                    [3] => 0
                                    [4] => 0
                                    [5] => 0
                                    [6] => 0
                                    [7] => 0
                                    [8] => 0
                                    [9] => 0
                                    [10] => 0
                                    [11] => 0
                                    [12] => 0
                                    [13] => 0
                                    [14] => 0
                                    [15] => 0
                                    [16] => 0
                                    [17] => 0
                                    [18] => 0
                                    [19] => 0
                                    [20] => 0
                                    [21] => 0
                                    [22] => 
                                )

                            [open] => Array
                                (
                                    [0] => 220.67080688477
                                    [1] => 219.48930358887
                                    [2] => 221.36250305176
                                    [3] => 220.58219909668
                                    [4] => 221.78930664062
                                    [5] => 223.0233001709
                                    [6] => 221.07339477539
                                    [7] => 220.63319396973
                                    [8] => 222.47700500488
                                    [9] => 223.01440429688
                                    [10] => 221.58279418945
                                    [11] => 221.10940551758
                                    [12] => 220.44529724121
                                    [13] => 220.54530334473
                                    [14] => 220.48010253906
                                    [15] => 221.29820251465
                                    [16] => 220.07150268555
                                    [17] => 217.28030395508
                                    [18] => 214.73820495605
                                    [19] => 217.10479736328
                                    [20] => 216.34620666504
                                    [21] => 216.49270629883
                                    [22] => 
                                )

                            [close] => Array
                                (
                                    [0] => 220.67080688477
                                    [1] => 219.48930358887
                                    [2] => 221.36250305176
                                    [3] => 220.58219909668
                                    [4] => 221.78930664062
                                    [5] => 223.0233001709
                                    [6] => 221.07339477539
                                    [7] => 220.63319396973
                                    [8] => 222.47700500488
                                    [9] => 223.01440429688
                                    [10] => 221.58279418945
                                    [11] => 221.10940551758
                                    [12] => 220.44529724121
                                    [13] => 220.54530334473
                                    [14] => 220.48010253906
                                    [15] => 221.29820251465
                                    [16] => 220.07150268555
                                    [17] => 217.28030395508
                                    [18] => 214.73820495605
                                    [19] => 217.10479736328
                                    [20] => 216.34620666504
                                    [21] => 216.49270629883
                                    [22] => 
                                )

                        )

                )

            [adjclose] => Array
                (
                    [0] => Array
                        (
                            [adjclose] => Array
                                (
                                    [0] => 220.67080688477
                                    [1] => 219.48930358887
                                    [2] => 221.36250305176
                                    [3] => 220.58219909668
                                    [4] => 221.78930664062
                                    [5] => 223.0233001709
                                    [6] => 221.07339477539
                                    [7] => 220.63319396973
                                    [8] => 222.47700500488
                                    [9] => 223.01440429688
                                    [10] => 221.58279418945
                                    [11] => 221.10940551758
                                    [12] => 220.44529724121
                                    [13] => 220.54530334473
                                    [14] => 220.48010253906
                                    [15] => 221.29820251465
                                    [16] => 220.07150268555
                                    [17] => 217.28030395508
                                    [18] => 214.73820495605
                                    [19] => 217.10479736328
                                    [20] => 216.34620666504
                                    [21] => 216.49270629883
                                    [22] => 
                                )

                        )

                )

        )

)
mapelo commented 4 hours ago

This error occurs when I call the api with

    $historicalData = $client->getHistoricalQuoteData(
            $symbol,
            "1d",
            new \DateTime("-1 months"), 
            new \DateTime("today") 
    );

but not with:

    $historicalData = $client->getHistoricalQuoteData(
            $symbol,
            "1d",
            new \DateTime("-1 months"),
            new \DateTime("yesterday")
    );

notice today versus yesterday