@sebspark/tradeinsight 0.1.0 → 0.2.0
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/README.md +1 -1
- package/dist/index.d.mts +19 -1
- package/dist/index.d.ts +19 -1
- package/dist/index.js +77 -0
- package/dist/index.mjs +49 -0
- package/package.json +1 -1
package/README.md
CHANGED
package/dist/index.d.mts
CHANGED
|
@@ -1,2 +1,20 @@
|
|
|
1
|
+
declare const createStockId: ({ isin, mic, currency, }: {
|
|
2
|
+
isin: string;
|
|
3
|
+
currency: string;
|
|
4
|
+
mic: string;
|
|
5
|
+
}) => string;
|
|
6
|
+
declare const createForexId: ({ fromCurrency, toCurrency, }: {
|
|
7
|
+
toCurrency: string;
|
|
8
|
+
fromCurrency: string;
|
|
9
|
+
}) => string;
|
|
1
10
|
|
|
2
|
-
|
|
11
|
+
declare const parseId: (id: string) => {
|
|
12
|
+
type: "STOCK" | "FOREX";
|
|
13
|
+
isin?: string;
|
|
14
|
+
mic?: string;
|
|
15
|
+
currency?: string;
|
|
16
|
+
fromCurrency?: string;
|
|
17
|
+
toCurrency?: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { createForexId, createStockId, parseId };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,2 +1,20 @@
|
|
|
1
|
+
declare const createStockId: ({ isin, mic, currency, }: {
|
|
2
|
+
isin: string;
|
|
3
|
+
currency: string;
|
|
4
|
+
mic: string;
|
|
5
|
+
}) => string;
|
|
6
|
+
declare const createForexId: ({ fromCurrency, toCurrency, }: {
|
|
7
|
+
toCurrency: string;
|
|
8
|
+
fromCurrency: string;
|
|
9
|
+
}) => string;
|
|
1
10
|
|
|
2
|
-
|
|
11
|
+
declare const parseId: (id: string) => {
|
|
12
|
+
type: "STOCK" | "FOREX";
|
|
13
|
+
isin?: string;
|
|
14
|
+
mic?: string;
|
|
15
|
+
currency?: string;
|
|
16
|
+
fromCurrency?: string;
|
|
17
|
+
toCurrency?: string;
|
|
18
|
+
};
|
|
19
|
+
|
|
20
|
+
export { createForexId, createStockId, parseId };
|
package/dist/index.js
CHANGED
|
@@ -1 +1,78 @@
|
|
|
1
1
|
"use strict";
|
|
2
|
+
var __defProp = Object.defineProperty;
|
|
3
|
+
var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
|
|
4
|
+
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
5
|
+
var __hasOwnProp = Object.prototype.hasOwnProperty;
|
|
6
|
+
var __export = (target, all) => {
|
|
7
|
+
for (var name in all)
|
|
8
|
+
__defProp(target, name, { get: all[name], enumerable: true });
|
|
9
|
+
};
|
|
10
|
+
var __copyProps = (to, from, except, desc) => {
|
|
11
|
+
if (from && typeof from === "object" || typeof from === "function") {
|
|
12
|
+
for (let key of __getOwnPropNames(from))
|
|
13
|
+
if (!__hasOwnProp.call(to, key) && key !== except)
|
|
14
|
+
__defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
|
|
15
|
+
}
|
|
16
|
+
return to;
|
|
17
|
+
};
|
|
18
|
+
var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
|
|
19
|
+
|
|
20
|
+
// src/index.ts
|
|
21
|
+
var index_exports = {};
|
|
22
|
+
__export(index_exports, {
|
|
23
|
+
createForexId: () => createForexId,
|
|
24
|
+
createStockId: () => createStockId,
|
|
25
|
+
parseId: () => parseId
|
|
26
|
+
});
|
|
27
|
+
module.exports = __toCommonJS(index_exports);
|
|
28
|
+
|
|
29
|
+
// src/createId.ts
|
|
30
|
+
var createStockId = ({
|
|
31
|
+
isin,
|
|
32
|
+
mic,
|
|
33
|
+
currency
|
|
34
|
+
}) => `STOCK-${isin};${mic};${currency}`.toUpperCase();
|
|
35
|
+
var createForexId = ({
|
|
36
|
+
fromCurrency,
|
|
37
|
+
toCurrency
|
|
38
|
+
}) => `FOREX-${toCurrency};${fromCurrency}`.toUpperCase();
|
|
39
|
+
|
|
40
|
+
// src/parseId.ts
|
|
41
|
+
var parseId = (id) => {
|
|
42
|
+
const [type, ...rest] = id.split("-");
|
|
43
|
+
const [first, second, third] = rest.join("-").split(";");
|
|
44
|
+
if (type === "STOCK") {
|
|
45
|
+
if (!second) {
|
|
46
|
+
throw new Error("Missing MIC");
|
|
47
|
+
}
|
|
48
|
+
if (!third) {
|
|
49
|
+
throw new Error("Missing currency");
|
|
50
|
+
}
|
|
51
|
+
return {
|
|
52
|
+
type,
|
|
53
|
+
isin: first,
|
|
54
|
+
mic: second,
|
|
55
|
+
currency: third
|
|
56
|
+
};
|
|
57
|
+
}
|
|
58
|
+
if (type === "FOREX") {
|
|
59
|
+
if (!first) {
|
|
60
|
+
throw new Error("Missing fromCurrency");
|
|
61
|
+
}
|
|
62
|
+
if (!second) {
|
|
63
|
+
throw new Error("Missing toCurrency");
|
|
64
|
+
}
|
|
65
|
+
return {
|
|
66
|
+
type,
|
|
67
|
+
fromCurrency: first,
|
|
68
|
+
toCurrency: second
|
|
69
|
+
};
|
|
70
|
+
}
|
|
71
|
+
throw new Error("Invalid type");
|
|
72
|
+
};
|
|
73
|
+
// Annotate the CommonJS export names for ESM import in node:
|
|
74
|
+
0 && (module.exports = {
|
|
75
|
+
createForexId,
|
|
76
|
+
createStockId,
|
|
77
|
+
parseId
|
|
78
|
+
});
|
package/dist/index.mjs
CHANGED
|
@@ -0,0 +1,49 @@
|
|
|
1
|
+
// src/createId.ts
|
|
2
|
+
var createStockId = ({
|
|
3
|
+
isin,
|
|
4
|
+
mic,
|
|
5
|
+
currency
|
|
6
|
+
}) => `STOCK-${isin};${mic};${currency}`.toUpperCase();
|
|
7
|
+
var createForexId = ({
|
|
8
|
+
fromCurrency,
|
|
9
|
+
toCurrency
|
|
10
|
+
}) => `FOREX-${toCurrency};${fromCurrency}`.toUpperCase();
|
|
11
|
+
|
|
12
|
+
// src/parseId.ts
|
|
13
|
+
var parseId = (id) => {
|
|
14
|
+
const [type, ...rest] = id.split("-");
|
|
15
|
+
const [first, second, third] = rest.join("-").split(";");
|
|
16
|
+
if (type === "STOCK") {
|
|
17
|
+
if (!second) {
|
|
18
|
+
throw new Error("Missing MIC");
|
|
19
|
+
}
|
|
20
|
+
if (!third) {
|
|
21
|
+
throw new Error("Missing currency");
|
|
22
|
+
}
|
|
23
|
+
return {
|
|
24
|
+
type,
|
|
25
|
+
isin: first,
|
|
26
|
+
mic: second,
|
|
27
|
+
currency: third
|
|
28
|
+
};
|
|
29
|
+
}
|
|
30
|
+
if (type === "FOREX") {
|
|
31
|
+
if (!first) {
|
|
32
|
+
throw new Error("Missing fromCurrency");
|
|
33
|
+
}
|
|
34
|
+
if (!second) {
|
|
35
|
+
throw new Error("Missing toCurrency");
|
|
36
|
+
}
|
|
37
|
+
return {
|
|
38
|
+
type,
|
|
39
|
+
fromCurrency: first,
|
|
40
|
+
toCurrency: second
|
|
41
|
+
};
|
|
42
|
+
}
|
|
43
|
+
throw new Error("Invalid type");
|
|
44
|
+
};
|
|
45
|
+
export {
|
|
46
|
+
createForexId,
|
|
47
|
+
createStockId,
|
|
48
|
+
parseId
|
|
49
|
+
};
|