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

fix module chart: fixes validation error in the case where null value… #662

Merged
merged 1 commit into from
Sep 4, 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
14 changes: 14 additions & 0 deletions src/modules/chart.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -34,6 +34,20 @@ describe("chart", () => {
);
});

it("passes validation if some results are null", async () => {
await yf.chart(
"WSU.DE",
{
period1: "2023-08-04", // This was yielding a FailedYahooValidationError since
period2: "2023-08-09", // there are no results on the 2023-08-07
return: "object", // native Yahoo return format, first validation step.
},
{
devel: `chart-WSU.DE-2023-08-04-to-2023-08-09.json`,
}
);
});

it("throws if period1,period2 are the same", async () => {
await expect(
yf.chart("TSLA", { period1: "2022-02-22", period2: "2022-02-22" })
Expand Down
24 changes: 12 additions & 12 deletions src/modules/chart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,12 +24,12 @@ export interface ChartResultArray {
export interface ChartResultArrayQuote {
[key: string]: any;
date: Date;
high: number;
low: number;
open: number;
close: number;
volume: number;
adjclose?: number;
high: number|null;
low: number|null;
open: number|null;
close: number|null;
volume: number|null;
adjclose?: number|null;
}

export interface ChartMeta {
Expand Down Expand Up @@ -117,16 +117,16 @@ export interface ChartIndicatorsObject {

export interface ChartIndicatorQuote {
[key: string]: any;
high: Array<number>;
low: Array<number>;
open: Array<number>;
close: Array<number>;
volume: Array<number>;
high: Array<number|null>;
low: Array<number|null>;
open: Array<number|null>;
close: Array<number|null>;
volume: Array<number|null>;
}

export interface ChartIndicatorAdjclose {
[key: string]: any;
adjclose?: Array<number>; // Missing in e.g. "APS.AX"
adjclose?: Array<number|null>; // Missing in e.g. "APS.AX"
}

export interface ChartOptions {
Expand Down