node-yahoo-finance2 icon indicating copy to clipboard operation
node-yahoo-finance2 copied to clipboard

I get an error when querying { fields } in .quotes.

Open Emre4x0 opened this issue 1 year ago • 4 comments

Validation Error

Minimal Reproduction

await yahooFinance.quote(symbols.map((symbol) => symbol.name), { fields: [ "symbol", "regularMarketChange", "regularMarketChangePercent", "quoteType", "circulatingSupply", "fromCurrency", "toCurrency", "lastMarket", "coinImageUrl", "volume24Hr", "volumeAllCurrencies", "startDate", "priceHint" ] });

Error Message

[yahooFinance] Invalid options ("{
  "type": 62,
  "schema": {
    "anyOf": [
      {
        "const": "language",
        "type": "string"
      },
      {
        "const": "region",
        "type": "string"
      },
      {
        "const": "quoteType",
        "type": "string"
      },
      {
        "const": "typeDisp",
        "type": "string"
      },
      {
        "const": "quoteSourceName",
        "type": "string"
      },
      {
        "const": "triggerable",
        "type": "string"
      },
      {
        "const": "currency",
        "type": "string"
      },
      {
        "const": "customPriceAlertConfidence",
        "type": "string"
      },
      {
        "const": "marketState",
        "type": "string"
      },
      {
        "const": "tradeable",
        "type": "string"
      },
      {
        "const": "cryptoTradeable",
        "type": "string"
      },
      {
        "const": "exchange",
        "type": "string"
      },
      {
        "const": "shortName",
        "type": "string"
      },
      {
        "const": "longName",
        "type": "string"
      },
      {
        "const": "messageBoardId",
        "type": "string"
      },
      {
        "const": "exchangeTimezoneName",
        "type": "string"
      },
      {
        "const": "exchangeTimezoneShortName",
        "type": "string"
      },
      {
        "const": "gmtOffSetMilliseconds",
        "type": "string"
      },
      {
        "const": "market",
        "type": "string"
      },
      {
        "const": "esgPopulated",
        "type": "string"
      },
      {
        "const": "fiftyTwoWeekLowChange",
        "type": "string"
      },
      {
        "const": "fiftyTwoWeekLowChangePercent",
        "type": "string"
      },
      {
        "const": "fiftyTwoWeekRange",
        "type": "string"
      },
      {
        "const": "fiftyTwoWeekHighChange",
        "type": "string"
      },
      {
        "const": "fiftyTwoWeekHighChangePercent",
        "type": "string"
      },
      {
        "const": "fiftyTwoWeekLow",
        "type": "string"
      },
      {
        "const": "fiftyTwoWeekHigh",
        "type": "string"
      },
      {
        "const": "fiftyTwoWeekChangePercent",
        "type": "string"
      },
      {
        "const": "dividendDate",
        "type": "string"
      },
      {
        "const": "earningsTimestamp",
        "type": "string"
      },
      {
        "const": "earningsTimestampStart",
        "type": "string"
      },
      {
        "const": "earningsTimestampEnd",
        "type": "string"
      },
      {
        "const": "trailingAnnualDividendRate",
        "type": "string"
      },
      {
        "const": "trailingPE",
        "type": "string"
      },
      {
        "const": "trailingAnnualDividendYield",
        "type": "string"
      },
      {
        "const": "epsTrailingTwelveMonths",
        "type": "string"
      },
      {
        "const": "epsForward",
        "type": "string"
      },
      {
        "const": "epsCurrentYear",
        "type": "string"
      },
      {
        "const": "priceEpsCurrentYear",
        "type": "string"
      },
      {
        "const": "sharesOutstanding",
        "type": "string"
      },
      {
        "const": "bookValue",
        "type": "string"
      },
      {
        "const": "fiftyDayAverage",
        "type": "string"
      },
      {
        "const": "fiftyDayAverageChange",
        "type": "string"
      },
      {
        "const": "fiftyDayAverageChangePercent",
        "type": "string"
      },
      {
        "const": "twoHundredDayAverage",
        "type": "string"
      },
      {
        "const": "twoHundredDayAverageChange",
        "type": "string"
      },
      {
        "const": "twoHundredDayAverageChangePercent",
        "type": "string"
      },
      {
        "const": "marketCap",
        "type": "string"
      },
      {
        "const": "forwardPE",
        "type": "string"
      },
      {
        "const": "priceToBook",
        "type": "string"
      },
      {
        "const": "sourceInterval",
        "type": "string"
      },
      {
        "const": "exchangeDataDelayedBy",
        "type": "string"
      },
      {
        "const": "firstTradeDateMilliseconds",
        "type": "string"
      },
      {
        "const": "priceHint",
        "type": "string"
      },
      {
        "const": "postMarketChangePercent",
        "type": "string"
      },
      {
        "const": "postMarketTime",
        "type": "string"
      },
      {
        "const": "postMarketPrice",
        "type": "string"
      },
      {
        "const": "postMarketChange",
        "type": "string"
      },
      {
        "const": "regularMarketChange",
        "type": "string"
      },
      {
        "const": "regularMarketChangePercent",
        "type": "string"
      },
      {
        "const": "regularMarketTime",
        "type": "string"
      },
      {
        "const": "regularMarketPrice",
        "type": "string"
      },
      {
        "const": "regularMarketDayHigh",
        "type": "string"
      },
      {
        "const": "regularMarketDayRange",
        "type": "string"
      },
      {
        "const": "regularMarketDayLow",
        "type": "string"
      },
      {
        "const": "regularMarketVolume",
        "type": "string"
      },
      {
        "const": "regularMarketPreviousClose",
        "type": "string"
      },
      {
        "const": "preMarketChange",
        "type": "string"
      },
      {
        "const": "preMarketChangePercent",
        "type": "string"
      },
      {
        "const": "preMarketTime",
        "type": "string"
      },
      {
        "const": "preMarketPrice",
        "type": "string"
      },
      {
        "const": "bid",
        "type": "string"
      },
      {
        "const": "ask",
        "type": "string"
      },
      {
        "const": "bidSize",
        "type": "string"
      },
      {
        "const": "askSize",
        "type": "string"
      },
      {
        "const": "fullExchangeName",
        "type": "string"
      },
      {
        "const": "financialCurrency",
        "type": "string"
      },
      {
        "const": "regularMarketOpen",
        "type": "string"
      },
      {
        "const": "averageDailyVolume3Month",
        "type": "string"
      },
      {
        "const": "averageDailyVolume10Day",
        "type": "string"
      },
      {
        "const": "displayName",
        "type": "string"
      },
      {
        "const": "symbol",
        "type": "string"
      },
      {
        "const": "underlyingSymbol",
        "type": "string"
      },
      {
        "const": "ytdReturn",
        "type": "string"
      },
      {
        "const": "trailingThreeMonthReturns",
        "type": "string"
      },
      {
        "const": "trailingThreeMonthNavReturns",
        "type": "string"
      },
      {
        "const": "ipoExpectedDate",
        "type": "string"
      },
      {
        "const": "newListingDate",
        "type": "string"
      },
      {
        "const": "nameChangeDate",
        "type": "string"
      },
      {
        "const": "prevName",
        "type": "string"
      },
      {
        "const": "averageAnalystRating",
        "type": "string"
      },
      {
        "const": "pageViewGrowthWeekly",
        "type": "string"
      },
      {
        "const": "openInterest",
        "type": "string"
      },
      {
        "const": "beta",
        "type": "string"
      }
    ]
  },
  "path": "/fields/7",
  "value": "circulatingSupply",
  "message": "Expected union value"
}")
[yahooFinance] Invalid options ("{
  "type": 62,
  "schema": {
    "anyOf": [
      {
        "const": "language",
        "type": "string"
      },
      {
        "const": "region",
        "type": "string"
      },
      {
        "const": "quoteType",
        "type": "string"
      },
      {
        "const": "typeDisp",
        "type": "string"
      },
      {
        "const": "quoteSourceName",
        "type": "string"
      },
      {
        "const": "triggerable",
        "type": "string"
      },
      {
        "const": "currency",
        "type": "string"
      },
      {
        "const": "customPriceAlertConfidence",
        "type": "string"
      },
      {
        "const": "marketState",
        "type": "string"
      },
      {
        "const": "tradeable",
        "type": "string"
      },
      {
        "const": "cryptoTradeable",
        "type": "string"
      },
      {
        "const": "exchange",
        "type": "string"
      },
      {
        "const": "shortName",
        "type": "string"
      },
      {
        "const": "longName",
        "type": "string"
      },
      {
        "const": "messageBoardId",
        "type": "string"
      },
      {
        "const": "exchangeTimezoneName",
        "type": "string"
      },
      {
        "const": "exchangeTimezoneShortName",
        "type": "string"
      },
      {
        "const": "gmtOffSetMilliseconds",
        "type": "string"
      },
      {
        "const": "market",
        "type": "string"
      },
      {
        "const": "esgPopulated",
        "type": "string"
      },
      {
        "const": "fiftyTwoWeekLowChange",
        "type": "string"
      },
      {
        "const": "fiftyTwoWeekLowChangePercent",
        "type": "string"
      },
      {
        "const": "fiftyTwoWeekRange",
        "type": "string"
      },
      {
        "const": "fiftyTwoWeekHighChange",
        "type": "string"
      },
      {
        "const": "fiftyTwoWeekHighChangePercent",
        "type": "string"
      },
      {
        "const": "fiftyTwoWeekLow",
        "type": "string"
      },
      {
        "const": "fiftyTwoWeekHigh",
        "type": "string"
      },
      {
        "const": "fiftyTwoWeekChangePercent",
        "type": "string"
      },
      {
        "const": "dividendDate",
        "type": "string"
      },
      {
        "const": "earningsTimestamp",
        "type": "string"
      },
      {
        "const": "earningsTimestampStart",
        "type": "string"
      },
      {
        "const": "earningsTimestampEnd",
        "type": "string"
      },
      {
        "const": "trailingAnnualDividendRate",
        "type": "string"
      },
      {
        "const": "trailingPE",
        "type": "string"
      },
      {
        "const": "trailingAnnualDividendYield",
        "type": "string"
      },
      {
        "const": "epsTrailingTwelveMonths",
        "type": "string"
      },
      {
        "const": "epsForward",
        "type": "string"
      },
      {
        "const": "epsCurrentYear",
        "type": "string"
      },
      {
        "const": "priceEpsCurrentYear",
        "type": "string"
      },
      {
        "const": "sharesOutstanding",
        "type": "string"
      },
      {
        "const": "bookValue",
        "type": "string"
      },
      {
        "const": "fiftyDayAverage",
        "type": "string"
      },
      {
        "const": "fiftyDayAverageChange",
        "type": "string"
      },
      {
        "const": "fiftyDayAverageChangePercent",
        "type": "string"
      },
      {
        "const": "twoHundredDayAverage",
        "type": "string"
      },
      {
        "const": "twoHundredDayAverageChange",
        "type": "string"
      },
      {
        "const": "twoHundredDayAverageChangePercent",
        "type": "string"
      },
      {
        "const": "marketCap",
        "type": "string"
      },
      {
        "const": "forwardPE",
        "type": "string"
      },
      {
        "const": "priceToBook",
        "type": "string"
      },
      {
        "const": "sourceInterval",
        "type": "string"
      },
      {
        "const": "exchangeDataDelayedBy",
        "type": "string"
      },
      {
        "const": "firstTradeDateMilliseconds",
        "type": "string"
      },
      {
        "const": "priceHint",
        "type": "string"
      },
      {
        "const": "postMarketChangePercent",
        "type": "string"
      },
      {
        "const": "postMarketTime",
        "type": "string"
      },
      {
        "const": "postMarketPrice",
        "type": "string"
      },
      {
        "const": "postMarketChange",
        "type": "string"
      },
      {
        "const": "regularMarketChange",
        "type": "string"
      },
      {
        "const": "regularMarketChangePercent",
        "type": "string"
      },
      {
        "const": "regularMarketTime",
        "type": "string"
      },
      {
        "const": "regularMarketPrice",
        "type": "string"
      },
      {
        "const": "regularMarketDayHigh",
        "type": "string"
      },
      {
        "const": "regularMarketDayRange",
        "type": "string"
      },
      {
        "const": "regularMarketDayLow",
        "type": "string"
      },
      {
        "const": "regularMarketVolume",
        "type": "string"
      },
      {
        "const": "regularMarketPreviousClose",
        "type": "string"
      },
      {
        "const": "preMarketChange",
        "type": "string"
      },
      {
        "const": "preMarketChangePercent",
        "type": "string"
      },
      {
        "const": "preMarketTime",
        "type": "string"
      },
      {
        "const": "preMarketPrice",
        "type": "string"
      },
      {
        "const": "bid",
        "type": "string"
      },
      {
        "const": "ask",
        "type": "string"
      },
      {
        "const": "bidSize",
        "type": "string"
      },
      {
        "const": "askSize",
        "type": "string"
      },
      {
        "const": "fullExchangeName",
        "type": "string"
      },
      {
        "const": "financialCurrency",
        "type": "string"
      },
      {
        "const": "regularMarketOpen",
        "type": "string"
      },
      {
        "const": "averageDailyVolume3Month",
        "type": "string"
      },
      {
        "const": "averageDailyVolume10Day",
        "type": "string"
      },
      {
        "const": "displayName",
        "type": "string"
      },
      {
        "const": "symbol",
        "type": "string"
      },
      {
        "const": "underlyingSymbol",
        "type": "string"
      },
      {
        "const": "ytdReturn",
        "type": "string"
      },
      {
        "const": "trailingThreeMonthReturns",
        "type": "string"
      },
      {
        "const": "trailingThreeMonthNavReturns",
        "type": "string"
      },
      {
        "const": "ipoExpectedDate",
        "type": "string"
      },
      {
        "const": "newListingDate",
        "type": "string"
      },
      {
        "const": "nameChangeDate",
        "type": "string"
      },
      {
        "const": "prevName",
        "type": "string"
      },
      {
        "const": "averageAnalystRating",
        "type": "string"
      },
      {
        "const": "pageViewGrowthWeekly",
        "type": "string"
      },
      {
        "const": "openInterest",
        "type": "string"
      },
      {
        "const": "beta",
        "type": "string"
      }
    ]
  },
  "path": "/fields/4",
  "value": "circulatingSupply",
  "message": "Expected union value"
}")
  

