Skip to content

Commit

Permalink
fix(quote): interface fixes, 10am UTC tests (#35)
Browse files Browse the repository at this point in the history
  • Loading branch information
gadicc committed Feb 10, 2021
1 parent afcb397 commit 1c256c7
Show file tree
Hide file tree
Showing 13 changed files with 803 additions and 1 deletion.
56 changes: 56 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2634,7 +2634,9 @@
},
"marketState": {
"enum": [
"REGULAR",
"CLOSED",
"PRE",
"PREPRE",
"POST",
"POSTPOST"
Expand All @@ -2656,6 +2658,18 @@
"postMarketTime": {
"yahooFinanceType": "date"
},
"preMarketChange": {
"yahooFinanceType": "number"
},
"preMarketChangePercent": {
"yahooFinanceType": "number"
},
"preMarketPrice": {
"yahooFinanceType": "number"
},
"preMarketTime": {
"yahooFinanceType": "number"
},
"priceEpsCurrentYear": {
"yahooFinanceType": "number"
},
Expand Down Expand Up @@ -2916,7 +2930,9 @@
},
"marketState": {
"enum": [
"REGULAR",
"CLOSED",
"PRE",
"PREPRE",
"POST",
"POSTPOST"
Expand All @@ -2938,6 +2954,18 @@
"postMarketTime": {
"yahooFinanceType": "date"
},
"preMarketChange": {
"yahooFinanceType": "number"
},
"preMarketChangePercent": {
"yahooFinanceType": "number"
},
"preMarketPrice": {
"yahooFinanceType": "number"
},
"preMarketTime": {
"yahooFinanceType": "number"
},
"priceEpsCurrentYear": {
"yahooFinanceType": "number"
},
Expand Down Expand Up @@ -3199,7 +3227,9 @@
},
"marketState": {
"enum": [
"REGULAR",
"CLOSED",
"PRE",
"PREPRE",
"POST",
"POSTPOST"
Expand All @@ -3221,6 +3251,18 @@
"postMarketTime": {
"yahooFinanceType": "date"
},
"preMarketChange": {
"yahooFinanceType": "number"
},
"preMarketChangePercent": {
"yahooFinanceType": "number"
},
"preMarketPrice": {
"yahooFinanceType": "number"
},
"preMarketTime": {
"yahooFinanceType": "number"
},
"priceEpsCurrentYear": {
"yahooFinanceType": "number"
},
Expand Down Expand Up @@ -3482,7 +3524,9 @@
},
"marketState": {
"enum": [
"REGULAR",
"CLOSED",
"PRE",
"PREPRE",
"POST",
"POSTPOST"
Expand All @@ -3504,6 +3548,18 @@
"postMarketTime": {
"yahooFinanceType": "date"
},
"preMarketChange": {
"yahooFinanceType": "number"
},
"preMarketChangePercent": {
"yahooFinanceType": "number"
},
"preMarketPrice": {
"yahooFinanceType": "number"
},
"preMarketTime": {
"yahooFinanceType": "number"
},
"priceEpsCurrentYear": {
"yahooFinanceType": "number"
},
Expand Down
9 changes: 9 additions & 0 deletions src/modules/quote.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ describe('quote', () => {
});
});

describe('passes validation', () => {
testSymbols.forEach(symbol => {
it(symbol, async () => {
const devel = `quote-${symbol}-10am.json`;
await yf.quote(symbol, {}, { devel });
});
});
});

it('allows blank options', async () => {
await expect(
() => yf.quote('AAPL', undefined, { devel: 'quote-AAPL.json' })
Expand Down
6 changes: 5 additions & 1 deletion src/modules/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export interface QuoteBase {
quoteSourceName: string; // "Delayed Quote",
triggerable: boolean; // true,
currency: string; // "USD",
marketState: "CLOSED" | "PREPRE" | "POST" | "POSTPOST";
marketState: "REGULAR" | "CLOSED" | "PRE" | "PREPRE" | "POST" | "POSTPOST";
tradeable: boolean; // false,
exchange: string; // "NMS",
shortName: string; // "NVIDIA Corporation",
Expand Down Expand Up @@ -75,6 +75,10 @@ export interface QuoteBase {
regularMarketDayLow?: number; // 541.867,
regularMarketVolume?: number; // 4228841,
regularMarketPreviousClose?: number; // 546.57,
preMarketChange?: number; // -2.9299927,
preMarketChangePercent?: number; // -0.53606904,
preMarketTime?: number; // 1612558802,
preMarketPrice?: number; // 543.64,
bid?: number; // 543.84,
ask?: number; // 544.15,
bidSize?: number; // 18,
Expand Down
73 changes: 73 additions & 0 deletions tests/http/quote-0P000071W8.TO-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=0P000071W8.TO"
},
"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": [
"2ek44mhg27b9c"
],
"x-yahoo-request-id": [
"2ek44mhg27b9c"
],
"x-request-id": [
"ff98e2ee-8def-490d-95d3-271c57d86596"
],
"content-encoding": [
"gzip"
],
"content-length": [
"648"
],
"x-envoy-upstream-service-time": [
"3"
],
"date": [
"Wed, 10 Feb 2021 09:53:47 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\":\"MUTUALFUND\",\"quoteSourceName\":\"Delayed Quote\",\"triggerable\":true,\"currency\":\"CAD\",\"marketState\":\"PREPRE\",\"firstTradeDateMilliseconds\":1344519000000,\"priceHint\":2,\"regularMarketChange\":0.15000153,\"regularMarketChangePercent\":0.16890162,\"regularMarketTime\":1612900800,\"regularMarketPrice\":88.96,\"regularMarketPreviousClose\":88.81,\"fullExchangeName\":\"Toronto\",\"averageDailyVolume3Month\":0,\"averageDailyVolume10Day\":0,\"fiftyTwoWeekLowChange\":31.779999,\"fiftyTwoWeekLowChangePercent\":0.5557887,\"fiftyTwoWeekRange\":\"57.18 - 88.96\",\"fiftyTwoWeekHighChange\":0.0,\"fiftyTwoWeekHighChangePercent\":0.0,\"fiftyTwoWeekLow\":57.18,\"fiftyTwoWeekHigh\":88.96,\"exchange\":\"TOR\",\"shortName\":\"TD U.S. Index Fund - e\",\"longName\":\"TD U.S. Index Fund - e\",\"exchangeTimezoneName\":\"America/Toronto\",\"exchangeTimezoneShortName\":\"EST\",\"gmtOffSetMilliseconds\":-18000000,\"market\":\"ca_market\",\"esgPopulated\":false,\"tradeable\":false,\"ytdReturn\":18.12,\"trailingThreeMonthReturns\":7.59,\"fiftyDayAverage\":86.26305,\"fiftyDayAverageChange\":2.6969528,\"fiftyDayAverageChangePercent\":0.03126429,\"twoHundredDayAverage\":82.27291,\"twoHundredDayAverageChange\":6.687088,\"twoHundredDayAverageChangePercent\":0.081279345,\"sourceInterval\":15,\"exchangeDataDelayedBy\":15,\"symbol\":\"0P000071W8.TO\"}],\"error\":null}}"
}
}
73 changes: 73 additions & 0 deletions tests/http/quote-0P000071W8.TO-10m.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=0P000071W8.TO"
},
"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": [
"18pfvblg27b6f"
],
"x-yahoo-request-id": [
"18pfvblg27b6f"
],
"x-request-id": [
"8979b83a-59fe-4551-b5e2-a6e001c039ef"
],
"content-encoding": [
"gzip"
],
"content-length": [
"646"
],
"x-envoy-upstream-service-time": [
"3"
],
"date": [
"Wed, 10 Feb 2021 09:52:15 GMT"
],
"server": [
"ATS"
],
"x-envoy-decorator-operation": [
"finance-quote-api--mtls-production-ir2.finance-k8s.svc.yahoo.local:4080/*"
],
"age": [
"0"
],
"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\":\"MUTUALFUND\",\"quoteSourceName\":\"Delayed Quote\",\"triggerable\":true,\"currency\":\"CAD\",\"regularMarketChange\":0.15000153,\"regularMarketChangePercent\":0.16890162,\"regularMarketTime\":1612900800,\"regularMarketPrice\":88.96,\"regularMarketPreviousClose\":88.81,\"fullExchangeName\":\"Toronto\",\"averageDailyVolume3Month\":0,\"averageDailyVolume10Day\":0,\"fiftyTwoWeekLowChange\":31.779999,\"fiftyTwoWeekLowChangePercent\":0.5557887,\"fiftyTwoWeekRange\":\"57.18 - 88.96\",\"fiftyTwoWeekHighChange\":0.0,\"fiftyTwoWeekHighChangePercent\":0.0,\"fiftyTwoWeekLow\":57.18,\"fiftyTwoWeekHigh\":88.96,\"ytdReturn\":18.12,\"trailingThreeMonthReturns\":7.59,\"fiftyDayAverage\":86.26305,\"fiftyDayAverageChange\":2.6969528,\"fiftyDayAverageChangePercent\":0.03126429,\"twoHundredDayAverage\":82.27291,\"twoHundredDayAverageChange\":6.687088,\"twoHundredDayAverageChangePercent\":0.081279345,\"sourceInterval\":15,\"exchangeDataDelayedBy\":15,\"firstTradeDateMilliseconds\":1344519000000,\"priceHint\":2,\"exchange\":\"TOR\",\"shortName\":\"TD U.S. Index Fund - e\",\"longName\":\"TD U.S. Index Fund - e\",\"exchangeTimezoneName\":\"America/Toronto\",\"exchangeTimezoneShortName\":\"EST\",\"gmtOffSetMilliseconds\":-18000000,\"market\":\"ca_market\",\"esgPopulated\":false,\"marketState\":\"PREPRE\",\"tradeable\":false,\"symbol\":\"0P000071W8.TO\"}],\"error\":null}}"
}
}
76 changes: 76 additions & 0 deletions tests/http/quote-AAPL-10am.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
{
"request": {
"url": "https://query2.finance.yahoo.com/v7/finance/quote?symbols=AAPL"
},
"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": [
"2gtsmp1g27b6c"
],
"x-yahoo-request-id": [
"2gtsmp1g27b6c"
],
"x-request-id": [
"04af3571-b3d0-44ae-946a-d9b566e8ecc2"
],
"content-encoding": [
"gzip"
],
"content-length": [
"1015"
],
"x-envoy-upstream-service-time": [
"2"
],
"date": [
"Wed, 10 Feb 2021 09:52:11 GMT"
],
"server": [
"ATS"
],
"x-envoy-decorator-operation": [
"finance-quote-api--mtls-production-ir2.finance-k8s.svc.yahoo.local:4080/*"
],
"age": [
"2"
],
"strict-transport-security": [
"max-age=15552000"
],
"warning": [
"110 Response is stale"
],
"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\",\"quoteSourceName\":\"Nasdaq Real Time Price\",\"triggerable\":true,\"currency\":\"USD\",\"tradeable\":false,\"averageDailyVolume3Month\":104997270,\"averageDailyVolume10Day\":83876142,\"fiftyTwoWeekLowChange\":82.8575,\"fiftyTwoWeekLowChangePercent\":1.5588636,\"fiftyTwoWeekRange\":\"53.1525 - 145.09\",\"fiftyTwoWeekHighChange\":-9.080002,\"fiftyTwoWeekHighChangePercent\":-0.06258186,\"fiftyTwoWeekLow\":53.1525,\"fiftyTwoWeekHigh\":145.09,\"dividendDate\":1613001600,\"earningsTimestamp\":1611765000,\"earningsTimestampStart\":1619607540,\"earningsTimestampEnd\":1620043200,\"trailingAnnualDividendRate\":0.807,\"trailingPE\":36.88907,\"trailingAnnualDividendYield\":0.005894383,\"epsTrailingTwelveMonths\":3.687,\"epsForward\":4.69,\"epsCurrentYear\":4.45,\"priceEpsCurrentYear\":30.564045,\"sharesOutstanding\":16788100096,\"bookValue\":3.936,\"fiftyDayAverage\":133.65515,\"fiftyDayAverageChange\":2.3548431,\"fiftyDayAverageChangePercent\":0.017618798,\"twoHundredDayAverage\":120.74684,\"twoHundredDayAverageChange\":15.263153,\"twoHundredDayAverageChangePercent\":0.12640624,\"marketCap\":2283349475328,\"forwardPE\":28.999998,\"priceToBook\":34.555386,\"sourceInterval\":15,\"exchangeDataDelayedBy\":0,\"marketState\":\"PRE\",\"exchange\":\"NMS\",\"shortName\":\"Apple Inc.\",\"longName\":\"Apple Inc.\",\"messageBoardId\":\"finmb_24937\",\"exchangeTimezoneName\":\"America/New_York\",\"exchangeTimezoneShortName\":\"EST\",\"gmtOffSetMilliseconds\":-18000000,\"market\":\"us_market\",\"esgPopulated\":false,\"firstTradeDateMilliseconds\":345479400000,\"priceHint\":2,\"preMarketChange\":0.3899994,\"preMarketChangePercent\":0.2867432,\"preMarketTime\":1612950728,\"preMarketPrice\":136.4,\"regularMarketChange\":-0.90000916,\"regularMarketChangePercent\":-0.65737283,\"regularMarketTime\":1612904402,\"regularMarketPrice\":136.01,\"regularMarketDayHigh\":137.877,\"regularMarketDayRange\":\"135.85 - 137.877\",\"regularMarketDayLow\":135.85,\"regularMarketVolume\":76774213,\"regularMarketPreviousClose\":136.91,\"bid\":136.6,\"ask\":136.67,\"bidSize\":13,\"askSize\":29,\"fullExchangeName\":\"NasdaqGS\",\"financialCurrency\":\"USD\",\"regularMarketOpen\":136.62,\"displayName\":\"Apple\",\"symbol\":\"AAPL\"}],\"error\":null}}"
}
}
Loading

0 comments on commit 1c256c7

Please sign in to comment.