Skip to content

Commit

Permalink
fix(quoteSummary): more optional props, more tests
Browse files Browse the repository at this point in the history
  • Loading branch information
gadicc committed Feb 3, 2021
1 parent 0b85048 commit 3fa958c
Show file tree
Hide file tree
Showing 4 changed files with 64 additions and 52 deletions.
81 changes: 40 additions & 41 deletions schema.json
Original file line number Diff line number Diff line change
Expand Up @@ -283,15 +283,12 @@
"maxAge",
"endDate",
"cash",
"netReceivables",
"inventory",
"otherCurrentAssets",
"totalCurrentAssets",
"longTermInvestments",
"propertyPlantEquipment",
"otherAssets",
"totalAssets",
"accountsPayable",
"otherCurrentLiab",
"longTermDebt",
"otherLiab",
Expand Down Expand Up @@ -441,7 +438,6 @@
"capitalExpenditures",
"otherCashflowsFromInvestingActivities",
"totalCashflowsFromInvestingActivities",
"netBorrowings",
"otherCashflowsFromFinancingActivities",
"totalCashFromFinancingActivities",
"changeInCash"
Expand Down Expand Up @@ -1800,6 +1796,45 @@
],
"type": "object"
},
"QuoteSummaryModules": {
"enum": [
"assetProfile",
"balanceSheetHistory",
"balanceSheetHistoryQuarterly",
"calendarEvents",
"cashflowStatementHistory",
"cashflowStatementHistoryQuarterly",
"defaultKeyStatistics",
"earnings",
"earningsHistory",
"earningsTrend",
"financialData",
"fundOwnership",
"fundPerformance",
"fundProfile",
"incomeStatementHistory",
"incomeStatementHistoryQuarterly",
"indexTrend",
"industryTrend",
"insiderHolders",
"insiderTransactions",
"institutionOwnership",
"majorDirectHolders",
"majorHoldersBreakdown",
"netSharePurchaseActivity",
"price",
"quoteType",
"recommendationTrend",
"secFilings",
"sectorTrend",
"summaryDetail",
"summaryProfile",
"symbol",
"topHoldings",
"upgradeDowngradeHistory"
],
"type": "string"
},
"QuoteSummaryOptions": {
"additionalProperties": false,
"properties": {
Expand All @@ -1810,43 +1845,7 @@
"anyOf": [
{
"items": {
"enum": [
"assetProfile",
"balanceSheetHistory",
"balanceSheetHistoryQuarterly",
"calendarEvents",
"cashflowStatementHistory",
"cashflowStatementHistoryQuarterly",
"defaultKeyStatistics",
"earnings",
"earningsHistory",
"earningsTrend",
"financialData",
"fundOwnership",
"fundPerformance",
"fundProfile",
"incomeStatementHistory",
"incomeStatementHistoryQuarterly",
"indexTrend",
"industryTrend",
"insiderHolders",
"insiderTransactions",
"institutionOwnership",
"majorDirectHolders",
"majorHoldersBreakdown",
"netSharePurchaseActivity",
"price",
"quoteType",
"recommendationTrend",
"secFilings",
"sectorTrend",
"summaryDetail",
"summaryProfile",
"symbol",
"topHoldings",
"upgradeDowngradeHistory"
],
"type": "string"
"$ref": "#/definitions/QuoteSummaryModules"
},
"type": "array"
},
Expand Down
8 changes: 4 additions & 4 deletions src/modules/quoteSummary-iface.ts
Original file line number Diff line number Diff line change
Expand Up @@ -91,15 +91,15 @@ export interface BalanceSheetStatement {
endDate: Date;
cash: number;
shortTermInvestments?: number;
netReceivables: number;
inventory: number;
netReceivables?: number;
inventory?: number;
otherCurrentAssets: number;
totalCurrentAssets: number;
longTermInvestments: number;
propertyPlantEquipment: number;
otherAssets: number;
totalAssets: number;
accountsPayable: number;
accountsPayable?: number;
shortLongTermDebt?: number;
otherCurrentLiab: number;
longTermDebt: number;
Expand Down Expand Up @@ -158,7 +158,7 @@ export interface CashflowStatement {
otherCashflowsFromInvestingActivities: number;
totalCashflowsFromInvestingActivities: number;
dividendsPaid?: number;
netBorrowings: number;
netBorrowings?: number;
otherCashflowsFromFinancingActivities: number;
totalCashFromFinancingActivities: number;
changeInCash: number;
Expand Down
23 changes: 18 additions & 5 deletions src/modules/quoteSummary.spec.ts
Original file line number Diff line number Diff line change
Expand Up @@ -10,8 +10,21 @@ const yf = {
quoteSummary
};

function itValidates(name: QuoteSummaryModules|"all", skip:Array<string>=[]) {
const symbols = ['AAPL','OCDO.L'].filter(s => !skip.includes(s));
const testSymbols = [
'AAPL', // NMS (Nasdaq)
'OCDO.L', // LSE
'BABA', // NYSE
];

interface itValidatesOpts {
skip?: Array<string>
}

function itValidates(name: QuoteSummaryModules|"all", opts:itValidatesOpts={}) {
let symbols = testSymbols;
if (opts.skip) // @ts-ignore
symbols = symbols.filter(s => !opts.skip.includes(s));

const modules = name === 'all' ? 'all' : [name];
symbols.forEach(symbol => {
it(`validates ${symbol}`, async () => {
Expand Down Expand Up @@ -138,7 +151,7 @@ describe('quoteSummary', () => {

describe('insiderTransactions', () => {

itValidates("insiderTransactions");
itValidates("insiderTransactions", { skip: ['BABA'] });

});

Expand Down Expand Up @@ -186,7 +199,7 @@ describe('quoteSummary', () => {

describe('secFilings', () => {

itValidates("secFilings", ['OCDO.L']);
itValidates("secFilings", { skip: ['OCDO.L','BABA'] });

});

Expand All @@ -204,7 +217,7 @@ describe('quoteSummary', () => {

describe('upgradeDowngradeHistory', () => {

itValidates("upgradeDowngradeHistory", ['OCDO.L']);
itValidates("upgradeDowngradeHistory", { skip: ['OCDO.L'] });

});

Expand Down
4 changes: 2 additions & 2 deletions src/modules/quoteSummary.ts
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@ const QUERY_URL = 'https://query2.finance.yahoo.com/v10/finance/quoteSummary';
const QUERY_OPTIONS_SCHEMA_KEY = '#/definitions/QuoteSummaryOptions'
const QUERY_RESULT_SCHEMA_KEY = "#/definitions/QuoteSummaryResult";

const quoteSummary_modules = [
export const quoteSummary_modules = [
'assetProfile',
'balanceSheetHistory',
'balanceSheetHistoryQuarterly',
Expand Down Expand Up @@ -45,7 +45,7 @@ const quoteSummary_modules = [
'upgradeDowngradeHistory',
];

type QuoteSummaryModules =
export type QuoteSummaryModules =
"assetProfile" |
"balanceSheetHistory" |
"balanceSheetHistoryQuarterly" |
Expand Down

0 comments on commit 3fa958c

Please sign in to comment.