Skip to content

Commit

Permalink
Add the ability to get historical data using a specified date range
Browse files Browse the repository at this point in the history
  • Loading branch information
liardoecp committed Oct 22, 2024
1 parent 1e1f371 commit 2dbac78
Show file tree
Hide file tree
Showing 6 changed files with 276 additions and 4,161 deletions.
14 changes: 14 additions & 0 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -13,4 +13,18 @@ declare module "investing-com-api" {
price_low: number,
price_close: number,
}[]>;

export function getHistoricalData(
input: string,
resolution: '5' | '60' | 'D' | 'W' | 'M',
from: Date,
to: Date
): Promise<{
date: number,
value: number,
price_open: number,
price_high: number,
price_low: number,
price_close: number,
}[]>;
}
6 changes: 5 additions & 1 deletion index.js
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
const puppeteer = require('puppeteer');
const { mapping } = require('./mapping');
const { getJsonContent, mapResponse } = require('./functions');
const getHistoricalData = require('./src/getHistoricalData')

const validPeriod = ['P1D', 'P1W', 'P1M', 'P3M', 'P6M', 'P1Y', 'P5Y', 'MAX'];
const validInterval = ['PT1M', 'PT5M', 'PT15M', 'PT30M', 'PT1H', 'PT5H', 'P1D', 'P1W', 'P1M'];
Expand Down Expand Up @@ -83,4 +84,7 @@ async function investing(input, period = 'P1M', interval = 'P1D', pointscount =

// investing('1').then(console.log);

exports.investing = investing;
module.exports = {
investing,
getHistoricalData
}
Loading

0 comments on commit 2dbac78

Please sign in to comment.