Skip to content

Commit

Permalink
fix(quote): make certain properties optional
Browse files Browse the repository at this point in the history
  • Loading branch information
pudgereyem committed Feb 13, 2021
1 parent a6115a2 commit 1881bcb
Show file tree
Hide file tree
Showing 5 changed files with 165 additions and 54 deletions.
46 changes: 3 additions & 43 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2768,7 +2768,6 @@
"language",
"region",
"quoteType",
"quoteSourceName",
"triggerable",
"currency",
"marketState",
Expand All @@ -2788,19 +2787,10 @@
"fiftyTwoWeekHighChangePercent",
"fiftyTwoWeekLow",
"fiftyTwoWeekHigh",
"fiftyDayAverage",
"fiftyDayAverageChange",
"fiftyDayAverageChangePercent",
"twoHundredDayAverage",
"twoHundredDayAverageChange",
"twoHundredDayAverageChangePercent",
"sourceInterval",
"exchangeDataDelayedBy",
"firstTradeDateMilliseconds",
"priceHint",
"fullExchangeName",
"averageDailyVolume3Month",
"averageDailyVolume10Day",
"symbol"
],
"type": "object"
Expand Down Expand Up @@ -3062,43 +3052,33 @@
}
},
"required": [
"averageDailyVolume10Day",
"averageDailyVolume3Month",
"currency",
"esgPopulated",
"exchange",
"exchangeDataDelayedBy",
"exchangeTimezoneName",
"exchangeTimezoneShortName",
"fiftyDayAverage",
"fiftyDayAverageChange",
"fiftyDayAverageChangePercent",
"fiftyTwoWeekHigh",
"fiftyTwoWeekHighChange",
"fiftyTwoWeekHighChangePercent",
"fiftyTwoWeekLow",
"fiftyTwoWeekLowChange",
"fiftyTwoWeekLowChangePercent",
"fiftyTwoWeekRange",
"firstTradeDateMilliseconds",
"fullExchangeName",
"gmtOffSetMilliseconds",
"language",
"longName",
"market",
"marketState",
"priceHint",
"quoteSourceName",
"quoteType",
"region",
"shortName",
"sourceInterval",
"symbol",
"tradeable",
"triggerable",
"twoHundredDayAverage",
"twoHundredDayAverageChange",
"twoHundredDayAverageChangePercent"
"triggerable"
],
"type": "object"
},
Expand Down Expand Up @@ -3359,43 +3339,33 @@
}
},
"required": [
"averageDailyVolume10Day",
"averageDailyVolume3Month",
"currency",
"esgPopulated",
"exchange",
"exchangeDataDelayedBy",
"exchangeTimezoneName",
"exchangeTimezoneShortName",
"fiftyDayAverage",
"fiftyDayAverageChange",
"fiftyDayAverageChangePercent",
"fiftyTwoWeekHigh",
"fiftyTwoWeekHighChange",
"fiftyTwoWeekHighChangePercent",
"fiftyTwoWeekLow",
"fiftyTwoWeekLowChange",
"fiftyTwoWeekLowChangePercent",
"fiftyTwoWeekRange",
"firstTradeDateMilliseconds",
"fullExchangeName",
"gmtOffSetMilliseconds",
"language",
"longName",
"market",
"marketState",
"priceHint",
"quoteSourceName",
"quoteType",
"region",
"shortName",
"sourceInterval",
"symbol",
"tradeable",
"triggerable",
"twoHundredDayAverage",
"twoHundredDayAverageChange",
"twoHundredDayAverageChangePercent"
"triggerable"
],
"type": "object"
},
Expand Down Expand Up @@ -3656,43 +3626,33 @@
}
},
"required": [
"averageDailyVolume10Day",
"averageDailyVolume3Month",
"currency",
"esgPopulated",
"exchange",
"exchangeDataDelayedBy",
"exchangeTimezoneName",
"exchangeTimezoneShortName",
"fiftyDayAverage",
"fiftyDayAverageChange",
"fiftyDayAverageChangePercent",
"fiftyTwoWeekHigh",
"fiftyTwoWeekHighChange",
"fiftyTwoWeekHighChangePercent",
"fiftyTwoWeekLow",
"fiftyTwoWeekLowChange",
"fiftyTwoWeekLowChangePercent",
"fiftyTwoWeekRange",
"firstTradeDateMilliseconds",
"fullExchangeName",
"gmtOffSetMilliseconds",
"language",
"longName",
"market",
"marketState",
"priceHint",
"quoteSourceName",
"quoteType",
"region",
"shortName",
"sourceInterval",
"symbol",
"tradeable",
"triggerable",
"twoHundredDayAverage",
"twoHundredDayAverageChange",
"twoHundredDayAverageChangePercent"
"triggerable"
],
"type": "object"
},
Expand Down
7 changes: 6 additions & 1 deletion src/modules/quote.spec.ts
Original file line number Diff line number Diff line change
@@ -1,7 +1,12 @@
import quote from "./quote";
import { testSymbols } from "../../tests/symbols";
import { testSymbols as testSymbolsOriginal } from "../../tests/symbols";
import testYf from "../../tests/testYf";

