@sebspark/tradeinsight 1.0.2 → 3.0.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/dist/index.d.ts +19 -8
- package/dist/index.js +16 -36
- package/package.json +3 -2
- package/dist/index.d.mts +0 -58
- package/dist/index.mjs +0 -140
package/dist/index.d.ts
CHANGED
|
@@ -40,19 +40,30 @@ declare const createForexId: ({ quoteCurrency, baseCurrency, }: {
|
|
|
40
40
|
baseCurrency: string;
|
|
41
41
|
quoteCurrency: string;
|
|
42
42
|
}) => string;
|
|
43
|
+
declare const createIndexId: ({ ticker }: {
|
|
44
|
+
ticker: string;
|
|
45
|
+
}) => string;
|
|
43
46
|
|
|
44
|
-
|
|
45
|
-
type:
|
|
46
|
-
isin
|
|
47
|
-
mic
|
|
48
|
-
currency
|
|
49
|
-
|
|
50
|
-
|
|
47
|
+
type StockId = {
|
|
48
|
+
type: 'STOCK';
|
|
49
|
+
isin: string;
|
|
50
|
+
mic: string;
|
|
51
|
+
currency: string;
|
|
52
|
+
};
|
|
53
|
+
type ForexId = {
|
|
54
|
+
type: 'FOREX';
|
|
55
|
+
baseCurrency: string;
|
|
56
|
+
quoteCurrency: string;
|
|
57
|
+
};
|
|
58
|
+
type IndexId = {
|
|
59
|
+
type: 'INDEX';
|
|
60
|
+
ticker: string;
|
|
51
61
|
};
|
|
62
|
+
declare const parseId: (id: string) => StockId | ForexId | IndexId;
|
|
52
63
|
|
|
53
64
|
declare const TickersTopic = "tradeinsight.tickers";
|
|
54
65
|
type TickersPubSubChannels = {
|
|
55
66
|
[TickersTopic]: TickerMessage;
|
|
56
67
|
};
|
|
57
68
|
|
|
58
|
-
export { CloudSchema, type InstrumentPrice, type Ticker, type TickerMessage, type TickersPubSubChannels, TickersTopic, createForexId, createStockId, parseId };
|
|
69
|
+
export { CloudSchema, type InstrumentPrice, type Ticker, type TickerMessage, type TickersPubSubChannels, TickersTopic, createForexId, createIndexId, createStockId, parseId };
|
package/dist/index.js
CHANGED
|
@@ -1,33 +1,3 @@
|
|
|
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
|
-
CloudSchema: () => CloudSchema,
|
|
24
|
-
TickersTopic: () => TickersTopic,
|
|
25
|
-
createForexId: () => createForexId,
|
|
26
|
-
createStockId: () => createStockId,
|
|
27
|
-
parseId: () => parseId
|
|
28
|
-
});
|
|
29
|
-
module.exports = __toCommonJS(index_exports);
|
|
30
|
-
|
|
31
1
|
// src/generated/tickerMessage.ts
|
|
32
2
|
var CloudSchema = {
|
|
33
3
|
schemaId: "ticker-v1",
|
|
@@ -119,16 +89,17 @@ var createStockId = ({
|
|
|
119
89
|
isin,
|
|
120
90
|
mic,
|
|
121
91
|
currency
|
|
122
|
-
}) => `STOCK-${isin}
|
|
92
|
+
}) => `STOCK-${isin}_${mic}_${currency}`.toUpperCase();
|
|
123
93
|
var createForexId = ({
|
|
124
94
|
quoteCurrency,
|
|
125
95
|
baseCurrency
|
|
126
|
-
}) => `FOREX-${baseCurrency}
|
|
96
|
+
}) => `FOREX-${baseCurrency}_${quoteCurrency}`.toUpperCase();
|
|
97
|
+
var createIndexId = ({ ticker }) => `INDEX-${ticker}`.toUpperCase();
|
|
127
98
|
|
|
128
99
|
// src/instruments/parseId.ts
|
|
129
100
|
var parseId = (id) => {
|
|
130
101
|
const [type, ...rest] = id.split("-");
|
|
131
|
-
const [first, second, third] = rest.join(
|
|
102
|
+
const [first, second, third] = rest.join().split("_");
|
|
132
103
|
if (type === "STOCK") {
|
|
133
104
|
if (!second) {
|
|
134
105
|
throw new Error("Missing MIC");
|
|
@@ -156,16 +127,25 @@ var parseId = (id) => {
|
|
|
156
127
|
quoteCurrency: second
|
|
157
128
|
};
|
|
158
129
|
}
|
|
130
|
+
if (type === "INDEX") {
|
|
131
|
+
if (!first) {
|
|
132
|
+
throw new Error("Missing ticker");
|
|
133
|
+
}
|
|
134
|
+
return {
|
|
135
|
+
type,
|
|
136
|
+
ticker: first
|
|
137
|
+
};
|
|
138
|
+
}
|
|
159
139
|
throw new Error("Invalid type");
|
|
160
140
|
};
|
|
161
141
|
|
|
162
142
|
// src/pubsub/main.ts
|
|
163
143
|
var TickersTopic = "tradeinsight.tickers";
|
|
164
|
-
|
|
165
|
-
0 && (module.exports = {
|
|
144
|
+
export {
|
|
166
145
|
CloudSchema,
|
|
167
146
|
TickersTopic,
|
|
168
147
|
createForexId,
|
|
148
|
+
createIndexId,
|
|
169
149
|
createStockId,
|
|
170
150
|
parseId
|
|
171
|
-
}
|
|
151
|
+
};
|
package/package.json
CHANGED
|
@@ -1,15 +1,16 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sebspark/tradeinsight",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "3.0.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
7
|
+
"type": "module",
|
|
7
8
|
"types": "dist/index.d.ts",
|
|
8
9
|
"files": [
|
|
9
10
|
"dist"
|
|
10
11
|
],
|
|
11
12
|
"scripts": {
|
|
12
|
-
"build": "tsup-node src/index.ts --format esm
|
|
13
|
+
"build": "tsup-node src/index.ts --format esm --target node22 --dts",
|
|
13
14
|
"dev": "tsc --watch --noEmit",
|
|
14
15
|
"generate:avro": "ts-node ./scripts/avro-to-ts.ts",
|
|
15
16
|
"lint": "biome check .",
|
package/dist/index.d.mts
DELETED
|
@@ -1,58 +0,0 @@
|
|
|
1
|
-
interface InstrumentPrice {
|
|
2
|
-
ask: null | number;
|
|
3
|
-
bid: null | number;
|
|
4
|
-
last: null | number;
|
|
5
|
-
lastInSek: null | number;
|
|
6
|
-
}
|
|
7
|
-
interface Ticker {
|
|
8
|
-
id: string;
|
|
9
|
-
mic: string;
|
|
10
|
-
isin: string;
|
|
11
|
-
ticker: string;
|
|
12
|
-
currencyCode: string;
|
|
13
|
-
price: InstrumentPrice;
|
|
14
|
-
}
|
|
15
|
-
interface TickerMessage {
|
|
16
|
-
tickers: Ticker[];
|
|
17
|
-
}
|
|
18
|
-
declare const CloudSchema: {
|
|
19
|
-
schemaId: string;
|
|
20
|
-
avroDefinition: string;
|
|
21
|
-
};
|
|
22
|
-
|
|
23
|
-
declare const createStockId: ({ isin, mic, currency, }: {
|
|
24
|
-
isin: string;
|
|
25
|
-
currency: string;
|
|
26
|
-
mic: string;
|
|
27
|
-
}) => string;
|
|
28
|
-
/**
|
|
29
|
-
* Create an ID for a FOREX instrument, i.e. a currency relationship.
|
|
30
|
-
* The structure matches a currency pair:
|
|
31
|
-
*
|
|
32
|
-
* Base currency / quote currency = Exchange rate
|
|
33
|
-
*
|
|
34
|
-
* @see https://en.wikipedia.org/wiki/Currency_pair
|
|
35
|
-
* @example
|
|
36
|
-
* EUR/USD = 1.45
|
|
37
|
-
* This means a person would need 1.45 US dollars to purchase one Euro.
|
|
38
|
-
*/
|
|
39
|
-
declare const createForexId: ({ quoteCurrency, baseCurrency, }: {
|
|
40
|
-
baseCurrency: string;
|
|
41
|
-
quoteCurrency: string;
|
|
42
|
-
}) => string;
|
|
43
|
-
|
|
44
|
-
declare const parseId: (id: string) => {
|
|
45
|
-
type: "STOCK" | "FOREX";
|
|
46
|
-
isin?: string;
|
|
47
|
-
mic?: string;
|
|
48
|
-
currency?: string;
|
|
49
|
-
baseCurrency?: string;
|
|
50
|
-
quoteCurrency?: string;
|
|
51
|
-
};
|
|
52
|
-
|
|
53
|
-
declare const TickersTopic = "tradeinsight.tickers";
|
|
54
|
-
type TickersPubSubChannels = {
|
|
55
|
-
[TickersTopic]: TickerMessage;
|
|
56
|
-
};
|
|
57
|
-
|
|
58
|
-
export { CloudSchema, type InstrumentPrice, type Ticker, type TickerMessage, type TickersPubSubChannels, TickersTopic, createForexId, createStockId, parseId };
|
package/dist/index.mjs
DELETED
|
@@ -1,140 +0,0 @@
|
|
|
1
|
-
// src/generated/tickerMessage.ts
|
|
2
|
-
var CloudSchema = {
|
|
3
|
-
schemaId: "ticker-v1",
|
|
4
|
-
avroDefinition: `{
|
|
5
|
-
"type": "record",
|
|
6
|
-
"name": "TickerMessage",
|
|
7
|
-
"namespace": "com.financial.api",
|
|
8
|
-
"doc": "Real-time update containing the latest pricing details of financial instruments.",
|
|
9
|
-
"fields": [
|
|
10
|
-
{
|
|
11
|
-
"name": "tickers",
|
|
12
|
-
"type": {
|
|
13
|
-
"type": "array",
|
|
14
|
-
"items": {
|
|
15
|
-
"type": "record",
|
|
16
|
-
"name": "Ticker",
|
|
17
|
-
"doc": "A real-time update containing the latest pricing details of a financial instrument.",
|
|
18
|
-
"fields": [
|
|
19
|
-
{
|
|
20
|
-
"name": "id",
|
|
21
|
-
"type": "string",
|
|
22
|
-
"doc": "Unique identifier of the instrument. Consists of type followed by the least common denominators making it unique. Example: STOCK-SE0000148884;XSTO;SEK"
|
|
23
|
-
},
|
|
24
|
-
{
|
|
25
|
-
"name": "mic",
|
|
26
|
-
"type": "string",
|
|
27
|
-
"doc": "The Market Identifier Code (MIC), specifying the financial market where the instrument is listed."
|
|
28
|
-
},
|
|
29
|
-
{
|
|
30
|
-
"name": "isin",
|
|
31
|
-
"type": "string",
|
|
32
|
-
"doc": "International Securities Identification Number (ISIN) uniquely identifying the financial instrument."
|
|
33
|
-
},
|
|
34
|
-
{
|
|
35
|
-
"name": "ticker",
|
|
36
|
-
"type": "string",
|
|
37
|
-
"doc": "The stock market symbol or abbreviation used to identify the financial instrument on the exchange."
|
|
38
|
-
},
|
|
39
|
-
{
|
|
40
|
-
"name": "currencyCode",
|
|
41
|
-
"type": "string",
|
|
42
|
-
"doc": "The code representing the currency in which the instrument's price is denominated."
|
|
43
|
-
},
|
|
44
|
-
{
|
|
45
|
-
"name": "price",
|
|
46
|
-
"type": {
|
|
47
|
-
"type": "record",
|
|
48
|
-
"name": "InstrumentPrice",
|
|
49
|
-
"doc": "A representation of the current pricing details for a financial instrument.",
|
|
50
|
-
"fields": [
|
|
51
|
-
{
|
|
52
|
-
"name": "ask",
|
|
53
|
-
"type": ["null", "double"],
|
|
54
|
-
"doc": "The current ask price. If no ask price is available, this can be null.",
|
|
55
|
-
"default": null
|
|
56
|
-
},
|
|
57
|
-
{
|
|
58
|
-
"name": "bid",
|
|
59
|
-
"type": ["null", "double"],
|
|
60
|
-
"doc": "The current bid price. If no bid price is available, this can be null.",
|
|
61
|
-
"default": null
|
|
62
|
-
},
|
|
63
|
-
{
|
|
64
|
-
"name": "last",
|
|
65
|
-
"type": ["null", "double"],
|
|
66
|
-
"doc": "The last traded price. If there hasn't been any recent trade, this can be null.",
|
|
67
|
-
"default": null
|
|
68
|
-
},
|
|
69
|
-
{
|
|
70
|
-
"name": "lastInSek",
|
|
71
|
-
"type": ["null", "double"],
|
|
72
|
-
"doc": "The last traded price in SEK. If there hasn't been any recent trade, this can be null.",
|
|
73
|
-
"default": null
|
|
74
|
-
}
|
|
75
|
-
]
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
]
|
|
79
|
-
}
|
|
80
|
-
}
|
|
81
|
-
}
|
|
82
|
-
]
|
|
83
|
-
}
|
|
84
|
-
`
|
|
85
|
-
};
|
|
86
|
-
|
|
87
|
-
// src/instruments/createId.ts
|
|
88
|
-
var createStockId = ({
|
|
89
|
-
isin,
|
|
90
|
-
mic,
|
|
91
|
-
currency
|
|
92
|
-
}) => `STOCK-${isin};${mic};${currency}`.toUpperCase();
|
|
93
|
-
var createForexId = ({
|
|
94
|
-
quoteCurrency,
|
|
95
|
-
baseCurrency
|
|
96
|
-
}) => `FOREX-${baseCurrency};${quoteCurrency}`.toUpperCase();
|
|
97
|
-
|
|
98
|
-
// src/instruments/parseId.ts
|
|
99
|
-
var parseId = (id) => {
|
|
100
|
-
const [type, ...rest] = id.split("-");
|
|
101
|
-
const [first, second, third] = rest.join("-").split(";");
|
|
102
|
-
if (type === "STOCK") {
|
|
103
|
-
if (!second) {
|
|
104
|
-
throw new Error("Missing MIC");
|
|
105
|
-
}
|
|
106
|
-
if (!third) {
|
|
107
|
-
throw new Error("Missing currency");
|
|
108
|
-
}
|
|
109
|
-
return {
|
|
110
|
-
type,
|
|
111
|
-
isin: first,
|
|
112
|
-
mic: second,
|
|
113
|
-
currency: third
|
|
114
|
-
};
|
|
115
|
-
}
|
|
116
|
-
if (type === "FOREX") {
|
|
117
|
-
if (!first) {
|
|
118
|
-
throw new Error("Missing baseCurrency");
|
|
119
|
-
}
|
|
120
|
-
if (!second) {
|
|
121
|
-
throw new Error("Missing quoteCurrency");
|
|
122
|
-
}
|
|
123
|
-
return {
|
|
124
|
-
type,
|
|
125
|
-
baseCurrency: first,
|
|
126
|
-
quoteCurrency: second
|
|
127
|
-
};
|
|
128
|
-
}
|
|
129
|
-
throw new Error("Invalid type");
|
|
130
|
-
};
|
|
131
|
-
|
|
132
|
-
// src/pubsub/main.ts
|
|
133
|
-
var TickersTopic = "tradeinsight.tickers";
|
|
134
|
-
export {
|
|
135
|
-
CloudSchema,
|
|
136
|
-
TickersTopic,
|
|
137
|
-
createForexId,
|
|
138
|
-
createStockId,
|
|
139
|
-
parseId
|
|
140
|
-
};
|