@sebspark/tradeinsight 0.2.0 → 0.4.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 CHANGED
@@ -1,3 +1,43 @@
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
+ /**
24
+ * @deprecated Use the Ticker type instead.
25
+ */
26
+ interface StockTicker {
27
+ id: string;
28
+ mic: string;
29
+ isin: string;
30
+ ticker: string;
31
+ currencyCode: string;
32
+ price: InstrumentPrice;
33
+ }
34
+ /**
35
+ * @deprecated Use the TickerMessage type instead.
36
+ */
37
+ interface StockTickerMessage {
38
+ tickers: StockTicker[];
39
+ }
40
+
1
41
  declare const createStockId: ({ isin, mic, currency, }: {
2
42
  isin: string;
3
43
  currency: string;
@@ -17,4 +57,19 @@ declare const parseId: (id: string) => {
17
57
  toCurrency?: string;
18
58
  };
19
59
 
20
- export { createForexId, createStockId, parseId };
60
+ /**
61
+ * @deprecated Use TickersTopic instead
62
+ */
63
+ declare const StockTickerTopic = "tradeinsight.stockticker";
64
+ /**
65
+ * @deprecated Use TickersPubSubChannels instead
66
+ */
67
+ type StockTickerPubSubChannels = {
68
+ [StockTickerTopic]: StockTickerMessage;
69
+ };
70
+ declare const TickersTopic = "tradeinsight.tickers";
71
+ type TickersPubSubChannels = {
72
+ [TickersTopic]: TickerMessage;
73
+ };
74
+
75
+ export { CloudSchema, type InstrumentPrice, type StockTicker, type StockTickerMessage, type StockTickerPubSubChannels, StockTickerTopic, type Ticker, type TickerMessage, type TickersPubSubChannels, TickersTopic, createForexId, createStockId, parseId };
package/dist/index.d.ts CHANGED
@@ -1,3 +1,43 @@
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
+ /**
24
+ * @deprecated Use the Ticker type instead.
25
+ */
26
+ interface StockTicker {
27
+ id: string;
28
+ mic: string;
29
+ isin: string;
30
+ ticker: string;
31
+ currencyCode: string;
32
+ price: InstrumentPrice;
33
+ }
34
+ /**
35
+ * @deprecated Use the TickerMessage type instead.
36
+ */
37
+ interface StockTickerMessage {
38
+ tickers: StockTicker[];
39
+ }
40
+
1
41
  declare const createStockId: ({ isin, mic, currency, }: {
2
42
  isin: string;
3
43
  currency: string;
@@ -17,4 +57,19 @@ declare const parseId: (id: string) => {
17
57
  toCurrency?: string;
18
58
  };
19
59
 
20
- export { createForexId, createStockId, parseId };
60
+ /**
61
+ * @deprecated Use TickersTopic instead
62
+ */
63
+ declare const StockTickerTopic = "tradeinsight.stockticker";
64
+ /**
65
+ * @deprecated Use TickersPubSubChannels instead
66
+ */
67
+ type StockTickerPubSubChannels = {
68
+ [StockTickerTopic]: StockTickerMessage;
69
+ };
70
+ declare const TickersTopic = "tradeinsight.tickers";
71
+ type TickersPubSubChannels = {
72
+ [TickersTopic]: TickerMessage;
73
+ };
74
+
75
+ export { CloudSchema, type InstrumentPrice, type StockTicker, type StockTickerMessage, type StockTickerPubSubChannels, StockTickerTopic, type Ticker, type TickerMessage, type TickersPubSubChannels, TickersTopic, createForexId, createStockId, parseId };
package/dist/index.js CHANGED
@@ -20,13 +20,102 @@ 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,
25
+ TickersTopic: () => TickersTopic,
23
26
  createForexId: () => createForexId,
24
27
  createStockId: () => createStockId,
25
28
  parseId: () => parseId
26
29
  });
27
30
  module.exports = __toCommonJS(index_exports);
28
31
 
29
- // src/createId.ts
32
+ // src/generated/tickerMessage.ts
33
+ var CloudSchema = {
34
+ schemaId: "ticker-v1",
35
+ avroDefinition: `{
36
+ "type": "record",
37
+ "name": "TickerMessage",
38
+ "namespace": "com.financial.api",
39
+ "doc": "Real-time update containing the latest pricing details of financial instruments.",
40
+ "fields": [
41
+ {
42
+ "name": "tickers",
43
+ "type": {
44
+ "type": "array",
45
+ "items": {
46
+ "type": "record",
47
+ "name": "Ticker",
48
+ "doc": "A real-time update containing the latest pricing details of a financial instrument.",
49
+ "fields": [
50
+ {
51
+ "name": "id",
52
+ "type": "string",
53
+ "doc": "Unique identifier of the instrument. Consists of type followed by the least common denominators making it unique. Example: STOCK-SE0000148884;XSTO;SEK"
54
+ },
55
+ {
56
+ "name": "mic",
57
+ "type": "string",
58
+ "doc": "The Market Identifier Code (MIC), specifying the financial market where the instrument is listed."
59
+ },
60
+ {
61
+ "name": "isin",
62
+ "type": "string",
63
+ "doc": "International Securities Identification Number (ISIN) uniquely identifying the financial instrument."
64
+ },
65
+ {
66
+ "name": "ticker",
67
+ "type": "string",
68
+ "doc": "The stock market symbol or abbreviation used to identify the financial instrument on the exchange."
69
+ },
70
+ {
71
+ "name": "currencyCode",
72
+ "type": "string",
73
+ "doc": "The code representing the currency in which the instrument's price is denominated."
74
+ },
75
+ {
76
+ "name": "price",
77
+ "type": {
78
+ "type": "record",
79
+ "name": "InstrumentPrice",
80
+ "doc": "A representation of the current pricing details for a financial instrument.",
81
+ "fields": [
82
+ {
83
+ "name": "ask",
84
+ "type": ["null", "double"],
85
+ "doc": "The current ask price. If no ask price is available, this can be null.",
86
+ "default": null
87
+ },
88
+ {
89
+ "name": "bid",
90
+ "type": ["null", "double"],
91
+ "doc": "The current bid price. If no bid price is available, this can be null.",
92
+ "default": null
93
+ },
94
+ {
95
+ "name": "last",
96
+ "type": ["null", "double"],
97
+ "doc": "The last traded price. If there hasn't been any recent trade, this can be null.",
98
+ "default": null
99
+ },
100
+ {
101
+ "name": "lastInSek",
102
+ "type": ["null", "double"],
103
+ "doc": "The last traded price in SEK. If there hasn't been any recent trade, this can be null.",
104
+ "default": null
105
+ }
106
+ ]
107
+ }
108
+ }
109
+ ]
110
+ }
111
+ }
112
+ }
113
+ ]
114
+ }
115
+ `
116
+ };
117
+
118
+ // src/instruments/createId.ts
30
119
  var createStockId = ({
31
120
  isin,
32
121
  mic,
@@ -37,7 +126,7 @@ var createForexId = ({
37
126
  toCurrency
38
127
  }) => `FOREX-${toCurrency};${fromCurrency}`.toUpperCase();
39
128
 
40
- // src/parseId.ts
129
+ // src/instruments/parseId.ts
41
130
  var parseId = (id) => {
42
131
  const [type, ...rest] = id.split("-");
43
132
  const [first, second, third] = rest.join("-").split(";");
@@ -70,8 +159,15 @@ var parseId = (id) => {
70
159
  }
71
160
  throw new Error("Invalid type");
72
161
  };
162
+
163
+ // src/pubsub/main.ts
164
+ var StockTickerTopic = "tradeinsight.stockticker";
165
+ var TickersTopic = "tradeinsight.tickers";
73
166
  // Annotate the CommonJS export names for ESM import in node:
74
167
  0 && (module.exports = {
168
+ CloudSchema,
169
+ StockTickerTopic,
170
+ TickersTopic,
75
171
  createForexId,
76
172
  createStockId,
77
173
  parseId
package/dist/index.mjs CHANGED
@@ -1,4 +1,90 @@
1
- // src/createId.ts
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
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,14 @@ 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";
134
+ var TickersTopic = "tradeinsight.tickers";
45
135
  export {
136
+ CloudSchema,
137
+ StockTickerTopic,
138
+ TickersTopic,
46
139
  createForexId,
47
140
  createStockId,
48
141
  parseId
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sebspark/tradeinsight",
3
- "version": "0.2.0",
3
+ "version": "0.4.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
  }