Skip to content

Commit

Permalink
feat(historical-v8): Fetch prices, splits, dividends in one network r…
Browse files Browse the repository at this point in the history
…equest.

1. Apply patch generated from [gadicc#239] that fetches
historical prices, splits, and dividends in a single network request.
Original code by @PythonCreator27.

2. Regenerate schema.

Fixes [gadicc/node-yahoo-finance#238]
  • Loading branch information
huned committed Nov 12, 2021
1 parent 2dac6d7 commit e5379e1
Show file tree
Hide file tree
Showing 3 changed files with 444 additions and 0 deletions.
269 changes: 269 additions & 0 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -244,6 +244,275 @@
],
"additionalProperties": false
},
"Historical2Result": {
"type": "object",
"properties": {
"quote": {
"type": "array",
"items": {
"type": "object",
"properties": {
"date": {
"yahooFinanceType": "date"
},
"open": {
"yahooFinanceType": "number"
},
"high": {
"yahooFinanceType": "number"
},
"low": {
"yahooFinanceType": "number"
},
"close": {
"yahooFinanceType": "number"
},
"adjClose": {
"yahooFinanceType": "number"
},
"volume": {
"yahooFinanceType": "number"
}
},
"required": [
"date",
"open",
"high",
"low",
"close",
"volume"
],
"additionalProperties": false
}
},
"dividends": {
"type": "array",
"items": {
"type": "object",
"properties": {
"date": {
"yahooFinanceType": "date"
},
"amount": {
"yahooFinanceType": "number"
}
},
"required": [
"date",
"amount"
],
"additionalProperties": false
}
},
"splits": {
"type": "array",
"items": {
"type": "object",
"properties": {
"date": {
"yahooFinanceType": "date"
},
"numerator": {
"yahooFinanceType": "number"
},
"denominator": {
"yahooFinanceType": "number"
},
"splitRatio": {
"type": "string"
}
},
"required": [
"date",
"numerator",
"denominator",
"splitRatio"
],
"additionalProperties": false
}
},
"meta": {
"type": "object",
"properties": {
"currency": {
"type": "string"
},
"symbol": {
"type": "string"
},
"exchangeName": {
"type": "string"
},
"instrumentType": {
"type": "string"
},
"firstTradeDate": {
"yahooFinanceType": "date"
},
"regularMarketTime": {
"yahooFinanceType": "date"
},
"gmtoffset": {
"yahooFinanceType": "number"
},
"timezone": {
"type": "string"
},
"exchangeTimezoneName": {
"type": "string"
},
"regularMarketPrice": {
"yahooFinanceType": "number"
},
"chartPreviousClose": {
"yahooFinanceType": "number"
},
"priceHint": {
"yahooFinanceType": "number"
},
"currentTradingPeriod": {
"type": "object",
"properties": {
"pre": {
"$ref": "#/definitions/Historical2TradingPeriod"
},
"regular": {
"$ref": "#/definitions/Historical2TradingPeriod"
},
"post": {
"$ref": "#/definitions/Historical2TradingPeriod"
}
},
"required": [
"pre",
"regular",
"post"
],
"additionalProperties": false
},
"dataGranularity": {
"type": "string",
"enum": [
"1d",
"1wk",
"1mo"
]
},
"range": {
"type": "string"
},
"validRanges": {
"type": "array",
"items": {
"type": "string"
}
}
},
"required": [
"symbol",
"exchangeName",
"instrumentType",
"firstTradeDate",
"regularMarketTime",
"gmtoffset",
"timezone",
"exchangeTimezoneName",
"regularMarketPrice",
"chartPreviousClose",
"priceHint",
"currentTradingPeriod",
"dataGranularity",
"range",
"validRanges"
],
"additionalProperties": false
}
},
"required": [
"quote",
"meta"
],
"additionalProperties": false
},
"Historical2TradingPeriod": {
"type": "object",
"properties": {
"timezone": {
"type": "string"
},
"start": {
"yahooFinanceType": "date"
},
"end": {
"yahooFinanceType": "date"
},
"gmtoffset": {
"yahooFinanceType": "number"
}
},
"required": [
"timezone",
"start",
"end",
"gmtoffset"
],
"additionalProperties": false
},
"Historical2Options": {
"type": "object",
"properties": {
"period1": {
"anyOf": [
{
"yahooFinanceType": "date"
},
{
"type": "string"
},
{
"yahooFinanceType": "number"
}
]
},
"period2": {
"anyOf": [
{
"yahooFinanceType": "date"
},
{
"type": "string"
},
{
"yahooFinanceType": "number"
}
]
},
"interval": {
"type": "string",
"enum": [
"1d",
"1wk",
"1mo"
]
},
"events": {
"type": "string",
"enum": [
"div",
"split",
"div|split"
]
},
"includeAdjustedClose": {
"type": "boolean"
}
},
"required": [
"period1",
"period2"
],
"additionalProperties": false
},
"InsightsResult": {
"type": "object",
"properties": {
Expand Down
2 changes: 2 additions & 0 deletions src/index-common.ts
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import errors from "./lib/errors.js";
// modules
import autoc from "./modules/autoc.js";
import historical from "./modules/historical.js";
import historical2 from "./modules/historical2.js";
import insights from "./modules/insights.js";
import optionsModule from "./modules/options.js";
import quote from "./modules/quote.js";
Expand Down Expand Up @@ -38,6 +39,7 @@ export default {
recommendationsBySymbol,
search,
trendingSymbols,
historical2,

// other
quoteCombine,
Expand Down
Loading

0 comments on commit e5379e1

Please sign in to comment.