underlying-exchange-tokens-india 1.0.0

Sign up to get free protection for your applications and to get access to all the features.
package/README.md ADDED
@@ -0,0 +1,47 @@
1
+ # Underlying Exchange Tokens India
2
+
3
+ A comprehensive mapping of exchange tokens for underlying instruments across different Indian brokers.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install underlying-exchange-tokens-india
9
+ ```
10
+
11
+ ## Usage
12
+
13
+ ```typescript
14
+ import {
15
+ getExchangeToken,
16
+ isSymbolSupported,
17
+ getAvailableSymbols,
18
+ } from "underlying-exchange-tokens-india";
19
+ // Get token for NIFTY on Zerodha
20
+ const niftyToken = getExchangeToken("NIFTY", "Zerodha");
21
+ console.log(niftyToken); // '1001'
22
+ // Check if symbol is supported
23
+ console.log(isSymbolSupported("NIFTY")); // true
24
+ // Get all available symbols
25
+ console.log(getAvailableSymbols()); // ['NIFTY', 'BANKNIFTY', 'FINNIFTY', ...]
26
+ ```
27
+
28
+ ## Supported Brokers
29
+
30
+ - Zerodha
31
+ - Flattrade
32
+ - Shoonya
33
+
34
+ ## Supported Symbols
35
+
36
+ - NIFTY
37
+ - BANKNIFTY
38
+ - FINNIFTY
39
+ - (and more...)
40
+
41
+ ## Contributing
42
+
43
+ Contributions are welcome! Please feel free to submit a Pull Request.
44
+
45
+ ## License
46
+
47
+ MIT
@@ -0,0 +1,2 @@
1
+ import type { UnderlyingTokenMap } from "./types";
2
+ export declare const UNDERLYING_TOKEN_MAP: UnderlyingTokenMap;
@@ -0,0 +1,21 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
3
+ exports.UNDERLYING_TOKEN_MAP = void 0;
4
+ exports.UNDERLYING_TOKEN_MAP = {
5
+ NIFTY: {
6
+ Flattrade: "26000",
7
+ Shoonya: "26000",
8
+ Zerodha: "1001",
9
+ },
10
+ BANKNIFTY: {
11
+ Flattrade: "26009",
12
+ Shoonya: "26009",
13
+ Zerodha: "1016",
14
+ },
15
+ FINNIFTY: {
16
+ Flattrade: "26037",
17
+ Shoonya: "26037",
18
+ Zerodha: "1020",
19
+ },
20
+ // Add more symbols as needed
21
+ };
@@ -0,0 +1,20 @@
1
+ export * from "./types";
2
+ export * from "./constants";
3
+ /**
4
+ * Get the exchange token for a given symbol and broker
5
+ * @param symbol The underlying symbol (e.g., 'NIFTY')
6
+ * @param broker The broker type (e.g., 'Zerodha')
7
+ * @returns The exchange token or null if not found
8
+ */
9
+ export declare function getExchangeToken(symbol: string, broker: string): string | null;
10
+ /**
11
+ * Get all available symbols
12
+ * @returns Array of available symbols
13
+ */
14
+ export declare function getAvailableSymbols(): string[];
15
+ /**
16
+ * Check if a symbol is supported
17
+ * @param symbol The symbol to check
18
+ * @returns boolean indicating if the symbol is supported
19
+ */
20
+ export declare function isSymbolSupported(symbol: string): boolean;
package/dist/index.js ADDED
@@ -0,0 +1,49 @@
1
+ "use strict";
2
+ var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) {
3
+ if (k2 === undefined) k2 = k;
4
+ var desc = Object.getOwnPropertyDescriptor(m, k);
5
+ if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) {
6
+ desc = { enumerable: true, get: function() { return m[k]; } };
7
+ }
8
+ Object.defineProperty(o, k2, desc);
9
+ }) : (function(o, m, k, k2) {
10
+ if (k2 === undefined) k2 = k;
11
+ o[k2] = m[k];
12
+ }));
13
+ var __exportStar = (this && this.__exportStar) || function(m, exports) {
14
+ for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p);
15
+ };
16
+ Object.defineProperty(exports, "__esModule", { value: true });
17
+ exports.getExchangeToken = getExchangeToken;
18
+ exports.getAvailableSymbols = getAvailableSymbols;
19
+ exports.isSymbolSupported = isSymbolSupported;
20
+ __exportStar(require("./types"), exports);
21
+ __exportStar(require("./constants"), exports);
22
+ const constants_1 = require("./constants");
23
+ /**
24
+ * Get the exchange token for a given symbol and broker
25
+ * @param symbol The underlying symbol (e.g., 'NIFTY')
26
+ * @param broker The broker type (e.g., 'Zerodha')
27
+ * @returns The exchange token or null if not found
28
+ */
29
+ function getExchangeToken(symbol, broker) {
30
+ if (!(symbol in constants_1.UNDERLYING_TOKEN_MAP)) {
31
+ return null;
32
+ }
33
+ return constants_1.UNDERLYING_TOKEN_MAP[symbol][broker] || null;
34
+ }
35
+ /**
36
+ * Get all available symbols
37
+ * @returns Array of available symbols
38
+ */
39
+ function getAvailableSymbols() {
40
+ return Object.keys(constants_1.UNDERLYING_TOKEN_MAP);
41
+ }
42
+ /**
43
+ * Check if a symbol is supported
44
+ * @param symbol The symbol to check
45
+ * @returns boolean indicating if the symbol is supported
46
+ */
47
+ function isSymbolSupported(symbol) {
48
+ return symbol in constants_1.UNDERLYING_TOKEN_MAP;
49
+ }
@@ -0,0 +1,7 @@
1
+ export type BrokerType = "Flattrade" | "Shoonya" | "Zerodha";
2
+ export type TokenMapping = {
3
+ [K in BrokerType]: string;
4
+ };
5
+ export interface UnderlyingTokenMap {
6
+ [symbol: string]: TokenMapping;
7
+ }
package/dist/types.js ADDED
@@ -0,0 +1,2 @@
1
+ "use strict";
2
+ Object.defineProperty(exports, "__esModule", { value: true });
package/package.json ADDED
@@ -0,0 +1,41 @@
1
+ {
2
+ "name": "underlying-exchange-tokens-india",
3
+ "version": "1.0.0",
4
+ "description": "Exchange tokens mapping for underlying instruments across different Indian brokers",
5
+ "main": "dist/index.js",
6
+ "types": "dist/index.d.ts",
7
+ "files": [
8
+ "dist"
9
+ ],
10
+ "scripts": {
11
+ "build": "tsc",
12
+ "prepare": "npm run build",
13
+ "test": "jest",
14
+ "test:watch": "jest --watch",
15
+ "test:coverage": "jest --coverage",
16
+ "prepublishOnly": "npm test",
17
+ "clean": "rm -rf dist"
18
+ },
19
+ "keywords": [
20
+ "india",
21
+ "stock-market",
22
+ "exchange-tokens",
23
+ "zerodha",
24
+ "flattrade",
25
+ "shoonya",
26
+ "nse",
27
+ "trading"
28
+ ],
29
+ "author": "Narendra Krishna Ram",
30
+ "license": "MIT",
31
+ "devDependencies": {
32
+ "@types/jest": "^29.5.14",
33
+ "jest": "^29.7.0",
34
+ "ts-jest": "^29.2.5",
35
+ "typescript": "^5.7.2"
36
+ },
37
+ "repository": {
38
+ "type": "git",
39
+ "url": "https://github.com/narenkram/underlying-exchange-tokens-india.git"
40
+ }
41
+ }