Skip to content

Commit

Permalink
fix(insights): fix schema for more recent yahoo results
Browse files Browse the repository at this point in the history
  • Loading branch information
gadicc committed Mar 6, 2022
1 parent 82ba1cb commit c71a400
Show file tree
Hide file tree
Showing 2 changed files with 164 additions and 10 deletions.
137 changes: 130 additions & 7 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -837,7 +837,6 @@
}
},
"required": [
"targetPrice",
"provider",
"rating"
],
Expand All @@ -863,6 +862,24 @@
},
"upsell": {
"$ref": "#/definitions/InsightsUpsell"
},
"upsellSearchDD": {
"type": "object",
"properties": {
"researchReports": {
"$ref": "#/definitions/InsightsResearchReport"
}
},
"required": [
"researchReports"
],
"additionalProperties": false
},
"secReports": {
"type": "array",
"items": {
"$ref": "#/definitions/InsightsSecReport"
}
}
},
"required": [
Expand Down Expand Up @@ -1115,13 +1132,32 @@
"type": "string"
},
"reportDate": {
"type": "string"
"yahooFinanceType": "date"
},
"reportTitle": {
"type": "string"
},
"reportType": {
"type": "string"
},
"targetPrice": {
"yahooFinanceType": "number"
},
"targetPriceStatus": {
"type": "string",
"enum": [
"Increased",
"Maintained",
"Decreased"
]
},
"investmentRating": {
"type": "string",
"enum": [
"Bullish",
"Neutral",
"Bearish"
]
}
},
"required": [
Expand Down Expand Up @@ -1151,6 +1187,21 @@
"InsightsUpsell": {
"type": "object",
"properties": {
"msBullishSummary": {
"type": "array",
"items": {
"type": "string"
}
},
"msBearishSummary": {
"type": "array",
"items": {
"type": "string"
}
},
"msBullishBearishSummariesPublishDate": {
"yahooFinanceType": "DateInMs"
},
"companyName": {
"type": "string"
},
Expand All @@ -1159,10 +1210,85 @@
}
},
"required": [
"companyName",
"upsellReportType"
"companyName"
]
},
"DateInMs": {
"yahooFinanceType": "date"
},
"InsightsResearchReport": {
"type": "object",
"properties": {
"reportId": {
"type": "string"
},
"provider": {
"type": "string"
},
"title": {
"type": "string"
},
"reportDate": {
"yahooFinanceType": "date"
},
"summary": {
"type": "string"
},
"investmentRating": {
"type": "string",
"enum": [
"Bullish",
"Neutral",
"Bearish"
]
}
},
"required": [
"reportId",
"provider",
"title",
"reportDate",
"summary",
"investmentRating"
],
"additionalProperties": false
},
"InsightsSecReport": {
"type": "object",
"properties": {
"id": {
"type": "string"
},
"type": {
"type": "string"
},
"title": {
"type": "string"
},
"description": {
"type": "string"
},
"filingDate": {
"yahooFinanceType": "DateInMs"
},
"snapshotUrl": {
"type": "string"
},
"formType": {
"type": "string"
}
},
"required": [
"id",
"type",
"title",
"description",
"filingDate",
"snapshotUrl",
"formType"
],
"additionalProperties": false
},
"InsightsOptions": {
"type": "object",
"properties": {
Expand Down Expand Up @@ -1531,9 +1657,6 @@
],
"additionalProperties": false
},
"DateInMs": {
"yahooFinanceType": "date"
},
"QuoteCryptoCurrency": {
"type": "object",
"properties": {
Expand Down
37 changes: 34 additions & 3 deletions src/modules/insights.ts
Original file line number Diff line number Diff line change
Expand Up @@ -5,20 +5,26 @@ import type {
ModuleThis,
} from "../lib/moduleCommon.js";

import type { DateInMs } from "../lib/commonTypes.js";

export interface InsightsResult {
[key: string]: any;
symbol: string;
instrumentInfo?: InsightsInstrumentInfo;
companySnapshot?: InsightsCompanySnapshot;
recommendation?: {
targetPrice: number;
targetPrice?: number;
provider: string;
rating: "BUY" | "SELL" | "HOLD";
};
events?: InsightsEvent[];
reports?: InsightsReport[];
sigDevs: InsightsSigDev[];
upsell?: InsightsUpsell;
upsellSearchDD?: {
researchReports: InsightsResearchReport;
};
secReports?: InsightsSecReport[];
}

export interface InsightsSigDev {
Expand All @@ -32,9 +38,31 @@ export interface InsightsReport {
id: string;
headHtml: string;
provider: string;
reportDate: string;
reportDate: Date;
reportTitle: string;
reportType: string;
targetPrice?: number;
targetPriceStatus?: "Increased" | "Maintained" | "Decreased";
investmentRating?: "Bullish" | "Neutral" | "Bearish";
}

export interface InsightsResearchReport {
reportId: string;
provider: string;
title: string;
reportDate: Date;
summary: string;
investmentRating: "Bullish" | "Neutral" | "Bearish";
}

export interface InsightsSecReport {
id: string;
type: string;
title: string;
description: string;
filingDate: DateInMs;
snapshotUrl: string;
formType: string;
}

export interface InsightsEvent {
Expand Down Expand Up @@ -116,8 +144,11 @@ export interface InsightsOutlook {

export interface InsightsUpsell {
[key: string]: any;
msBullishSummary?: Array<string>;
msBearishSummary?: Array<string>;
msBullishBearishSummariesPublishDate?: DateInMs;
companyName: string;
upsellReportType: string;
upsellReportType?: string;
}

export interface InsightsOptions {
Expand Down

0 comments on commit c71a400

Please sign in to comment.