Environment

Browser or Node: Node Node version (if applicable): v20.17.0 Library version (e.g. 1.10.1): 2.12.4

Additional Context

when i remove the warning fields, i get different versions of the same error. fetch works when I don't use fields.

Emre4x0 avatar Sep 24 '24 19:09 Emre4x0

Hey @Emre4x0

Thanks for reporting, confirming the bug. Unfortunately this is an issue with the validation framework we use, and I'll need to prepare a proper bug report there. I hope I'll have a chance over the weekend, let's see.

In the meantime, I just wanted to check how much this bug affects you... i.e., do you still get the fields you need without using the fields option, or do any of those fields need to explicitly specified to get them?

Thanks!

gadicc avatar Sep 26 '24 11:09 gadicc

Hello, thank you for ur response. I can get the result I want without using fields. I was using fields to shorten my fetch time.

Emre4x0 avatar Sep 26 '24 11:09 Emre4x0

I wish you luck with your work @gadicc. I look forward to the new update. 🤩

Emre4x0 avatar Sep 26 '24 11:09 Emre4x0

Hey, thanks so much, @Emre4x0, appreciate your super quick response and kind words.

I'll leave this open so we can still track it. I'd also like to cleanup the error message A LOT :sweat_smile:

Thanks again! :pray:

gadicc avatar Sep 26 '24 11:09 gadicc