const testSymbols = [
...testSymbolsOriginal,
"AZT.OL", // Far less properties than other symbols (#42)
];

const yf = testYf({ quote });

describe("quote", () => {
Expand Down
20 changes: 10 additions & 10 deletions src/modules/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -14,7 +14,7 @@ export interface QuoteBase {
language: string; // "en-US",
region: string; // "US",
quoteType: string; // "EQUITY" | "ETF" | "MUTUALFUND";
quoteSourceName: string; // "Delayed Quote",
quoteSourceName?: string; // "Delayed Quote",
triggerable: boolean; // true,
currency: string; // "USD",
marketState: "REGULAR" | "CLOSED" | "PRE" | "PREPRE" | "POST" | "POSTPOST";
Expand Down Expand Up @@ -49,18 +49,18 @@ export interface QuoteBase {
priceEpsCurrentYear?: number; // 55.930042,
sharesOutstanding?: number; // 619000000,
bookValue?: number; // 24.772,
fiftyDayAverage: number; // 530.8828,
fiftyDayAverageChange: number; // 12.757202,
fiftyDayAverageChangePercent: number; // 0.024030166,
twoHundredDayAverage: number; // 515.8518,
twoHundredDayAverageChange: number; // 27.788208,
twoHundredDayAverageChangePercent: number; // 0.053868588,
fiftyDayAverage?: number; // 530.8828,
fiftyDayAverageChange?: number; // 12.757202,
fiftyDayAverageChangePercent?: number; // 0.024030166,
twoHundredDayAverage?: number; // 515.8518,
twoHundredDayAverageChange?: number; // 27.788208,
twoHundredDayAverageChangePercent?: number; // 0.053868588,
marketCap?: number; // 336513171456,
forwardPE?: number; // 46.54452,
priceToBook?: number; // 21.945745,
sourceInterval: number; // 15,
exchangeDataDelayedBy: number; // 0,
firstTradeDateMilliseconds: DateInMs; // 917015400000 -> Date
firstTradeDateMilliseconds?: DateInMs; // 917015400000 -> Date
priceHint: number; // 2,
postMarketChangePercent?: number; // 0.093813874,
postMarketTime?: Date; // 1612573179,
Expand All @@ -86,8 +86,8 @@ export interface QuoteBase {
fullExchangeName: string; // "NasdaqGS",
financialCurrency?: string; // "USD",
regularMarketOpen?: number; // 549.0,
averageDailyVolume3Month: number; // 7475022,
averageDailyVolume10Day: number; // 5546385,
averageDailyVolume3Month?: number; // 7475022,
averageDailyVolume10Day?: number; // 5546385,
displayName?: string; // "NVIDIA",
symbol: string; // "NVDA"
// only on ETF? not on EQUITY?
Expand Down
73 changes: 73 additions & 0 deletions tests/http/quote-AZT.OL-10am.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"request": {
"url": "https://query2.finance.yahoo.com/v7/finance/quote?symbols=AZT.OL"
},
"response": {
"ok": true,
"status": 200,
"statusText": "OK",
"headers": {
"content-type": [
"application/json"
],
"cache-control": [
"public, max-age=1, stale-while-revalidate=9"
],
"vary": [
"Origin,Accept-Encoding"
],
"y-rid": [
"3t9u8mtg2da02"
],
"x-yahoo-request-id": [
"3t9u8mtg2da02"
],
"x-request-id": [
"2f842715-be94-4bee-afd7-e24195aba31c"
],
"content-encoding": [
"gzip"
],
"content-length": [
"705"
],
"x-envoy-upstream-service-time": [
"4"
],
"date": [
"Fri, 12 Feb 2021 16:08:33 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"
]
},
"body": "{\"quoteResponse\":{\"result\":[{\"language\":\"en-US\",\"region\":\"US\",\"quoteType\":\"EQUITY\",\"triggerable\":false,\"currency\":\"NOK\",\"tradeable\":false,\"earningsTimestampStart\":1611801000,\"earningsTimestampEnd\":1611801000,\"trailingPE\":40.232555,\"epsTrailingTwelveMonths\":1.72,\"sharesOutstanding\":48334700,\"bookValue\":4.018,\"marketCap\":3344761088,\"priceToBook\":17.222498,\"sourceInterval\":15,\"exchangeDataDelayedBy\":0,\"priceHint\":2,\"regularMarketChange\":1.199997,\"regularMarketChangePercent\":1.7647014,\"regularMarketTime\":1613143602,\"regularMarketPrice\":69.2,\"regularMarketDayHigh\":69.8,\"regularMarketDayRange\":\"67.0 - 69.8\",\"regularMarketDayLow\":67.0,\"regularMarketVolume\":162059,\"regularMarketPreviousClose\":68.0,\"bid\":68.8,\"ask\":69.0,\"fullExchangeName\":\"Oslo\",\"financialCurrency\":\"NOK\",\"regularMarketOpen\":67.8,\"fiftyTwoWeekLowChange\":2.199997,\"fiftyTwoWeekLowChangePercent\":0.032835774,\"fiftyTwoWeekRange\":\"67.0 - 69.8\",\"fiftyTwoWeekHighChange\":-0.6000061,\"fiftyTwoWeekHighChangePercent\":-0.008596076,\"fiftyTwoWeekLow\":67.0,\"fiftyTwoWeekHigh\":69.8,\"earningsTimestamp\":1611801000,\"exchange\":\"OSL\",\"shortName\":\"ARCTICZYMES TECH\",\"longName\":\"ArcticZymes Technologies ASA\",\"messageBoardId\":\"finmb_13529463\",\"exchangeTimezoneName\":\"Europe/Oslo\",\"exchangeTimezoneShortName\":\"CET\",\"gmtOffSetMilliseconds\":3600000,\"market\":\"no_market\",\"esgPopulated\":false,\"marketState\":\"POSTPOST\",\"symbol\":\"AZT.OL\"}],\"error\":null}}"
}
}
73 changes: 73 additions & 0 deletions tests/http/quote-AZT.OL.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"request": {
"url": "https://query2.finance.yahoo.com/v7/finance/quote?symbols=AZT.OL"
},
"response": {
"ok": true,
"status": 200,
"statusText": "OK",
"headers": {
"content-type": [
"application/json"
],
"cache-control": [
"public, max-age=1, stale-while-revalidate=9"
],
"vary": [
"Origin,Accept-Encoding"
],
"y-rid": [
"3t9u8mtg2da02"
],
"x-yahoo-request-id": [
"3t9u8mtg2da02"
],
"x-request-id": [
"2f842715-be94-4bee-afd7-e24195aba31c"
],
"content-encoding": [
"gzip"
],
"content-length": [
"705"
],
"x-envoy-upstream-service-time": [
"4"
],
"date": [
"Fri, 12 Feb 2021 16:08:33 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"
]
},
"body": "{\"quoteResponse\":{\"result\":[{\"language\":\"en-US\",\"region\":\"US\",\"quoteType\":\"EQUITY\",\"triggerable\":false,\"currency\":\"NOK\",\"tradeable\":false,\"earningsTimestampStart\":1611801000,\"earningsTimestampEnd\":1611801000,\"trailingPE\":40.232555,\"epsTrailingTwelveMonths\":1.72,\"sharesOutstanding\":48334700,\"bookValue\":4.018,\"marketCap\":3344761088,\"priceToBook\":17.222498,\"sourceInterval\":15,\"exchangeDataDelayedBy\":0,\"priceHint\":2,\"regularMarketChange\":1.199997,\"regularMarketChangePercent\":1.7647014,\"regularMarketTime\":1613143602,\"regularMarketPrice\":69.2,\"regularMarketDayHigh\":69.8,\"regularMarketDayRange\":\"67.0 - 69.8\",\"regularMarketDayLow\":67.0,\"regularMarketVolume\":162059,\"regularMarketPreviousClose\":68.0,\"bid\":68.8,\"ask\":69.0,\"fullExchangeName\":\"Oslo\",\"financialCurrency\":\"NOK\",\"regularMarketOpen\":67.8,\"fiftyTwoWeekLowChange\":2.199997,\"fiftyTwoWeekLowChangePercent\":0.032835774,\"fiftyTwoWeekRange\":\"67.0 - 69.8\",\"fiftyTwoWeekHighChange\":-0.6000061,\"fiftyTwoWeekHighChangePercent\":-0.008596076,\"fiftyTwoWeekLow\":67.0,\"fiftyTwoWeekHigh\":69.8,\"earningsTimestamp\":1611801000,\"exchange\":\"OSL\",\"shortName\":\"ARCTICZYMES TECH\",\"longName\":\"ArcticZymes Technologies ASA\",\"messageBoardId\":\"finmb_13529463\",\"exchangeTimezoneName\":\"Europe/Oslo\",\"exchangeTimezoneShortName\":\"CET\",\"gmtOffSetMilliseconds\":3600000,\"market\":\"no_market\",\"esgPopulated\":false,\"marketState\":\"POSTPOST\",\"symbol\":\"AZT.OL\"}],\"error\":null}}"
}
}

0 comments on commit 1881bcb

Please sign in to comment.