Skip to content

Commit

Permalink
fix(quote): optional "openInterest" prop; schema + tests (#248)
Browse files Browse the repository at this point in the history
  • Loading branch information
gadicc committed Apr 13, 2022
1 parent 1863fbf commit d8c7808
Show file tree
Hide file tree
Showing 4 changed files with 206 additions and 11 deletions.
60 changes: 49 additions & 11 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -1353,6 +1353,9 @@
"quoteType": {
"type": "string"
},
"typeDisp": {
"type": "string"
},
"quoteSourceName": {
"type": "string"
},
Expand Down Expand Up @@ -1618,14 +1621,16 @@
},
"pageViewGrowthWeekly": {
"yahooFinanceType": "number"
},
"openInterest": {
"yahooFinanceType": "number"
}
},
"required": [
"language",
"region",
"quoteType",
"triggerable",
"customPriceAlertConfidence",
"marketState",
"tradeable",
"exchange",
Expand Down Expand Up @@ -1670,6 +1675,9 @@
"type": "string",
"const": "CRYPTOCURRENCY"
},
"typeDisp": {
"type": "string"
},
"quoteSourceName": {
"type": "string"
},
Expand Down Expand Up @@ -1936,6 +1944,9 @@
"pageViewGrowthWeekly": {
"yahooFinanceType": "number"
},
"openInterest": {
"yahooFinanceType": "number"
},
"circulatingSupply": {
"yahooFinanceType": "number"
},
Expand Down Expand Up @@ -1963,7 +1974,6 @@
},
"required": [
"circulatingSupply",
"customPriceAlertConfidence",
"esgPopulated",
"exchange",
"exchangeDataDelayedBy",
Expand Down Expand Up @@ -1999,6 +2009,9 @@
"type": "string",
"const": "CURRENCY"
},
"typeDisp": {
"type": "string"
},
"quoteSourceName": {
"type": "string"
},
Expand Down Expand Up @@ -2264,10 +2277,12 @@
},
"pageViewGrowthWeekly": {
"yahooFinanceType": "number"
},
"openInterest": {
"yahooFinanceType": "number"
}
},
"required": [
"customPriceAlertConfidence",
"esgPopulated",
"exchange",
"exchangeDataDelayedBy",
Expand Down Expand Up @@ -2300,6 +2315,9 @@
"type": "string",
"const": "ETF"
},
"typeDisp": {
"type": "string"
},
"quoteSourceName": {
"type": "string"
},
Expand Down Expand Up @@ -2565,10 +2583,12 @@
},
"pageViewGrowthWeekly": {
"yahooFinanceType": "number"
},
"openInterest": {
"yahooFinanceType": "number"
}
},
"required": [
"customPriceAlertConfidence",
"esgPopulated",
"exchange",
"exchangeDataDelayedBy",
Expand Down Expand Up @@ -2601,6 +2621,9 @@
"type": "string",
"const": "EQUITY"
},
"typeDisp": {
"type": "string"
},
"quoteSourceName": {
"type": "string"
},
Expand Down Expand Up @@ -2866,10 +2889,12 @@
},
"pageViewGrowthWeekly": {
"yahooFinanceType": "number"
},
"openInterest": {
"yahooFinanceType": "number"
}
},
"required": [
"customPriceAlertConfidence",
"esgPopulated",
"exchange",
"exchangeDataDelayedBy",
Expand Down Expand Up @@ -2902,6 +2927,9 @@
"type": "string",
"const": "INDEX"
},
"typeDisp": {
"type": "string"
},
"quoteSourceName": {
"type": "string"
},
Expand Down Expand Up @@ -3167,10 +3195,12 @@
},
"pageViewGrowthWeekly": {
"yahooFinanceType": "number"
},
"openInterest": {
"yahooFinanceType": "number"
}
},
"required": [
"customPriceAlertConfidence",
"esgPopulated",
"exchange",
"exchangeDataDelayedBy",
Expand Down Expand Up @@ -3203,6 +3233,9 @@
"type": "string",
"const": "OPTION"
},
"typeDisp": {
"type": "string"
},
"quoteSourceName": {
"type": "string"
},
Expand Down Expand Up @@ -3469,10 +3502,10 @@
"pageViewGrowthWeekly": {
"yahooFinanceType": "number"
},
"strike": {
"openInterest": {
"yahooFinanceType": "number"
},
"openInterest": {
"strike": {
"yahooFinanceType": "number"
},
"expireDate": {
Expand All @@ -3483,7 +3516,6 @@
}
},
"required": [
"customPriceAlertConfidence",
"esgPopulated",
"exchange",
"exchangeDataDelayedBy",
Expand Down Expand Up @@ -3521,6 +3553,9 @@
"type": "string",
"const": "MUTUALFUND"
},
"typeDisp": {
"type": "string"
},
"quoteSourceName": {
"type": "string"
},
Expand Down Expand Up @@ -3786,10 +3821,12 @@
},
"pageViewGrowthWeekly": {
"yahooFinanceType": "number"
},
"openInterest": {
"yahooFinanceType": "number"
}
},
"required": [
"customPriceAlertConfidence",
"esgPopulated",
"exchange",
"exchangeDataDelayedBy",
Expand Down Expand Up @@ -3848,6 +3885,7 @@
"startDate",
"language",
"region",
"typeDisp",
"quoteSourceName",
"triggerable",
"currency",
Expand Down Expand Up @@ -3934,8 +3972,8 @@
"prevName",
"averageAnalystRating",
"pageViewGrowthWeekly",
"strike",
"openInterest",
"strike",
"expireDate",
"expireIsoDate"
]
Expand Down
1 change: 1 addition & 0 deletions src/modules/quote.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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 = [
Expand Down
1 change: 1 addition & 0 deletions src/modules/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -102,6 +102,7 @@ export interface QuoteBase {
prevName?: string;
averageAnalystRating?: string;
pageViewGrowthWeekly?: number; // Since 2021-11-11 (#326)
openInterest?: number; // SOHO (#248)
}

/*
Expand Down
155 changes: 155 additions & 0 deletions tests/http/quote-SOHO.json
Original file line number Diff line number Diff line change
@@ -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
}
}
}
}

0 comments on commit d8c7808

Please sign in to comment.