From 817410be01dfff72df91aeb697ed6822e4cd169b Mon Sep 17 00:00:00 2001 From: Gadi Cohen Date: Tue, 21 Dec 2021 09:32:06 +0000 Subject: [PATCH] fix(quote): equity: allow underlyingSymbol. LDN.MI test (#363) --- schema.json | 31 ++++++-- src/modules/quote.spec.ts | 1 + src/modules/quote.ts | 1 + tests/http/quote-LDO.MI.json | 146 +++++++++++++++++++++++++++++++++++ 4 files changed, 174 insertions(+), 5 deletions(-) create mode 100644 tests/http/quote-LDO.MI.json diff --git a/schema.json b/schema.json index ae116e31..dafdc367 100644 --- a/schema.json +++ b/schema.json @@ -1501,6 +1501,9 @@ "symbol": { "type": "string" }, + "underlyingSymbol": { + "type": "string" + }, "ytdReturn": { "yahooFinanceType": "number" }, @@ -1815,6 +1818,9 @@ "symbol": { "type": "string" }, + "underlyingSymbol": { + "type": "string" + }, "ytdReturn": { "yahooFinanceType": "number" }, @@ -2142,6 +2148,9 @@ "symbol": { "type": "string" }, + "underlyingSymbol": { + "type": "string" + }, "ytdReturn": { "yahooFinanceType": "number" }, @@ -2437,6 +2446,9 @@ "symbol": { "type": "string" }, + "underlyingSymbol": { + "type": "string" + }, "ytdReturn": { "yahooFinanceType": "number" }, @@ -2732,6 +2744,9 @@ "symbol": { "type": "string" }, + "underlyingSymbol": { + "type": "string" + }, "ytdReturn": { "yahooFinanceType": "number" }, @@ -3027,6 +3042,9 @@ "symbol": { "type": "string" }, + "underlyingSymbol": { + "type": "string" + }, "ytdReturn": { "yahooFinanceType": "number" }, @@ -3322,6 +3340,9 @@ "symbol": { "type": "string" }, + "underlyingSymbol": { + "type": "string" + }, "ytdReturn": { "yahooFinanceType": "number" }, @@ -3360,9 +3381,6 @@ }, "expireIsoDate": { "yahooFinanceType": "number" - }, - "underlyingSymbol": { - "type": "string" } }, "required": [ @@ -3637,6 +3655,9 @@ "symbol": { "type": "string" }, + "underlyingSymbol": { + "type": "string" + }, "ytdReturn": { "yahooFinanceType": "number" }, @@ -3800,6 +3821,7 @@ "averageDailyVolume10Day", "displayName", "symbol", + "underlyingSymbol", "ytdReturn", "trailingThreeMonthReturns", "trailingThreeMonthNavReturns", @@ -3812,8 +3834,7 @@ "strike", "openInterest", "expireDate", - "expireIsoDate", - "underlyingSymbol" + "expireIsoDate" ] }, "ResultType": { diff --git a/src/modules/quote.spec.ts b/src/modules/quote.spec.ts index 9786debe..1c0bd19a 100644 --- a/src/modules/quote.spec.ts +++ b/src/modules/quote.spec.ts @@ -6,6 +6,7 @@ const testSymbols = [ ...testSymbolsOriginal, "AZT.OL", // Far less properties than other symbols (#42) "AAPL220121C00025000", // Option + "LDO.MI", // additionalProperty: underlyingSymbol (#363) ]; const marketStates = [ diff --git a/src/modules/quote.ts b/src/modules/quote.ts index ee85ed61..36fd69f2 100644 --- a/src/modules/quote.ts +++ b/src/modules/quote.ts @@ -87,6 +87,7 @@ export interface QuoteBase { averageDailyVolume10Day?: number; // 5546385, displayName?: string; // "NVIDIA", symbol: string; // "NVDA" + underlyingSymbol?: string; // "LD.MI" (for LDO.MI, #363) // only on ETF? not on EQUITY? ytdReturn?: number; // 0.31 trailingThreeMonthReturns?: number; // 16.98 diff --git a/tests/http/quote-LDO.MI.json b/tests/http/quote-LDO.MI.json new file mode 100644 index 00000000..709c880f --- /dev/null +++ b/tests/http/quote-LDO.MI.json @@ -0,0 +1,146 @@ +{ + "request": { + "url": "https://query2.finance.yahoo.com/v7/finance/quote?symbols=LDO.MI" + }, + "response": { + "ok": true, + "status": 200, + "statusText": "OK", + "headers": { + "content-type": [ + "application/json;charset=utf-8" + ], + "vary": [ + "Origin,Accept-Encoding" + ], + "cache-control": [ + "public, max-age=1, stale-while-revalidate=9" + ], + "y-rid": [ + "atgppepgs362s" + ], + "x-yahoo-request-id": [ + "atgppepgs362s" + ], + "x-request-id": [ + "a23dafae-533d-4ee7-b4dc-70745fe76deb" + ], + "content-length": [ + "1938" + ], + "x-envoy-upstream-service-time": [ + "1" + ], + "date": [ + "Tue, 21 Dec 2021 09:03:23 GMT" + ], + "server": [ + "ATS" + ], + "x-envoy-decorator-operation": [ + "finance-quote-api--mtls-production-ir2.finance-k8s.svc.yahoo.local:4080/*" + ], + "age": [ + "1" + ], + "strict-transport-security": [ + "max-age=15552000" + ], + "referrer-policy": [ + "no-referrer-when-downgrade" + ], + "x-frame-options": [ + "SAMEORIGIN" + ], + "connection": [ + "close" + ], + "expect-ct": [ + "max-age=31536000, report-uri=\"http://csp.yahoo.com/beacon/csp?src=yahoocom-expect-ct-report-only\"" + ], + "x-xss-protection": [ + "1; mode=block" + ], + "x-content-type-options": [ + "nosniff" + ] + }, + "bodyJson": { + "quoteResponse": { + "result": [ + { + "language": "en-US", + "region": "US", + "quoteType": "EQUITY", + "triggerable": false, + "currency": "EUR", + "shortName": "LEONARDO", + "epsTrailingTwelveMonths": 0.578, + "epsForward": 1.21, + "epsCurrentYear": 1.13, + "priceEpsCurrentYear": 5.2778764, + "sharesOutstanding": 575174016, + "bookValue": 10.196, + "fiftyDayAverage": 6.39064, + "fiftyDayAverageChange": -0.42663956, + "fiftyDayAverageChangePercent": -0.06676007, + "twoHundredDayAverage": 6.79327, + "twoHundredDayAverageChange": -0.8292699, + "twoHundredDayAverageChangePercent": -0.122072265, + "marketCap": 3430338048, + "forwardPE": 4.9289255, + "priceToBook": 0.5849353, + "sourceInterval": 20, + "exchangeDataDelayedBy": 0, + "tradeable": false, + "underlyingSymbol": "LD.MI", + "exchange": "MIL", + "longName": "Leonardo S.p.a.", + "messageBoardId": "finmb_688713", + "exchangeTimezoneName": "Europe/Rome", + "exchangeTimezoneShortName": "CET", + "gmtOffSetMilliseconds": 3600000, + "market": "it_market", + "esgPopulated": false, + "marketState": "REGULAR", + "firstTradeDateMilliseconds": 1121670000000, + "priceHint": 2, + "regularMarketChange": 0.018000126, + "regularMarketChangePercent": 0.30272663, + "regularMarketTime": 1640076483, + "regularMarketPrice": 5.964, + "regularMarketDayHigh": 5.998, + "regularMarketDayRange": "5.94 - 5.998", + "regularMarketDayLow": 5.94, + "regularMarketVolume": 317973, + "regularMarketPreviousClose": 5.946, + "bid": 5.96, + "ask": 5.964, + "bidSize": 0, + "askSize": 0, + "fullExchangeName": "Milan", + "financialCurrency": "EUR", + "regularMarketOpen": 5.984, + "averageDailyVolume3Month": 6120701, + "averageDailyVolume10Day": 4489689, + "fiftyTwoWeekLowChange": 0.54400015, + "fiftyTwoWeekLowChangePercent": 0.10036903, + "fiftyTwoWeekRange": "5.42 - 8.01", + "fiftyTwoWeekHighChange": -2.046, + "fiftyTwoWeekHighChangePercent": -0.2554307, + "fiftyTwoWeekLow": 5.42, + "fiftyTwoWeekHigh": 8.01, + "earningsTimestamp": 1646909940, + "earningsTimestampStart": 1646909940, + "earningsTimestampEnd": 1646909940, + "trailingAnnualDividendRate": 0.14, + "trailingPE": 10.318339, + "trailingAnnualDividendYield": 0.023545241, + "symbol": "LDO.MI" + } + ], + "error": null + } + } + } +} \ No newline at end of file