yahoo-nse-api
Advanced tools
| export interface YahooChartResponse { | ||
| chart: Chart; | ||
| } | ||
| export interface Chart { | ||
| result: Result[]; | ||
| error: any; | ||
| } | ||
| export interface Result { | ||
| meta: Meta; | ||
| timestamp: number[]; | ||
| indicators: Indicators; | ||
| } | ||
| export interface Meta { | ||
| currency: string; | ||
| symbol: string; | ||
| exchangeName: string; | ||
| instrumentType: string; | ||
| firstTradeDate: number; | ||
| regularMarketTime: number; | ||
| gmtoffset: number; | ||
| timezone: string; | ||
| exchangeTimezoneName: string; | ||
| regularMarketPrice: number; | ||
| chartPreviousClose: number; | ||
| priceHint: number; | ||
| currentTradingPeriod: CurrentTradingPeriod; | ||
| dataGranularity: string; | ||
| range: string; | ||
| validRanges: string[]; | ||
| } | ||
| export interface CurrentTradingPeriod { | ||
| pre: Pre; | ||
| regular: Regular; | ||
| post: Post; | ||
| } | ||
| export interface Pre { | ||
| timezone: string; | ||
| start: number; | ||
| end: number; | ||
| gmtoffset: number; | ||
| } | ||
| export interface Regular { | ||
| timezone: string; | ||
| start: number; | ||
| end: number; | ||
| gmtoffset: number; | ||
| } | ||
| export interface Post { | ||
| timezone: string; | ||
| start: number; | ||
| end: number; | ||
| gmtoffset: number; | ||
| } | ||
| export interface Indicators { | ||
| quote: Quote[]; | ||
| adjclose: Adjclose[]; | ||
| } | ||
| export interface Quote { | ||
| low: number[]; | ||
| close: number[]; | ||
| high: number[]; | ||
| open: number[]; | ||
| volume: number[]; | ||
| } | ||
| export interface Adjclose { | ||
| adjclose: number[]; | ||
| } |
| "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); |
+2
-0
@@ -0,3 +1,5 @@ | ||
| import { YahooChartResponse } from "./yahoo.charts.types"; | ||
| import { YahooQuoteResponse, YahooQuoteResult } from "./yahoo.quotes.types"; | ||
| export declare const getMultipleLTPs: (symbols: string[]) => Promise<YahooQuoteResponse>; | ||
| export declare const getLTP: (symbol: string) => Promise<YahooQuoteResult>; | ||
| export declare const getHistoricalData: (symbol: string, interval: string, range: string) => Promise<YahooChartResponse>; |
+31
-1
@@ -39,3 +39,3 @@ "use strict"; | ||
| Object.defineProperty(exports, "__esModule", { value: true }); | ||
| exports.getLTP = exports.getMultipleLTPs = void 0; | ||
| exports.getHistoricalData = exports.getLTP = exports.getMultipleLTPs = void 0; | ||
| var fetch = function (url, init) { | ||
@@ -89,1 +89,31 @@ return Promise.resolve().then(function () { return require("node-fetch"); }).then(function (_a) { | ||
| exports.getLTP = getLTP; | ||
| var getHistoricalData = function (symbol, interval, range) { return __awaiter(void 0, void 0, void 0, function () { | ||
| var baseV8YahooFinanceURL, symbolWithNSE, url, response, data; | ||
| return __generator(this, function (_a) { | ||
| switch (_a.label) { | ||
| case 0: | ||
| validateFrame(range, "range"); | ||
| validateFrame(interval, "interval"); | ||
| baseV8YahooFinanceURL = "https://query1.finance.yahoo.com/v8/finance/chart/"; | ||
| symbolWithNSE = symbol + ".NS"; | ||
| url = "".concat(baseV8YahooFinanceURL).concat(symbolWithNSE, "?&interval=").concat(interval, "&range=").concat(range); | ||
| return [4 /*yield*/, fetch(url)]; | ||
| case 1: | ||
| response = _a.sent(); | ||
| return [4 /*yield*/, response.json()]; | ||
| case 2: | ||
| data = _a.sent(); | ||
| return [2 /*return*/, data]; | ||
| } | ||
| }); | ||
| }); }; | ||
| exports.getHistoricalData = getHistoricalData; | ||
| function validateFrame(frame, frameType) { | ||
| // should begin with a number | ||
| // should end with either d,mo,y, or max | ||
| // should not contain any other characters | ||
| var regex = /^[0-9]+[dmy]|max$/; | ||
| if (!regex.test(frame)) { | ||
| throw new Error("Invalid" + frameType); | ||
| } | ||
| } |
+1
-1
| { | ||
| "name": "yahoo-nse-api", | ||
| "version": "1.0.4", | ||
| "version": "1.0.5", | ||
| "description": "A Yahoo API Wrapper for getting quotes from the national stock exchance (NSE) ", | ||
@@ -5,0 +5,0 @@ "main": "lib/index.js", |
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
Network access
Supply chain riskThis module accesses the network.
Found 1 instance in 1 package
URL strings
Supply chain riskPackage contains fragments of external URLs or IP addresses, which the package may be accessing at runtime.
Found 1 instance in 1 package
11896
32.72%8
33.33%273
58.72%7
16.67%