@sebspark/tradeinsight 0.2.0 → 0.3.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.mts +28 -1
- package/dist/index.d.ts +28 -1
- package/dist/index.js +95 -2
- package/dist/index.mjs +93 -2
- package/package.json +4 -1
package/dist/index.d.mts
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
interface InstrumentPrice {
|
|
2
|
+
ask: null | number;
|
|
3
|
+
bid: null | number;
|
|
4
|
+
last: null | number;
|
|
5
|
+
lastInSek: null | number;
|
|
6
|
+
}
|
|
7
|
+
interface StockTicker {
|
|
8
|
+
id: string;
|
|
9
|
+
mic: string;
|
|
10
|
+
isin: string;
|
|
11
|
+
ticker: string;
|
|
12
|
+
currencyCode: string;
|
|
13
|
+
price: InstrumentPrice;
|
|
14
|
+
}
|
|
15
|
+
interface StockTickerMessage {
|
|
16
|
+
tickers: StockTicker[];
|
|
17
|
+
}
|
|
18
|
+
declare const CloudSchema: {
|
|
19
|
+
schemaId: string;
|
|
20
|
+
avroDefinition: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
1
23
|
declare const createStockId: ({ isin, mic, currency, }: {
|
|
2
24
|
isin: string;
|
|
3
25
|
currency: string;
|
|
@@ -17,4 +39,9 @@ declare const parseId: (id: string) => {
|
|
|
17
39
|
toCurrency?: string;
|
|
18
40
|
};
|
|
19
41
|
|
|
20
|
-
|
|
42
|
+
declare const StockTickerTopic = "tradeinsight.stockticker";
|
|
43
|
+
type StockTickerPubSubChannels = {
|
|
44
|
+
[StockTickerTopic]: StockTickerMessage;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { CloudSchema, type InstrumentPrice, type StockTicker, type StockTickerMessage, type StockTickerPubSubChannels, StockTickerTopic, createForexId, createStockId, parseId };
|
package/dist/index.d.ts
CHANGED
|
@@ -1,3 +1,25 @@
|
|
|
1
|
+
interface InstrumentPrice {
|
|
2
|
+
ask: null | number;
|
|
3
|
+
bid: null | number;
|
|
4
|
+
last: null | number;
|
|
5
|
+
lastInSek: null | number;
|
|
6
|
+
}
|
|
7
|
+
interface StockTicker {
|
|
8
|
+
id: string;
|
|
9
|
+
mic: string;
|
|
10
|
+
isin: string;
|
|
11
|
+
ticker: string;
|
|
12
|
+
currencyCode: string;
|
|
13
|
+
price: InstrumentPrice;
|
|
14
|
+
}
|
|
15
|
+
interface StockTickerMessage {
|
|
16
|
+
tickers: StockTicker[];
|
|
17
|
+
}
|
|
18
|
+
declare const CloudSchema: {
|
|
19
|
+
schemaId: string;
|
|
20
|
+
avroDefinition: string;
|
|
21
|
+
};
|
|
22
|
+
|
|
1
23
|
declare const createStockId: ({ isin, mic, currency, }: {
|
|
2
24
|
isin: string;
|
|
3
25
|
currency: string;
|
|
@@ -17,4 +39,9 @@ declare const parseId: (id: string) => {
|
|
|
17
39
|
toCurrency?: string;
|
|
18
40
|
};
|
|
19
41
|
|
|
20
|
-
|
|
42
|
+
declare const StockTickerTopic = "tradeinsight.stockticker";
|
|
43
|
+
type StockTickerPubSubChannels = {
|
|
44
|
+
[StockTickerTopic]: StockTickerMessage;
|
|
45
|
+
};
|
|
46
|
+
|
|
47
|
+
export { CloudSchema, type InstrumentPrice, type StockTicker, type StockTickerMessage, type StockTickerPubSubChannels, StockTickerTopic, createForexId, createStockId, parseId };
|
package/dist/index.js
CHANGED
|
@@ -20,13 +20,101 @@ var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: tru
|
|
|
20
20
|
// src/index.ts
|
|
21
21
|
var index_exports = {};
|
|
22
22
|
__export(index_exports, {
|
|
23
|
+
CloudSchema: () => CloudSchema,
|
|
24
|
+
StockTickerTopic: () => StockTickerTopic,
|
|
23
25
|
createForexId: () => createForexId,
|
|
24
26
|
createStockId: () => createStockId,
|
|
25
27
|
parseId: () => parseId
|
|
26
28
|
});
|
|
27
29
|
module.exports = __toCommonJS(index_exports);
|
|
28
30
|
|
|
29
|
-
// src/
|
|
31
|
+
// src/generated/stockticker.ts
|
|
32
|
+
var CloudSchema = {
|
|
33
|
+
schemaId: "stockticker-v1",
|
|
34
|
+
avroDefinition: `{
|
|
35
|
+
"type": "record",
|
|
36
|
+
"name": "StockTickerMessage",
|
|
37
|
+
"namespace": "com.financial.api",
|
|
38
|
+
"doc": "Real-time update containing the latest pricing details of financial instruments.",
|
|
39
|
+
"fields": [
|
|
40
|
+
{
|
|
41
|
+
"name": "tickers",
|
|
42
|
+
"type": {
|
|
43
|
+
"type": "array",
|
|
44
|
+
"items": {
|
|
45
|
+
"type": "record",
|
|
46
|
+
"name": "StockTicker",
|
|
47
|
+
"doc": "A real-time update containing the latest pricing details of a financial instrument.",
|
|
48
|
+
"fields": [
|
|
49
|
+
{
|
|
50
|
+
"name": "id",
|
|
51
|
+
"type": "string",
|
|
52
|
+
"doc": "Unique identifier of the instrument, consists of TYPE, ISIN, MIC, and Currency Code. Format: TYPE-ISIN;MIC;CurrencyCode"
|
|
53
|
+
},
|
|
54
|
+
{
|
|
55
|
+
"name": "mic",
|
|
56
|
+
"type": "string",
|
|
57
|
+
"doc": "The Market Identifier Code (MIC), specifying the financial market where the instrument is listed."
|
|
58
|
+
},
|
|
59
|
+
{
|
|
60
|
+
"name": "isin",
|
|
61
|
+
"type": "string",
|
|
62
|
+
"doc": "International Securities Identification Number (ISIN) uniquely identifying the financial instrument."
|
|
63
|
+
},
|
|
64
|
+
{
|
|
65
|
+
"name": "ticker",
|
|
66
|
+
"type": "string",
|
|
67
|
+
"doc": "The stock market symbol or abbreviation used to identify the financial instrument on the exchange."
|
|
68
|
+
},
|
|
69
|
+
{
|
|
70
|
+
"name": "currencyCode",
|
|
71
|
+
"type": "string",
|
|
72
|
+
"doc": "The code representing the currency in which the instrument's price is denominated."
|
|
73
|
+
},
|
|
74
|
+
{
|
|
75
|
+
"name": "price",
|
|
76
|
+
"type": {
|
|
77
|
+
"type": "record",
|
|
78
|
+
"name": "InstrumentPrice",
|
|
79
|
+
"doc": "A representation of the current pricing details for a financial instrument.",
|
|
80
|
+
"fields": [
|
|
81
|
+
{
|
|
82
|
+
"name": "ask",
|
|
83
|
+
"type": ["null", "double"],
|
|
84
|
+
"doc": "The current ask price. If no ask price is available, this can be null.",
|
|
85
|
+
"default": null
|
|
86
|
+
},
|
|
87
|
+
{
|
|
88
|
+
"name": "bid",
|
|
89
|
+
"type": ["null", "double"],
|
|
90
|
+
"doc": "The current bid price. If no bid price is available, this can be null.",
|
|
91
|
+
"default": null
|
|
92
|
+
},
|
|
93
|
+
{
|
|
94
|
+
"name": "last",
|
|
95
|
+
"type": ["null", "double"],
|
|
96
|
+
"doc": "The last traded price. If there hasn't been any recent trade, this can be null.",
|
|
97
|
+
"default": null
|
|
98
|
+
},
|
|
99
|
+
{
|
|
100
|
+
"name": "lastInSek",
|
|
101
|
+
"type": ["null", "double"],
|
|
102
|
+
"doc": "The last traded price in SEK. If there hasn't been any recent trade, this can be null.",
|
|
103
|
+
"default": null
|
|
104
|
+
}
|
|
105
|
+
]
|
|
106
|
+
}
|
|
107
|
+
}
|
|
108
|
+
]
|
|
109
|
+
}
|
|
110
|
+
}
|
|
111
|
+
}
|
|
112
|
+
]
|
|
113
|
+
}
|
|
114
|
+
`
|
|
115
|
+
};
|
|
116
|
+
|
|
117
|
+
// src/instruments/createId.ts
|
|
30
118
|
var createStockId = ({
|
|
31
119
|
isin,
|
|
32
120
|
mic,
|
|
@@ -37,7 +125,7 @@ var createForexId = ({
|
|
|
37
125
|
toCurrency
|
|
38
126
|
}) => `FOREX-${toCurrency};${fromCurrency}`.toUpperCase();
|
|
39
127
|
|
|
40
|
-
// src/parseId.ts
|
|
128
|
+
// src/instruments/parseId.ts
|
|
41
129
|
var parseId = (id) => {
|
|
42
130
|
const [type, ...rest] = id.split("-");
|
|
43
131
|
const [first, second, third] = rest.join("-").split(";");
|
|
@@ -70,8 +158,13 @@ var parseId = (id) => {
|
|
|
70
158
|
}
|
|
71
159
|
throw new Error("Invalid type");
|
|
72
160
|
};
|
|
161
|
+
|
|
162
|
+
// src/pubsub/main.ts
|
|
163
|
+
var StockTickerTopic = "tradeinsight.stockticker";
|
|
73
164
|
// Annotate the CommonJS export names for ESM import in node:
|
|
74
165
|
0 && (module.exports = {
|
|
166
|
+
CloudSchema,
|
|
167
|
+
StockTickerTopic,
|
|
75
168
|
createForexId,
|
|
76
169
|
createStockId,
|
|
77
170
|
parseId
|
package/dist/index.mjs
CHANGED
|
@@ -1,4 +1,90 @@
|
|
|
1
|
-
// src/
|
|
1
|
+
// src/generated/stockticker.ts
|
|
2
|
+
var CloudSchema = {
|
|
3
|
+
schemaId: "stockticker-v1",
|
|
4
|
+
avroDefinition: `{
|
|
5
|
+
"type": "record",
|
|
6
|
+
"name": "StockTickerMessage",
|
|
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": "StockTicker",
|
|
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, ISIN, MIC, and Currency Code. Format: TYPE-ISIN;MIC;CurrencyCode"
|
|
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
|
|
2
88
|
var createStockId = ({
|
|
3
89
|
isin,
|
|
4
90
|
mic,
|
|
@@ -9,7 +95,7 @@ var createForexId = ({
|
|
|
9
95
|
toCurrency
|
|
10
96
|
}) => `FOREX-${toCurrency};${fromCurrency}`.toUpperCase();
|
|
11
97
|
|
|
12
|
-
// src/parseId.ts
|
|
98
|
+
// src/instruments/parseId.ts
|
|
13
99
|
var parseId = (id) => {
|
|
14
100
|
const [type, ...rest] = id.split("-");
|
|
15
101
|
const [first, second, third] = rest.join("-").split(";");
|
|
@@ -42,7 +128,12 @@ var parseId = (id) => {
|
|
|
42
128
|
}
|
|
43
129
|
throw new Error("Invalid type");
|
|
44
130
|
};
|
|
131
|
+
|
|
132
|
+
// src/pubsub/main.ts
|
|
133
|
+
var StockTickerTopic = "tradeinsight.stockticker";
|
|
45
134
|
export {
|
|
135
|
+
CloudSchema,
|
|
136
|
+
StockTickerTopic,
|
|
46
137
|
createForexId,
|
|
47
138
|
createStockId,
|
|
48
139
|
parseId
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sebspark/tradeinsight",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.3.0",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"module": "dist/index.mjs",
|
|
@@ -11,11 +11,14 @@
|
|
|
11
11
|
"scripts": {
|
|
12
12
|
"build": "tsup-node src/index.ts --format esm,cjs --dts",
|
|
13
13
|
"dev": "tsc --watch --noEmit",
|
|
14
|
+
"generate:avro": "ts-node ./scripts/avro-to-ts.ts",
|
|
14
15
|
"lint": "biome check .",
|
|
15
16
|
"test": "vitest run --passWithNoTests --coverage",
|
|
16
17
|
"typecheck": "vitest --typecheck.only --passWithNoTests"
|
|
17
18
|
},
|
|
18
19
|
"devDependencies": {
|
|
20
|
+
"avro-typescript": "1.3.0",
|
|
21
|
+
"ts-node": "10.9.2",
|
|
19
22
|
"tsconfig": "*"
|
|
20
23
|
}
|
|
21
24
|
}
|