@sebspark/tradeinsight 2.0.0 → 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.js +2 -34
- package/package.json +3 -2
- package/dist/index.d.mts +0 -69
- package/dist/index.mjs +0 -151
package/dist/index.js
CHANGED
|
@@ -1,34 +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
|
-
createIndexId: () => createIndexId,
|
|
27
|
-
createStockId: () => createStockId,
|
|
28
|
-
parseId: () => parseId
|
|
29
|
-
});
|
|
30
|
-
module.exports = __toCommonJS(index_exports);
|
|
31
|
-
|
|
32
1
|
// src/generated/tickerMessage.ts
|
|
33
2
|
var CloudSchema = {
|
|
34
3
|
schemaId: "ticker-v1",
|
|
@@ -172,12 +141,11 @@ var parseId = (id) => {
|
|
|
172
141
|
|
|
173
142
|
// src/pubsub/main.ts
|
|
174
143
|
var TickersTopic = "tradeinsight.tickers";
|
|
175
|
-
|
|
176
|
-
0 && (module.exports = {
|
|
144
|
+
export {
|
|
177
145
|
CloudSchema,
|
|
178
146
|
TickersTopic,
|
|
179
147
|
createForexId,
|
|
180
148
|
createIndexId,
|
|
181
149
|
createStockId,
|
|
182
150
|
parseId
|
|
183
|
-
}
|
|
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,69 +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
|
-
declare const createIndexId: ({ ticker }: {
|
|
44
|
-
ticker: string;
|
|
45
|
-
}) => string;
|
|
46
|
-
|
|
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;
|
|
61
|
-
};
|
|
62
|
-
declare const parseId: (id: string) => StockId | ForexId | IndexId;
|
|
63
|
-
|
|
64
|
-
declare const TickersTopic = "tradeinsight.tickers";
|
|
65
|
-
type TickersPubSubChannels = {
|
|
66
|
-
[TickersTopic]: TickerMessage;
|
|
67
|
-
};
|
|
68
|
-
|
|
69
|
-
export { CloudSchema, type InstrumentPrice, type Ticker, type TickerMessage, type TickersPubSubChannels, TickersTopic, createForexId, createIndexId, createStockId, parseId };
|
package/dist/index.mjs
DELETED
|
@@ -1,151 +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
|
-
var createIndexId = ({ ticker }) => `INDEX-${ticker}`.toUpperCase();
|
|
98
|
-
|
|
99
|
-
// src/instruments/parseId.ts
|
|
100
|
-
var parseId = (id) => {
|
|
101
|
-
const [type, ...rest] = id.split("-");
|
|
102
|
-
const [first, second, third] = rest.join().split("_");
|
|
103
|
-
if (type === "STOCK") {
|
|
104
|
-
if (!second) {
|
|
105
|
-
throw new Error("Missing MIC");
|
|
106
|
-
}
|
|
107
|
-
if (!third) {
|
|
108
|
-
throw new Error("Missing currency");
|
|
109
|
-
}
|
|
110
|
-
return {
|
|
111
|
-
type,
|
|
112
|
-
isin: first,
|
|
113
|
-
mic: second,
|
|
114
|
-
currency: third
|
|
115
|
-
};
|
|
116
|
-
}
|
|
117
|
-
if (type === "FOREX") {
|
|
118
|
-
if (!first) {
|
|
119
|
-
throw new Error("Missing baseCurrency");
|
|
120
|
-
}
|
|
121
|
-
if (!second) {
|
|
122
|
-
throw new Error("Missing quoteCurrency");
|
|
123
|
-
}
|
|
124
|
-
return {
|
|
125
|
-
type,
|
|
126
|
-
baseCurrency: first,
|
|
127
|
-
quoteCurrency: second
|
|
128
|
-
};
|
|
129
|
-
}
|
|
130
|
-
if (type === "INDEX") {
|
|
131
|
-
if (!first) {
|
|
132
|
-
throw new Error("Missing ticker");
|
|
133
|
-
}
|
|
134
|
-
return {
|
|
135
|
-
type,
|
|
136
|
-
ticker: first
|
|
137
|
-
};
|
|
138
|
-
}
|
|
139
|
-
throw new Error("Invalid type");
|
|
140
|
-
};
|
|
141
|
-
|
|
142
|
-
// src/pubsub/main.ts
|
|
143
|
-
var TickersTopic = "tradeinsight.tickers";
|
|
144
|
-
export {
|
|
145
|
-
CloudSchema,
|
|
146
|
-
TickersTopic,
|
|
147
|
-
createForexId,
|
|
148
|
-
createIndexId,
|
|
149
|
-
createStockId,
|
|
150
|
-
parseId
|
|
151
|
-
};
|