gadicc / node-yahoo-finance2

Unofficial API for Yahoo Finance
https://www.npmjs.com/package/yahoo-finance2
MIT License
367 stars 59 forks source link

Failed validation: #/definitions/QuoteSummaryResult #639

Closed EcceGratum closed 1 year ago

EcceGratum commented 1 year ago

Validation Error

Minimal Reproduction

Symbol(s) that it happened for

Error Message

The following result did not validate with schema: #/definitions/QuoteSummaryResult
[
  {
    instancePath: '/topHoldings',
    schemaPath: '#/required',
    keyword: 'required',
    params: { missingProperty: 'stockPosition' },
    message: "must have required property 'stockPosition'",
    data: {
      maxAge: 1,
      holdings: [],
      equityHoldings: {
        priceToEarnings: 0,
        priceToBook: 0,
        priceToSales: 0,
        priceToCashflow: 0
      },
      bondHoldings: {},
      bondRatings: [],
      sectorWeightings: []
    }
  },
  {
    instancePath: '/topHoldings',
    schemaPath: '#/required',
    keyword: 'required',
    params: { missingProperty: 'bondPosition' },
    message: "must have required property 'bondPosition'",
    data: {
      maxAge: 1,
      holdings: [],
      equityHoldings: {
        priceToEarnings: 0,
        priceToBook: 0,
        priceToSales: 0,
        priceToCashflow: 0
      },
      bondHoldings: {},
      bondRatings: [],
      sectorWeightings: []
    }
  }
]

Environment

Browser or Node: Node version (if applicable): Npm version: Browser verion (if applicable): Library version (e.g. 1.10.1):

Additional Context

https://github.com/ghostfolio/ghostfolio/issues/1966

Xeli commented 1 year ago

I'm experiencing the same issue with a bunch of ETFs.

bmacedo commented 1 year ago

Same failure happens for the ETF CSH2.L

https://finance.yahoo.com/quote/CSH2.L/holdings?p=CSH2.L

gadicc commented 1 year ago

:tada: This issue has been resolved in version 2.4.3 :tada:

The release is available on:

Your semantic-release bot :package::rocket:

gadicc commented 1 year ago

Thanks, @EcceGratum, @Xeli, @bmacedo for reporting and for your patience.

This is now fixed and released, as per the above.

I've also added a section in the validation docs about how to help contribute these kinds of fixes, if anyone is interested :) https://github.com/gadicc/node-yahoo-finance2/blob/devel/docs/validation.md#help-fix

The changes are usually very simple, e.g.:

Error: message: "must have required property 'stockPosition'" (and bondPosition)

Modify src/modules/quoteSummary-iface.ts:

export interface TopHoldings {
  [key: string]: any;
  maxAge: number;
-  stockPosition: number;
-  bondPosition: number;
+  stockPosition?: number;
+  bondPosition?: number;
  holdings: TopHoldingsHolding[];
  equityHoldings: TopHoldingsEquityHoldings;
  bondHoldings: object;

and of course, a little more time for testing, etc. I'm just so overloaded at the moment so some help would be great :)

gadicc commented 1 year ago

:tada: This issue has been resolved in version 2.4.4 :tada:

The release is available on:

Your semantic-release bot :package::rocket: