From d8c7808e87a9415639bc55e49cbc3bea7975cef1 Mon Sep 17 00:00:00 2001 From: Gadi Cohen Date: Wed, 13 Apr 2022 16:21:07 +0100 Subject: [PATCH] fix(quote): optional "openInterest" prop; schema + tests (#248) --- schema.json | 60 +++++++++++--- src/modules/quote.spec.ts | 1 + src/modules/quote.ts | 1 + tests/http/quote-SOHO.json | 155 +++++++++++++++++++++++++++++++++++++ 4 files changed, 206 insertions(+), 11 deletions(-) create mode 100644 tests/http/quote-SOHO.json diff --git a/schema.json b/schema.json index 27861eff..58fde075 100644 --- a/schema.json +++ b/schema.json @@ -1353,6 +1353,9 @@ "quoteType": { "type": "string" }, + "typeDisp": { + "type": "string" + }, "quoteSourceName": { "type": "string" }, @@ -1618,6 +1621,9 @@ }, "pageViewGrowthWeekly": { "yahooFinanceType": "number" + }, + "openInterest": { + "yahooFinanceType": "number" } }, "required": [ @@ -1625,7 +1631,6 @@ "region", "quoteType", "triggerable", - "customPriceAlertConfidence", "marketState", "tradeable", "exchange", @@ -1670,6 +1675,9 @@ "type": "string", "const": "CRYPTOCURRENCY" }, + "typeDisp": { + "type": "string" + }, "quoteSourceName": { "type": "string" }, @@ -1936,6 +1944,9 @@ "pageViewGrowthWeekly": { "yahooFinanceType": "number" }, + "openInterest": { + "yahooFinanceType": "number" + }, "circulatingSupply": { "yahooFinanceType": "number" }, @@ -1963,7 +1974,6 @@ }, "required": [ "circulatingSupply", - "customPriceAlertConfidence", "esgPopulated", "exchange", "exchangeDataDelayedBy", @@ -1999,6 +2009,9 @@ "type": "string", "const": "CURRENCY" }, + "typeDisp": { + "type": "string" + }, "quoteSourceName": { "type": "string" }, @@ -2264,10 +2277,12 @@ }, "pageViewGrowthWeekly": { "yahooFinanceType": "number" + }, + "openInterest": { + "yahooFinanceType": "number" } }, "required": [ - "customPriceAlertConfidence", "esgPopulated", "exchange", "exchangeDataDelayedBy", @@ -2300,6 +2315,9 @@ "type": "string", "const": "ETF" }, + "typeDisp": { + "type": "string" + }, "quoteSourceName": { "type": "string" }, @@ -2565,10 +2583,12 @@ }, "pageViewGrowthWeekly": { "yahooFinanceType": "number" + }, + "openInterest": { + "yahooFinanceType": "number" } }, "required": [ - "customPriceAlertConfidence", "esgPopulated", "exchange", "exchangeDataDelayedBy", @@ -2601,6 +2621,9 @@ "type": "string", "const": "EQUITY" }, + "typeDisp": { + "type": "string" + }, "quoteSourceName": { "type": "string" }, @@ -2866,10 +2889,12 @@ }, "pageViewGrowthWeekly": { "yahooFinanceType": "number" + }, + "openInterest": { + "yahooFinanceType": "number" } }, "required": [ - "customPriceAlertConfidence", "esgPopulated", "exchange", "exchangeDataDelayedBy", @@ -2902,6 +2927,9 @@ "type": "string", "const": "INDEX" }, + "typeDisp": { + "type": "string" + }, "quoteSourceName": { "type": "string" }, @@ -3167,10 +3195,12 @@ }, "pageViewGrowthWeekly": { "yahooFinanceType": "number" + }, + "openInterest": { + "yahooFinanceType": "number" } }, "required": [ - "customPriceAlertConfidence", "esgPopulated", "exchange", "exchangeDataDelayedBy", @@ -3203,6 +3233,9 @@ "type": "string", "const": "OPTION" }, + "typeDisp": { + "type": "string" + }, "quoteSourceName": { "type": "string" }, @@ -3469,10 +3502,10 @@ "pageViewGrowthWeekly": { "yahooFinanceType": "number" }, - "strike": { + "openInterest": { "yahooFinanceType": "number" }, - "openInterest": { + "strike": { "yahooFinanceType": "number" }, "expireDate": { @@ -3483,7 +3516,6 @@ } }, "required": [ - "customPriceAlertConfidence", "esgPopulated", "exchange", "exchangeDataDelayedBy", @@ -3521,6 +3553,9 @@ "type": "string", "const": "MUTUALFUND" }, + "typeDisp": { + "type": "string" + }, "quoteSourceName": { "type": "string" }, @@ -3786,10 +3821,12 @@ }, "pageViewGrowthWeekly": { "yahooFinanceType": "number" + }, + "openInterest": { + "yahooFinanceType": "number" } }, "required": [ - "customPriceAlertConfidence", "esgPopulated", "exchange", "exchangeDataDelayedBy", @@ -3848,6 +3885,7 @@ "startDate", "language", "region", + "typeDisp", "quoteSourceName", "triggerable", "currency", @@ -3934,8 +3972,8 @@ "prevName", "averageAnalystRating", "pageViewGrowthWeekly", - "strike", "openInterest", + "strike", "expireDate", "expireIsoDate" ] diff --git a/src/modules/quote.spec.ts b/src/modules/quote.spec.ts index 08104651..bb542656 100644 --- a/src/modules/quote.spec.ts +++ b/src/modules/quote.spec.ts @@ -8,6 +8,7 @@ const testSymbols = [ "AAPL220121C00025000", // Option "LDO.MI", // additionalProperty: underlyingSymbol (#363) "ZRC-USD", // Low cap crypto (#403) + "SOHO", // "openInterest" prop (#445) ]; const marketStates = [ diff --git a/src/modules/quote.ts b/src/modules/quote.ts index 108f484c..b5f4e4ef 100644 --- a/src/modules/quote.ts +++ b/src/modules/quote.ts @@ -102,6 +102,7 @@ export interface QuoteBase { prevName?: string; averageAnalystRating?: string; pageViewGrowthWeekly?: number; // Since 2021-11-11 (#326) + openInterest?: number; // SOHO (#248) } /* diff --git a/tests/http/quote-SOHO.json b/tests/http/quote-SOHO.json new file mode 100644 index 00000000..d30ee704 --- /dev/null +++ b/tests/http/quote-SOHO.json @@ -0,0 +1,155 @@ +{ + "request": { + "url": "https://query2.finance.yahoo.com/v7/finance/quote?symbols=SOHO" + }, + "response": { + "ok": true, + "status": 200, + "statusText": "OK", + "headers": { + "content-type": [ + "application/json;charset=utf-8" + ], + "cache-control": [ + "public, max-age=1, stale-while-revalidate=9" + ], + "vary": [ + "Origin,Accept-Encoding" + ], + "y-rid": [ + "dq5vsihh5dqif" + ], + "x-yahoo-request-id": [ + "dq5vsihh5dqif" + ], + "x-request-id": [ + "ddc5ed4f-3dad-4f7e-97b6-16bc021d30f7" + ], + "content-encoding": [ + "gzip" + ], + "content-length": [ + "1007" + ], + "x-envoy-upstream-service-time": [ + "2" + ], + "date": [ + "Wed, 13 Apr 2022 15:20:46 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", + "typeDisp": "Equity", + "quoteSourceName": "Nasdaq Real Time Price", + "triggerable": true, + "customPriceAlertConfidence": "HIGH", + "currency": "USD", + "exchange": "NGM", + "shortName": "Sotherly Hotels Inc.", + "longName": "Sotherly Hotels Inc.", + "messageBoardId": "finmb_11605659", + "exchangeTimezoneName": "America/New_York", + "exchangeTimezoneShortName": "EDT", + "gmtOffSetMilliseconds": -14400000, + "market": "us_market", + "esgPopulated": false, + "marketState": "REGULAR", + "firstTradeDateMilliseconds": 1103293800000, + "priceHint": 4, + "regularMarketChange": -0.0149998665, + "regularMarketChangePercent": -0.71089417, + "regularMarketTime": 1649860377, + "regularMarketPrice": 2.095, + "regularMarketDayHigh": 2.11, + "regularMarketDayRange": "2.09 - 2.11", + "regularMarketDayLow": 2.09, + "regularMarketVolume": 12656, + "regularMarketPreviousClose": 2.11, + "bid": 2.09, + "ask": 2.1, + "bidSize": 11, + "askSize": 8, + "fullExchangeName": "NasdaqGM", + "financialCurrency": "USD", + "regularMarketOpen": 2.11, + "averageDailyVolume3Month": 57740, + "averageDailyVolume10Day": 67130, + "fiftyTwoWeekLowChange": 0.20500004, + "fiftyTwoWeekLowChangePercent": 0.108465634, + "fiftyTwoWeekRange": "1.89 - 4.17", + "fiftyTwoWeekHighChange": -2.075, + "fiftyTwoWeekHighChangePercent": -0.49760193, + "fiftyTwoWeekLow": 1.89, + "fiftyTwoWeekHigh": 4.17, + "dividendDate": 1586390400, + "earningsTimestamp": 1646289000, + "earningsTimestampStart": 1652185800, + "earningsTimestampEnd": 1652704200, + "trailingAnnualDividendRate": 0, + "trailingAnnualDividendYield": 0, + "openInterest": 0, + "epsTrailingTwelveMonths": -2.151, + "epsForward": -0.56, + "epsCurrentYear": -0.56, + "priceEpsCurrentYear": -3.7410715, + "sharesOutstanding": 17849100, + "bookValue": -4.766, + "fiftyDayAverage": 2.218, + "fiftyDayAverageChange": -0.12299991, + "fiftyDayAverageChangePercent": -0.055455323, + "twoHundredDayAverage": 2.35155, + "twoHundredDayAverageChange": -0.25655007, + "twoHundredDayAverageChangePercent": -0.10909828, + "marketCap": 74861680, + "forwardPE": -3.7410715, + "priceToBook": -0.439572, + "sourceInterval": 15, + "exchangeDataDelayedBy": 0, + "pageViewGrowthWeekly": -0.05135583, + "averageAnalystRating": "2.0 - Buy", + "tradeable": false, + "displayName": "Sotherly Hotels", + "symbol": "SOHO" + } + ], + "error": null + } + } + } +} \ No newline at end of file