Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(quote): Add beta to quote field option #713

Merged
merged 1 commit into from
Nov 20, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 28 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -2378,6 +2378,9 @@
},
"openInterest": {
"yahooFinanceType": "number"
},
"beta": {
"yahooFinanceType": "number"
}
},
"required": [
Expand Down Expand Up @@ -2707,6 +2710,9 @@
"openInterest": {
"yahooFinanceType": "number"
},
"beta": {
"yahooFinanceType": "number"
},
"circulatingSupply": {
"yahooFinanceType": "number"
},
Expand Down Expand Up @@ -3046,6 +3052,9 @@
},
"openInterest": {
"yahooFinanceType": "number"
},
"beta": {
"yahooFinanceType": "number"
}
},
"required": [
Expand Down Expand Up @@ -3358,6 +3367,9 @@
},
"openInterest": {
"yahooFinanceType": "number"
},
"beta": {
"yahooFinanceType": "number"
}
},
"required": [
Expand Down Expand Up @@ -3671,6 +3683,9 @@
"openInterest": {
"yahooFinanceType": "number"
},
"beta": {
"yahooFinanceType": "number"
},
"dividendRate": {
"yahooFinanceType": "number"
},
Expand Down Expand Up @@ -3989,6 +4004,9 @@
"openInterest": {
"yahooFinanceType": "number"
},
"beta": {
"yahooFinanceType": "number"
},
"headSymbolAsString": {
"type": "string"
},
Expand Down Expand Up @@ -4320,6 +4338,9 @@
},
"openInterest": {
"yahooFinanceType": "number"
},
"beta": {
"yahooFinanceType": "number"
}
},
"required": [
Expand Down Expand Up @@ -4633,6 +4654,9 @@
"openInterest": {
"yahooFinanceType": "number"
},
"beta": {
"yahooFinanceType": "number"
},
"strike": {
"yahooFinanceType": "number"
},
Expand Down Expand Up @@ -4958,6 +4982,9 @@
},
"openInterest": {
"yahooFinanceType": "number"
},
"beta": {
"yahooFinanceType": "number"
}
},
"required": [
Expand Down Expand Up @@ -5112,6 +5139,7 @@
"averageAnalystRating",
"pageViewGrowthWeekly",
"openInterest",
"beta",
"dividendRate",
"dividendYield",
"headSymbolAsString",
Expand Down
8 changes: 8 additions & 0 deletions src/modules/quote.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -130,4 +130,12 @@ describe("quote", () => {
expect(result).toBe(undefined);
});
});

it("passes through beta field option", async () => {
const devel = "quote-MSFT-fields-beta.json";
const queryOpts = { fields: ["beta"] };
const result = await yf.quote("MSFT", queryOpts, { devel });
expect(result.symbol).toBe("MSFT");
expect(result.beta).toBeDefined();
});
});
1 change: 1 addition & 0 deletions src/modules/quote.ts
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,7 @@ export interface QuoteBase {
averageAnalystRating?: string;
pageViewGrowthWeekly?: number; // Since 2021-11-11 (#326)
openInterest?: number; // SOHO (#248)
beta?: number;
}

/*
Expand Down
58 changes: 58 additions & 0 deletions tests/http/quote-MSFT-fields-beta.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,58 @@
{
"request": {
"url": "https://query2.finance.yahoo.com/v7/finance/quote?symbols=MSFT&fields=beta"
},
"response": {
"ok": true,
"status": 200,
"statusText": "OK",
"headers": {
"content-type": [
"application/json;charset=utf-8"
],
"vary": [
"Origin,Accept-Encoding"
],
"cache-control": [
"public, max-age=1, stale-while-revalidate=9"
],
"content-length": [
"603"
],
"x-envoy-upstream-service-time": [
"2"
],
"date": [
"Sat, 18 Nov 2023 17:35:06 GMT"
],
"server": [
"ATS"
],
"x-envoy-decorator-operation": [
"finance-quote-api--mtls-production-bf1.finance-k8s.svc.yahoo.local:4080/*"
],
"age": [
"0"
],
"strict-transport-security": [
"max-age=31536000"
],
"referrer-policy": [
"no-referrer-when-downgrade"
],
"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\",\"typeDisp\":\"Equity\",\"quoteSourceName\":\"Delayed Quote\",\"triggerable\":true,\"customPriceAlertConfidence\":\"HIGH\",\"marketState\":\"CLOSED\",\"exchange\":\"NMS\",\"exchangeTimezoneName\":\"America/New_York\",\"exchangeTimezoneShortName\":\"EST\",\"gmtOffSetMilliseconds\":-18000000,\"market\":\"us_market\",\"esgPopulated\":false,\"firstTradeDateMilliseconds\":511108200000,\"priceHint\":2,\"fullExchangeName\":\"NasdaqGS\",\"beta\":0.885,\"sourceInterval\":15,\"exchangeDataDelayedBy\":0,\"tradeable\":false,\"cryptoTradeable\":false,\"symbol\":\"MSFT\"}],\"error\":null}}"
}
}