Skip to content

Commit

Permalink
fix(search): change longname to be an optional property
Browse files Browse the repository at this point in the history
  • Loading branch information
pudgereyem committed Feb 4, 2021
1 parent 1e5473b commit 9b8128d
Show file tree
Hide file tree
Showing 7 changed files with 305 additions and 125 deletions.
121 changes: 0 additions & 121 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2157,38 +2157,6 @@
"type": "string"
}
},
"required": [
"link",
"providerPublishTime",
"publisher",
"title",
"type",
"uuid"
],
"type": "object"
},
"SearchNewsOrig": {
"additionalProperties": false,
"properties": {
"link": {
"type": "string"
},
"providerPublishTime": {
"yahooFinanceType": "number"
},
"publisher": {
"type": "string"
},
"title": {
"type": "string"
},
"type": {
"type": "string"
},
"uuid": {
"type": "string"
}
},
"required": [
"uuid",
"title",
Expand Down Expand Up @@ -2306,7 +2274,6 @@
"index",
"score",
"typeDisp",
"longname",
"isYahooFinance"
],
"type": "object"
Expand Down Expand Up @@ -2424,94 +2391,6 @@
"yahooFinanceType": "number"
}
},
"required": [
"count",
"explains",
"lists",
"nav",
"news",
"quotes",
"researchReports",
"timeTakenForAlgowatchlist",
"timeTakenForCrunchbase",
"timeTakenForNav",
"timeTakenForNews",
"timeTakenForPredefinedScreener",
"timeTakenForQuotes",
"timeTakenForResearchReports",
"totalTime"
],
"type": "object"
},
"SearchResultOrig": {
"additionalProperties": false,
"properties": {
"count": {
"yahooFinanceType": "number"
},
"explains": {
"items": {},
"type": "array"
},
"lists": {
"items": {},
"type": "array"
},
"nav": {
"items": {},
"type": "array"
},
"news": {
"items": {
"$ref": "#/definitions/SearchNewsOrig"
},
"type": "array"
},
"quotes": {
"items": {
"anyOf": [
{
"$ref": "#/definitions/SearchQuoteYahooEquity"
},
{
"$ref": "#/definitions/SearchQuoteYahooOption"
},
{
"$ref": "#/definitions/SearchQuoteNonYahoo"
}
]
},
"type": "array"
},
"researchReports": {
"items": {},
"type": "array"
},
"timeTakenForAlgowatchlist": {
"yahooFinanceType": "number"
},
"timeTakenForCrunchbase": {
"yahooFinanceType": "number"
},
"timeTakenForNav": {
"yahooFinanceType": "number"
},
"timeTakenForNews": {
"yahooFinanceType": "number"
},
"timeTakenForPredefinedScreener": {
"yahooFinanceType": "number"
},
"timeTakenForQuotes": {
"yahooFinanceType": "number"
},
"timeTakenForResearchReports": {
"yahooFinanceType": "number"
},
"totalTime": {
"yahooFinanceType": "number"
}
},
"required": [
"explains",
"count",
Expand Down
16 changes: 14 additions & 2 deletions src/modules/search.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,22 @@ const yf = {
search
};

const testSearches = [
"AAPL", // NMS (Nasdaq)
"OCDO.L", // LSE
"BABA", // NYSE
"Evolution Gaming Group", // STO
"Bayerische Motoren Werke AG", // GER
];

describe('search', () => {

it('passes validation', async () => {
await yf.search('AAPL', {}, { devel: "search-AAPL.json" });
// validate different searches
testSearches.forEach((search) => {
it(`passed validation for search: ${search}`, async () => {
const devel = `search-${search}.json`;
await yf.search(search, {}, { devel });
});
});

it('throws InvalidOptions on invalid options', async () => {
Expand Down
4 changes: 2 additions & 2 deletions src/modules/search.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,8 +5,8 @@ export interface SearchQuoteYahooEquity {
symbol: string; // "BABA"
index: "quotes"; // "quotes"
score: number; // 1111958.0
typeDisp: "Equity"; // "Equity"
longname: string; // "Alibaba Group Holding Limited"
typeDisp: "Equity"; // "Equity"
longname?: string; // "Alibaba Group Holding Limited"
isYahooFinance: true; // true
}
export interface SearchQuoteYahooOption {
Expand Down
73 changes: 73 additions & 0 deletions tests/http/search-BABA.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"request": {
"url": "https://query2.finance.yahoo.com/v1/finance/search?lang=en-US&region=US&quotesCount=6&newsCount=4&enableFuzzyQuery=false&quotesQueryId=tss_match_phrase_query&multiQuoteQueryId=multi_quote_single_token_query&newsQueryId=news_cie_vespa&enableCb=true&enableNavLinks=true&enableEnhancedTrivialQuery=true&q=BABA"
},
"response": {
"ok": true,
"status": 200,
"statusText": "OK",
"headers": {
"content-type": [
"application/json"
],
"vary": [
"Origin,Origin,Accept-Encoding"
],
"cache-control": [
"public, max-age=120, stale-while-revalidate=180"
],
"y-rid": [
"254otvdg1oh2f"
],
"x-yahoo-request-id": [
"254otvdg1oh2f"
],
"x-request-id": [
"25d97636-8501-44e6-adff-6fd48ef1b5d2"
],
"content-encoding": [
"gzip"
],
"content-length": [
"973"
],
"x-envoy-upstream-service-time": [
"51"
],
"date": [
"Thu, 04 Feb 2021 19:00:31 GMT"
],
"server": [
"ATS"
],
"x-envoy-decorator-operation": [
"finance-search--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": "{\"explains\":[],\"count\":11,\"quotes\":[{\"exchange\":\"NYQ\",\"shortname\":\"Alibaba Group Holding Limited\",\"quoteType\":\"EQUITY\",\"symbol\":\"BABA\",\"index\":\"quotes\",\"score\":1.030526E8,\"typeDisp\":\"Equity\",\"longname\":\"Alibaba Group Holding Limited\",\"isYahooFinance\":true},{\"exchange\":\"HKG\",\"shortname\":\"BABA-SW\",\"quoteType\":\"EQUITY\",\"symbol\":\"9988.HK\",\"index\":\"quotes\",\"score\":88098.0,\"typeDisp\":\"Equity\",\"longname\":\"Alibaba Group Holding Limited\",\"isYahooFinance\":true},{\"exchange\":\"PNK\",\"shortname\":\"ALIBABA GROUP HOLDING LTD\",\"quoteType\":\"EQUITY\",\"symbol\":\"BABAF\",\"index\":\"quotes\",\"score\":22257.0,\"typeDisp\":\"Equity\",\"longname\":\"Alibaba Group Holding Limited\",\"isYahooFinance\":true},{\"exchange\":\"MEX\",\"shortname\":\"ALIBABA GROUP HOLDING LTD\",\"quoteType\":\"EQUITY\",\"symbol\":\"BABAN.MX\",\"index\":\"quotes\",\"score\":20295.0,\"typeDisp\":\"Equity\",\"longname\":\"Alibaba Group Holding Limited\",\"isYahooFinance\":true},{\"exchange\":\"BUE\",\"shortname\":\"ALIBABA GROUP HLDG\",\"quoteType\":\"EQUITY\",\"symbol\":\"BABA.BA\",\"index\":\"quotes\",\"score\":20139.0,\"typeDisp\":\"Equity\",\"isYahooFinance\":true},{\"index\":\"28c0f1efda8f3257fb1353d48c109146\",\"name\":\"Babajob\",\"permalink\":\"babajob\",\"isYahooFinance\":false},{\"index\":\"bfb458f36b57fa497a837e6b565b6b5a\",\"name\":\"BABADU\",\"permalink\":\"babadu\",\"isYahooFinance\":false}],\"news\":[{\"uuid\":\"64f6c4d1-8034-37b9-b169-9c5af532bc0a\",\"title\":\"Best China ETFs for Q2 2021\",\"publisher\":\"Investopedia\",\"link\":\"https://finance.yahoo.com/m/64f6c4d1-8034-37b9-b169-9c5af532bc0a/best-china-etfs-for-q2-2021.html\",\"providerPublishTime\":1612463129,\"type\":\"STORY\"},{\"uuid\":\"0b988176-57f4-3b24-8e21-6013e44cda32\",\"title\":\"Alibaba Poised to Sell $5 Billion of Bonds in Four-Part Offering\",\"publisher\":\"Bloomberg\",\"link\":\"https://finance.yahoo.com/news/alibaba-rallies-credit-market-dollar-081527208.html\",\"providerPublishTime\":1612464477,\"type\":\"STORY\"},{\"uuid\":\"cab8d0ee-c691-3074-8205-916591e2f453\",\"title\":\"BABA earnings and revenue beat expectations\",\"publisher\":\"Yahoo Finance\",\"link\":\"https://finance.yahoo.com/news/baba-alibaba-earnings-235121833.html\",\"providerPublishTime\":1612275357,\"type\":\"STORY\"},{\"uuid\":\"9661284b-99b3-35ba-8bfa-d62a69bd0c87\",\"title\":\"Alibaba Group Holding Ltd. (BABA) Q3 2021 Earnings Call Transcript\",\"publisher\":\"Motley Fool\",\"link\":\"https://finance.yahoo.com/m/9661284b-99b3-35ba-8bfa-d62a69bd0c87/alibaba-group-holding-ltd..html\",\"providerPublishTime\":1612319495,\"type\":\"STORY\"}],\"nav\":[],\"lists\":[],\"researchReports\":[],\"totalTime\":49,\"timeTakenForQuotes\":428,\"timeTakenForNews\":700,\"timeTakenForAlgowatchlist\":400,\"timeTakenForPredefinedScreener\":400,\"timeTakenForCrunchbase\":400,\"timeTakenForNav\":400,\"timeTakenForResearchReports\":0}"
}
}
73 changes: 73 additions & 0 deletions tests/http/search-Bayerische Motoren Werke AG.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,73 @@
{
"request": {
"url": "https://query2.finance.yahoo.com/v1/finance/search?lang=en-US&region=US&quotesCount=6&newsCount=4&enableFuzzyQuery=false&quotesQueryId=tss_match_phrase_query&multiQuoteQueryId=multi_quote_single_token_query&newsQueryId=news_cie_vespa&enableCb=true&enableNavLinks=true&enableEnhancedTrivialQuery=true&q=Bayerische+Motoren+Werke+AG"
},
"response": {
"ok": true,
"status": 200,
"statusText": "OK",
"headers": {
"content-type": [
"application/json"
],
"vary": [
"Origin,Origin,Accept-Encoding"
],
"cache-control": [
"public, max-age=120, stale-while-revalidate=180"
],
"y-rid": [
"8abjk71g1oh2g"
],
"x-yahoo-request-id": [
"8abjk71g1oh2g"
],
"x-request-id": [
"56cc847d-3bf9-42e4-bfe2-8aed071c55d7"
],
"content-encoding": [
"gzip"
],
"content-length": [
"1147"
],
"x-envoy-upstream-service-time": [
"40"
],
"date": [
"Thu, 04 Feb 2021 19:00:31 GMT"
],
"server": [
"ATS"
],
"x-envoy-decorator-operation": [
"finance-search--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": "{\"explains\":[],\"count\":12,\"quotes\":[{\"exchange\":\"PNK\",\"shortname\":\"BAYERISCHE MOTOREN WERKE AG\",\"quoteType\":\"EQUITY\",\"symbol\":\"BMWYY\",\"index\":\"quotes\",\"score\":21419.0,\"typeDisp\":\"Equity\",\"longname\":\"Bayerische Motoren Werke Aktiengesellschaft\",\"isYahooFinance\":true},{\"exchange\":\"PNK\",\"shortname\":\"BAYERISCHE MOTOREN WERKE AG\",\"quoteType\":\"EQUITY\",\"symbol\":\"BAMXF\",\"index\":\"quotes\",\"score\":20076.0,\"typeDisp\":\"Equity\",\"longname\":\"Bayerische Motoren Werke Aktiengesellschaft\",\"isYahooFinance\":true},{\"exchange\":\"STU\",\"shortname\":\"Bayerische Motoren Werke AG Nam\",\"quoteType\":\"EQUITY\",\"symbol\":\"BMWB.SG\",\"index\":\"quotes\",\"score\":20017.0,\"typeDisp\":\"Equity\",\"isYahooFinance\":true},{\"exchange\":\"MEX\",\"shortname\":\"BAYERISCHE MOTOREN WERKE AG\",\"quoteType\":\"EQUITY\",\"symbol\":\"BMWM5N.MX\",\"index\":\"quotes\",\"score\":20004.0,\"typeDisp\":\"Equity\",\"longname\":\"Bayerische Motoren Werke Aktiengesellschaft\",\"isYahooFinance\":true},{\"exchange\":\"IOB\",\"shortname\":\"BAYERISCHE MOTOREN WERKE AG BMW\",\"quoteType\":\"EQUITY\",\"symbol\":\"0O0V.IL\",\"index\":\"quotes\",\"score\":20001.0,\"typeDisp\":\"Equity\",\"isYahooFinance\":true},{\"exchange\":\"IOB\",\"shortname\":\"BAYERISCHE MOTOREN WERKE AG BMW\",\"quoteType\":\"EQUITY\",\"symbol\":\"0O0U.IL\",\"index\":\"quotes\",\"score\":20001.0,\"typeDisp\":\"Equity\",\"isYahooFinance\":true}],\"news\":[{\"uuid\":\"882e19ed-6b71-3498-a2cf-33c1be252fb1\",\"title\":\"BMW Canada Auto Trust 2021-1 -- Moody's assigns provisional ratings to BMW Canada Auto Trust 2021-1 notes\",\"publisher\":\"Moody's\",\"link\":\"https://finance.yahoo.com/news/bmw-canada-auto-trust-2021-150808166.html\",\"providerPublishTime\":1612451288,\"type\":\"STORY\"},{\"uuid\":\"145581c7-9fbd-3cba-a1ed-9dc1a94c22a2\",\"title\":\"ROSEN, GLOBAL INVESTOR COUNSEL, Reminds Bayerische Motoren Werke AG Investors of Important December 28 Deadline in First Filed Securities Class Action Commenced by the Firm – BMWYY, BAMXF\",\"publisher\":\"GlobeNewswire\",\"link\":\"https://finance.yahoo.com/news/rosen-global-investor-counsel-reminds-001800995.html\",\"providerPublishTime\":1605917880,\"type\":\"STORY\"},{\"uuid\":\"501140e5-0b5f-34f3-ba8d-7c4cfa6f4011\",\"title\":\"ROSEN, A TOP RANKED LAW FIRM, Reminds Bayerische Motoren Werke AG Investors of Important Deadline in Securities Class Action First Filed by the Firm – BMWYY, BAMXF\",\"publisher\":\"GlobeNewswire\",\"link\":\"https://finance.yahoo.com/news/rosen-top-ranked-law-firm-184500445.html\",\"providerPublishTime\":1607193900,\"type\":\"STORY\"},{\"uuid\":\"e45869d5-a6ef-3877-a01a-bc4b2810c08a\",\"title\":\"ROSEN, A LEADING INVESTOR RIGHTS LAW FIRM, Reminds Bayerische Motoren Werke AG Investors of Important Deadline in Securities Class Action First Filed by the Firm – BMWYY, BAMXF\",\"publisher\":\"GlobeNewswire\",\"link\":\"https://finance.yahoo.com/news/rosen-leading-investor-rights-law-003800640.html\",\"providerPublishTime\":1608251880,\"type\":\"STORY\"}],\"nav\":[],\"lists\":[{\"slug\":\"the-fight-against-covid19\",\"name\":\"The Fight Against COVID19\",\"index\":\"the-fight-against-covid19\",\"score\":6.588091,\"type\":\"ALGO_WATCHLIST\",\"brandSlug\":\"trea\",\"pfId\":\"the_fight_against_covid19\"},{\"slug\":\"aging-baby-boomers\",\"name\":\"Aging Baby Boomers\",\"index\":\"aging-baby-boomers\",\"score\":1.0670694,\"type\":\"ALGO_WATCHLIST\",\"brandSlug\":\"yahoo-finance\",\"pfId\":\"aging_baby_boomers\"}],\"researchReports\":[],\"totalTime\":39,\"timeTakenForQuotes\":420,\"timeTakenForNews\":700,\"timeTakenForAlgowatchlist\":400,\"timeTakenForPredefinedScreener\":400,\"timeTakenForCrunchbase\":400,\"timeTakenForNav\":400,\"timeTakenForResearchReports\":0}"
}
}
Loading

0 comments on commit 9b8128d

Please sign in to comment.