corexxx 1.0.15 → 1.0.16
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/yahoofin.d.ts +19 -0
- package/dist/yahoofin.js +59 -0
- package/dist/yahoofin.js.map +1 -0
- package/package.json +1 -1
- package/src/yahoofin.ts +59 -0
|
@@ -0,0 +1,19 @@
|
|
|
1
|
+
export declare namespace yahooFin {
|
|
2
|
+
type TStockInfo = {
|
|
3
|
+
ltp: number;
|
|
4
|
+
open: number;
|
|
5
|
+
symbol: string;
|
|
6
|
+
name: string;
|
|
7
|
+
exchange: string;
|
|
8
|
+
volume: number;
|
|
9
|
+
high: number;
|
|
10
|
+
low: number;
|
|
11
|
+
week52High: number;
|
|
12
|
+
week52Low: number;
|
|
13
|
+
avgVolume: number;
|
|
14
|
+
change: number;
|
|
15
|
+
pChange: number;
|
|
16
|
+
yAnalystRating?: string;
|
|
17
|
+
};
|
|
18
|
+
function getBulkStockQuote(symbols: string[], exchange: "NSE" | "BSE" | "LSE" | "NASDAQ"): Promise<TStockInfo[]>;
|
|
19
|
+
}
|
package/dist/yahoofin.js
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
"use strict";
|
|
2
|
+
var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) {
|
|
3
|
+
function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); }
|
|
4
|
+
return new (P || (P = Promise))(function (resolve, reject) {
|
|
5
|
+
function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } }
|
|
6
|
+
function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } }
|
|
7
|
+
function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); }
|
|
8
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
9
|
+
});
|
|
10
|
+
};
|
|
11
|
+
Object.defineProperty(exports, "__esModule", { value: true });
|
|
12
|
+
exports.yahooFin = void 0;
|
|
13
|
+
const dlog_1 = require("./dlog");
|
|
14
|
+
const axios = require("axios").default;
|
|
15
|
+
var yahooFin;
|
|
16
|
+
(function (yahooFin) {
|
|
17
|
+
const extMap = { NSE: ".NS", BSE: ".BS", NASDAQ: "", LSE: ".L" };
|
|
18
|
+
function getBulkStockQuote(symbols, exchange) {
|
|
19
|
+
var _a;
|
|
20
|
+
return __awaiter(this, void 0, void 0, function* () {
|
|
21
|
+
symbols = symbols.map((x) => x + extMap[exchange]);
|
|
22
|
+
console.log(symbols);
|
|
23
|
+
let result = [];
|
|
24
|
+
try {
|
|
25
|
+
let resp = yield axios.get(`https://query1.finance.yahoo.com/v7/finance/quote?formatted=true&symbols=${symbols.join(",")}`, {
|
|
26
|
+
headers: {
|
|
27
|
+
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.193 Safari/537.36",
|
|
28
|
+
},
|
|
29
|
+
});
|
|
30
|
+
let data = resp.data;
|
|
31
|
+
for (let d of data.quoteResponse.result) {
|
|
32
|
+
result.push({
|
|
33
|
+
symbol: d.symbol.replace(extMap[exchange], ""),
|
|
34
|
+
name: d.shortName,
|
|
35
|
+
exchange: exchange,
|
|
36
|
+
ltp: d.regularMarketPrice.raw,
|
|
37
|
+
open: d.regularMarketOpen.raw,
|
|
38
|
+
low: d.regularMarketDayLow.raw,
|
|
39
|
+
high: d.regularMarketDayHigh.raw,
|
|
40
|
+
volume: d.regularMarketVolume.raw,
|
|
41
|
+
avgVolume: (_a = d.averageDailyVolume3Month) === null || _a === void 0 ? void 0 : _a.raw,
|
|
42
|
+
week52High: d.fiftyTwoWeekHigh.raw,
|
|
43
|
+
week52Low: d.fiftyTwoWeekLow.raw,
|
|
44
|
+
change: d.regularMarketChange.raw,
|
|
45
|
+
pChange: d.regularMarketChangePercent.raw,
|
|
46
|
+
yAnalystRating: d.averageAnalystRating,
|
|
47
|
+
});
|
|
48
|
+
}
|
|
49
|
+
return result;
|
|
50
|
+
}
|
|
51
|
+
catch (err) {
|
|
52
|
+
dlog_1.dlog.ex(err);
|
|
53
|
+
}
|
|
54
|
+
return result;
|
|
55
|
+
});
|
|
56
|
+
}
|
|
57
|
+
yahooFin.getBulkStockQuote = getBulkStockQuote;
|
|
58
|
+
})(yahooFin = exports.yahooFin || (exports.yahooFin = {}));
|
|
59
|
+
//# sourceMappingURL=yahoofin.js.map
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
{"version":3,"file":"yahoofin.js","sourceRoot":"","sources":["../src/yahoofin.ts"],"names":[],"mappings":";;;;;;;;;;;;AAAA,iCAA8B;AAE9B,MAAM,KAAK,GAAG,OAAO,CAAC,OAAO,CAAC,CAAC,OAAO,CAAC;AAEvC,IAAiB,QAAQ,CAsDxB;AAtDD,WAAiB,QAAQ;IAiBvB,MAAM,MAAM,GAAG,EAAE,GAAG,EAAE,KAAK,EAAE,GAAG,EAAE,KAAK,EAAE,MAAM,EAAE,EAAE,EAAE,GAAG,EAAE,IAAI,EAAE,CAAC;IAEjE,SAAsB,iBAAiB,CAAC,OAAiB,EAAE,QAA0C;;;YACnG,OAAO,GAAG,OAAO,CAAC,GAAG,CAAC,CAAC,CAAC,EAAE,EAAE,CAAC,CAAC,GAAG,MAAM,CAAC,QAAQ,CAAC,CAAC,CAAC;YACnD,OAAO,CAAC,GAAG,CAAC,OAAO,CAAC,CAAC;YACrB,IAAI,MAAM,GAAiB,EAAE,CAAC;YAC9B,IAAI;gBACF,IAAI,IAAI,GAAG,MAAM,KAAK,CAAC,GAAG,CAAC,4EAA4E,OAAO,CAAC,IAAI,CAAC,GAAG,CAAC,EAAE,EAAE;oBAC1H,OAAO,EAAE;wBACP,YAAY,EAAE,qHAAqH;qBACpI;iBACF,CAAC,CAAC;gBACH,IAAI,IAAI,GAAG,IAAI,CAAC,IAAI,CAAC;gBACrB,KAAK,IAAI,CAAC,IAAI,IAAI,CAAC,aAAa,CAAC,MAAM,EAAE;oBACvC,MAAM,CAAC,IAAI,CAAC;wBACV,MAAM,EAAE,CAAC,CAAC,MAAM,CAAC,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAC,EAAE,EAAE,CAAC;wBAC9C,IAAI,EAAE,CAAC,CAAC,SAAS;wBACjB,QAAQ,EAAE,QAAQ;wBAClB,GAAG,EAAE,CAAC,CAAC,kBAAkB,CAAC,GAAG;wBAC7B,IAAI,EAAE,CAAC,CAAC,iBAAiB,CAAC,GAAG;wBAC7B,GAAG,EAAE,CAAC,CAAC,mBAAmB,CAAC,GAAG;wBAC9B,IAAI,EAAE,CAAC,CAAC,oBAAoB,CAAC,GAAG;wBAChC,MAAM,EAAE,CAAC,CAAC,mBAAmB,CAAC,GAAG;wBACjC,SAAS,EAAE,MAAA,CAAC,CAAC,wBAAwB,0CAAE,GAAG;wBAC1C,UAAU,EAAE,CAAC,CAAC,gBAAgB,CAAC,GAAG;wBAClC,SAAS,EAAE,CAAC,CAAC,eAAe,CAAC,GAAG;wBAChC,MAAM,EAAE,CAAC,CAAC,mBAAmB,CAAC,GAAG;wBACjC,OAAO,EAAE,CAAC,CAAC,0BAA0B,CAAC,GAAG;wBACzC,cAAc,EAAE,CAAC,CAAC,oBAAoB;qBACvC,CAAC,CAAC;iBACJ;gBACD,OAAO,MAAM,CAAC;aACf;YAAC,OAAO,GAAG,EAAE;gBACZ,WAAI,CAAC,EAAE,CAAC,GAAY,CAAC,CAAC;aACvB;YACD,OAAO,MAAM,CAAC;;KACf;IAlCqB,0BAAiB,oBAkCtC,CAAA;AACH,CAAC,EAtDgB,QAAQ,GAAR,gBAAQ,KAAR,gBAAQ,QAsDxB"}
|
package/package.json
CHANGED
package/src/yahoofin.ts
ADDED
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
import { dlog } from "./dlog";
|
|
2
|
+
|
|
3
|
+
const axios = require("axios").default;
|
|
4
|
+
|
|
5
|
+
export namespace yahooFin {
|
|
6
|
+
export type TStockInfo = {
|
|
7
|
+
ltp: number;
|
|
8
|
+
open: number;
|
|
9
|
+
symbol: string;
|
|
10
|
+
name: string;
|
|
11
|
+
exchange: string;
|
|
12
|
+
volume: number;
|
|
13
|
+
high: number;
|
|
14
|
+
low: number;
|
|
15
|
+
week52High: number;
|
|
16
|
+
week52Low: number;
|
|
17
|
+
avgVolume: number;
|
|
18
|
+
change: number;
|
|
19
|
+
pChange: number;
|
|
20
|
+
yAnalystRating?: string;
|
|
21
|
+
};
|
|
22
|
+
const extMap = { NSE: ".NS", BSE: ".BS", NASDAQ: "", LSE: ".L" };
|
|
23
|
+
|
|
24
|
+
export async function getBulkStockQuote(symbols: string[], exchange: "NSE" | "BSE" | "LSE" | "NASDAQ"): Promise<TStockInfo[]> {
|
|
25
|
+
symbols = symbols.map((x) => x + extMap[exchange]);
|
|
26
|
+
console.log(symbols);
|
|
27
|
+
let result: TStockInfo[] = [];
|
|
28
|
+
try {
|
|
29
|
+
let resp = await axios.get(`https://query1.finance.yahoo.com/v7/finance/quote?formatted=true&symbols=${symbols.join(",")}`, {
|
|
30
|
+
headers: {
|
|
31
|
+
"user-agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/86.0.4240.193 Safari/537.36",
|
|
32
|
+
},
|
|
33
|
+
});
|
|
34
|
+
let data = resp.data;
|
|
35
|
+
for (let d of data.quoteResponse.result) {
|
|
36
|
+
result.push({
|
|
37
|
+
symbol: d.symbol.replace(extMap[exchange], ""),
|
|
38
|
+
name: d.shortName,
|
|
39
|
+
exchange: exchange,
|
|
40
|
+
ltp: d.regularMarketPrice.raw,
|
|
41
|
+
open: d.regularMarketOpen.raw,
|
|
42
|
+
low: d.regularMarketDayLow.raw,
|
|
43
|
+
high: d.regularMarketDayHigh.raw,
|
|
44
|
+
volume: d.regularMarketVolume.raw,
|
|
45
|
+
avgVolume: d.averageDailyVolume3Month?.raw,
|
|
46
|
+
week52High: d.fiftyTwoWeekHigh.raw,
|
|
47
|
+
week52Low: d.fiftyTwoWeekLow.raw,
|
|
48
|
+
change: d.regularMarketChange.raw,
|
|
49
|
+
pChange: d.regularMarketChangePercent.raw,
|
|
50
|
+
yAnalystRating: d.averageAnalystRating,
|
|
51
|
+
});
|
|
52
|
+
}
|
|
53
|
+
return result;
|
|
54
|
+
} catch (err) {
|
|
55
|
+
dlog.ex(err as Error);
|
|
56
|
+
}
|
|
57
|
+
return result;
|
|
58
|
+
}
|
|
59
|
+
}
|