@sebspark/tradeinsight 4.0.3 → 5.0.1
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 +96 -44
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +113 -51
- package/dist/index.mjs.map +1 -1
- package/package.json +3 -8
- package/dist/index-v2.d.mts +0 -116
- package/dist/index-v2.d.mts.map +0 -1
- package/dist/index-v2.mjs +0 -123
- package/dist/index-v2.mjs.map +0 -1
package/dist/index.d.mts
CHANGED
|
@@ -21,66 +21,118 @@ declare const CloudSchema: {
|
|
|
21
21
|
avroDefinition: string;
|
|
22
22
|
};
|
|
23
23
|
//#endregion
|
|
24
|
-
//#region src/instruments/
|
|
25
|
-
declare const
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
24
|
+
//#region src/instruments/types.d.ts
|
|
25
|
+
declare const types: {
|
|
26
|
+
readonly BNE: "BNE";
|
|
27
|
+
readonly BND: "BND";
|
|
28
|
+
readonly DER: "DER";
|
|
29
|
+
readonly ETF: "ETF";
|
|
30
|
+
readonly ETP: "ETP";
|
|
31
|
+
readonly FXS: "FXS";
|
|
32
|
+
readonly FND: "FND";
|
|
33
|
+
readonly IDX: "IDX";
|
|
34
|
+
readonly STO: "STO";
|
|
35
|
+
};
|
|
36
|
+
type BondExchangeId = {
|
|
37
|
+
type: (typeof types)['BNE'];
|
|
30
38
|
isin: string;
|
|
31
|
-
currency: string;
|
|
32
39
|
mic: string;
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
* EUR/USD = 1.45
|
|
43
|
-
* This means a person would need 1.45 US dollars to purchase one Euro.
|
|
44
|
-
*/
|
|
45
|
-
declare const createForexId: ({
|
|
46
|
-
quoteCurrency,
|
|
47
|
-
baseCurrency
|
|
48
|
-
}: {
|
|
49
|
-
baseCurrency: string;
|
|
50
|
-
quoteCurrency: string;
|
|
51
|
-
}) => string;
|
|
52
|
-
declare const createIndexId: ({
|
|
53
|
-
ticker
|
|
54
|
-
}: {
|
|
40
|
+
currency: string;
|
|
41
|
+
};
|
|
42
|
+
type BondOTCId = {
|
|
43
|
+
type: (typeof types)['BND'];
|
|
44
|
+
isin: string;
|
|
45
|
+
currency: string;
|
|
46
|
+
};
|
|
47
|
+
type DerivativeId = {
|
|
48
|
+
type: (typeof types)['DER'];
|
|
55
49
|
ticker: string;
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
50
|
+
mic: string;
|
|
51
|
+
currency: string;
|
|
52
|
+
strike: string;
|
|
53
|
+
expiry: string;
|
|
54
|
+
};
|
|
55
|
+
type ETFId = {
|
|
56
|
+
type: (typeof types)['ETF'];
|
|
60
57
|
isin: string;
|
|
61
|
-
|
|
62
|
-
|
|
63
|
-
|
|
64
|
-
type
|
|
65
|
-
type: '
|
|
58
|
+
mic: string;
|
|
59
|
+
currency: string;
|
|
60
|
+
};
|
|
61
|
+
type ETPId = {
|
|
62
|
+
type: (typeof types)['ETP'];
|
|
66
63
|
isin: string;
|
|
67
64
|
mic: string;
|
|
68
65
|
currency: string;
|
|
69
66
|
};
|
|
70
67
|
type ForexId = {
|
|
71
|
-
type: '
|
|
68
|
+
type: (typeof types)['FXS'];
|
|
72
69
|
baseCurrency: string;
|
|
73
70
|
quoteCurrency: string;
|
|
74
71
|
};
|
|
72
|
+
type FundId = {
|
|
73
|
+
type: (typeof types)['FND'];
|
|
74
|
+
isin: string;
|
|
75
|
+
currency: string;
|
|
76
|
+
};
|
|
75
77
|
type IndexId = {
|
|
76
|
-
type: '
|
|
78
|
+
type: (typeof types)['IDX'];
|
|
77
79
|
ticker: string;
|
|
80
|
+
currency: string;
|
|
78
81
|
};
|
|
79
|
-
type
|
|
80
|
-
type: '
|
|
82
|
+
type StockId = {
|
|
83
|
+
type: (typeof types)['STO'];
|
|
81
84
|
isin: string;
|
|
85
|
+
mic: string;
|
|
86
|
+
currency: string;
|
|
82
87
|
};
|
|
83
|
-
type TradeInsightId =
|
|
88
|
+
type TradeInsightId = BondExchangeId | BondOTCId | DerivativeId | ETFId | ETPId | ForexId | FundId | IndexId | StockId;
|
|
89
|
+
//#endregion
|
|
90
|
+
//#region src/instruments/createId.d.ts
|
|
91
|
+
declare const createBondExchangeId: ({
|
|
92
|
+
isin,
|
|
93
|
+
mic,
|
|
94
|
+
currency
|
|
95
|
+
}: Omit<BondExchangeId, "type">) => string;
|
|
96
|
+
declare const createBondOTCId: ({
|
|
97
|
+
isin,
|
|
98
|
+
currency
|
|
99
|
+
}: Omit<BondOTCId, "type">) => string;
|
|
100
|
+
declare const createDerivativeId: ({
|
|
101
|
+
ticker,
|
|
102
|
+
mic,
|
|
103
|
+
currency,
|
|
104
|
+
strike,
|
|
105
|
+
expiry
|
|
106
|
+
}: Omit<DerivativeId, "type">) => string;
|
|
107
|
+
declare const createETFId: ({
|
|
108
|
+
mic,
|
|
109
|
+
isin,
|
|
110
|
+
currency
|
|
111
|
+
}: Omit<ETFId, "type">) => string;
|
|
112
|
+
declare const createETPId: ({
|
|
113
|
+
mic,
|
|
114
|
+
isin,
|
|
115
|
+
currency
|
|
116
|
+
}: Omit<ETPId, "type">) => string;
|
|
117
|
+
declare const createFundId: ({
|
|
118
|
+
isin,
|
|
119
|
+
currency
|
|
120
|
+
}: Omit<FundId, "type">) => string;
|
|
121
|
+
declare const createIndexId: ({
|
|
122
|
+
ticker,
|
|
123
|
+
currency
|
|
124
|
+
}: Omit<IndexId, "type">) => string;
|
|
125
|
+
declare const createForexId: ({
|
|
126
|
+
quoteCurrency,
|
|
127
|
+
baseCurrency
|
|
128
|
+
}: Omit<ForexId, "type">) => string;
|
|
129
|
+
declare const createStockId: ({
|
|
130
|
+
isin,
|
|
131
|
+
mic,
|
|
132
|
+
currency
|
|
133
|
+
}: Omit<StockId, "type">) => string;
|
|
134
|
+
//#endregion
|
|
135
|
+
//#region src/instruments/parseId.d.ts
|
|
84
136
|
declare const parseId: (id: string) => TradeInsightId;
|
|
85
137
|
//#endregion
|
|
86
138
|
//#region src/pubsub/main.d.ts
|
|
@@ -89,5 +141,5 @@ type TickersPubSubChannels = {
|
|
|
89
141
|
[TickersTopic]: TickerMessage;
|
|
90
142
|
};
|
|
91
143
|
//#endregion
|
|
92
|
-
export { CloudSchema, InstrumentPrice, Ticker, TickerMessage, TickersPubSubChannels, TickersTopic, createForexId, createFundId, createIndexId, createStockId, parseId };
|
|
144
|
+
export { BondExchangeId, BondOTCId, CloudSchema, DerivativeId, ETFId, ETPId, ForexId, FundId, IndexId, InstrumentPrice, StockId, Ticker, TickerMessage, TickersPubSubChannels, TickersTopic, TradeInsightId, createBondExchangeId, createBondOTCId, createDerivativeId, createETFId, createETPId, createForexId, createFundId, createIndexId, createStockId, parseId, types };
|
|
93
145
|
//# sourceMappingURL=index.d.mts.map
|
package/dist/index.d.mts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/generated/tickerMessage.ts","../src/instruments/createId.ts","../src/instruments/parseId.ts","../src/pubsub/main.ts"],"sourcesContent":[],"mappings":";UAAiB,eAAA;EAAA,GAAA,EAAA,IAAA,GAAA,MAAe;EAOf,GAAA,EAAA,IAAM,GAAA,MAAA;EASN,IAAA,EAAA,IAAA,GAAA,MAAa;EAIjB,SAAA,EAAA,IAoFZ,GAAA,MAAA;;UAjGgB,MAAA;;ECPJ,GAAA,EAAA,
|
|
1
|
+
{"version":3,"file":"index.d.mts","names":[],"sources":["../src/generated/tickerMessage.ts","../src/instruments/types.ts","../src/instruments/createId.ts","../src/instruments/parseId.ts","../src/pubsub/main.ts"],"sourcesContent":[],"mappings":";UAAiB,eAAA;EAAA,GAAA,EAAA,IAAA,GAAA,MAAe;EAOf,GAAA,EAAA,IAAM,GAAA,MAAA;EASN,IAAA,EAAA,IAAA,GAAA,MAAa;E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,MAAA;EAAA;AAAA,CAAA,EEYd,IFZc,CEYT,YFZS,EAAA,MAAA,CAAA,EAAA,GAAA,MAAA;AAGJ,cEYA,WFwEZ,EAAA,CAAA;EAAA,GAAA;EAAA,IAAA;EAAA;AAAA,CAAA,EExEoD,IFwEpD,CExEyD,KFwEzD,EAAA,MAAA,CAAA,EAAA,GAAA,MAAA;cErEY;;;;GAAwC,KAAK;cAG7C;;;GAAoC,KAAK;cAGzC;;;GAAuC,KAAK;ADzC5C,cC4CA,aDlCH,EAAA,CAAA;EAAA,aAAA;EAAA;AAAA,CAAA,ECqCP,IDrCO,CCqCF,ODrCE,EAAA,MAAA,CAAA,EAAA,GAAA,MAAA;AAEE,cCsCC,aDrCG,EAAA,CAAA;EAAK,IAAA;EAAA,GAAA;EAAA;AAAA,CAAA,ECqCkC,IDrClC,CCqCuC,ODrCvC,EAAA,MAAA,CAAA,EAAA,GAAA,MAAA;;;ADbJ,cGcJ,OHdmB,EAAA,CAAA,EAAA,EAAA,MAAA,EAAA,GGcK,cHdL;;;AAAf,cIEJ,YAAA,GJFmB,sBAAA;AAOf,KIJL,qBAAA,GJUH;EAGQ,CIZd,YAAA,CJYc,EIZC,aJaP;AAGX,CAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -84,63 +84,125 @@ const CloudSchema = {
|
|
|
84
84
|
`
|
|
85
85
|
};
|
|
86
86
|
|
|
87
|
+
//#endregion
|
|
88
|
+
//#region src/instruments/types.ts
|
|
89
|
+
const types = {
|
|
90
|
+
BNE: "BNE",
|
|
91
|
+
BND: "BND",
|
|
92
|
+
DER: "DER",
|
|
93
|
+
ETF: "ETF",
|
|
94
|
+
ETP: "ETP",
|
|
95
|
+
FXS: "FXS",
|
|
96
|
+
FND: "FND",
|
|
97
|
+
IDX: "IDX",
|
|
98
|
+
STO: "STO"
|
|
99
|
+
};
|
|
100
|
+
|
|
87
101
|
//#endregion
|
|
88
102
|
//#region src/instruments/createId.ts
|
|
89
|
-
const
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
* EUR/USD = 1.45
|
|
99
|
-
* This means a person would need 1.45 US dollars to purchase one Euro.
|
|
100
|
-
*/
|
|
101
|
-
const createForexId = ({ quoteCurrency, baseCurrency }) => `FOREX-${baseCurrency}_${quoteCurrency}`.toUpperCase();
|
|
102
|
-
const createIndexId = ({ ticker }) => `INDEX-${ticker}`.toUpperCase();
|
|
103
|
-
const createFundId = ({ isin }) => `FUND-${isin}`.toUpperCase();
|
|
103
|
+
const createBondExchangeId = ({ isin, mic, currency }) => `${types.BNE}_${isin}_${mic}_${currency}`.toUpperCase();
|
|
104
|
+
const createBondOTCId = ({ isin, currency }) => `${types.BND}_${isin}_${currency}`.toUpperCase();
|
|
105
|
+
const createDerivativeId = ({ ticker, mic, currency, strike, expiry }) => `${types.DER}_${ticker}_${mic}_${currency}_${strike}_${expiry}`.toUpperCase();
|
|
106
|
+
const createETFId = ({ mic, isin, currency }) => `${types.ETF}_${isin}_${mic}_${currency}`.toUpperCase();
|
|
107
|
+
const createETPId = ({ mic, isin, currency }) => `${types.ETP}_${isin}_${mic}_${currency}`.toUpperCase();
|
|
108
|
+
const createFundId = ({ isin, currency }) => `${types.FND}_${isin}_${currency}`.toUpperCase();
|
|
109
|
+
const createIndexId = ({ ticker, currency }) => `${types.IDX}_${ticker}_${currency}`.toUpperCase();
|
|
110
|
+
const createForexId = ({ quoteCurrency, baseCurrency }) => `${types.FXS}_${baseCurrency}_${quoteCurrency}`.toUpperCase();
|
|
111
|
+
const createStockId = ({ isin, mic, currency }) => `${types.STO}_${isin}_${mic}_${currency}`.toUpperCase();
|
|
104
112
|
|
|
105
113
|
//#endregion
|
|
106
114
|
//#region src/instruments/parseId.ts
|
|
107
115
|
const parseId = (id) => {
|
|
108
|
-
const [
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
116
|
+
const [initial, first, second, third, fourth, fifth] = id.split("_");
|
|
117
|
+
switch (initial) {
|
|
118
|
+
case "BNE":
|
|
119
|
+
if (!first) throw new Error("Missing isin");
|
|
120
|
+
if (!second) throw new Error("Missing mic");
|
|
121
|
+
if (!third) throw new Error("Missing currency");
|
|
122
|
+
return {
|
|
123
|
+
type: "BNE",
|
|
124
|
+
isin: first,
|
|
125
|
+
mic: second,
|
|
126
|
+
currency: third
|
|
127
|
+
};
|
|
128
|
+
case "BND":
|
|
129
|
+
if (!first) throw new Error("Missing isin");
|
|
130
|
+
if (!second) throw new Error("Missing currency");
|
|
131
|
+
return {
|
|
132
|
+
type: "BND",
|
|
133
|
+
isin: first,
|
|
134
|
+
currency: second
|
|
135
|
+
};
|
|
136
|
+
case "DER":
|
|
137
|
+
if (!first) throw new Error("Missing ticker");
|
|
138
|
+
if (!second) throw new Error("Missing mic");
|
|
139
|
+
if (!third) throw new Error("Missing currency");
|
|
140
|
+
if (!fourth) throw new Error("Missing strike");
|
|
141
|
+
if (!fifth) throw new Error("Missing expiry");
|
|
142
|
+
return {
|
|
143
|
+
type: "DER",
|
|
144
|
+
ticker: first,
|
|
145
|
+
mic: second,
|
|
146
|
+
currency: third,
|
|
147
|
+
strike: fourth,
|
|
148
|
+
expiry: fifth
|
|
149
|
+
};
|
|
150
|
+
case "ETF":
|
|
151
|
+
if (!first) throw new Error("Missing isin");
|
|
152
|
+
if (!second) throw new Error("Missing mic");
|
|
153
|
+
if (!third) throw new Error("Missing currency");
|
|
154
|
+
return {
|
|
155
|
+
type: "ETF",
|
|
156
|
+
isin: first,
|
|
157
|
+
mic: second,
|
|
158
|
+
currency: third
|
|
159
|
+
};
|
|
160
|
+
case "ETP":
|
|
161
|
+
if (!first) throw new Error("Missing isin");
|
|
162
|
+
if (!second) throw new Error("Missing mic");
|
|
163
|
+
if (!third) throw new Error("Missing currency");
|
|
164
|
+
return {
|
|
165
|
+
type: "ETP",
|
|
166
|
+
isin: first,
|
|
167
|
+
mic: second,
|
|
168
|
+
currency: third
|
|
169
|
+
};
|
|
170
|
+
case "FXS":
|
|
171
|
+
if (!first) throw new Error("Missing baseCurrency");
|
|
172
|
+
if (!second) throw new Error("Missing quoteCurrency");
|
|
173
|
+
return {
|
|
174
|
+
type: "FXS",
|
|
175
|
+
baseCurrency: first,
|
|
176
|
+
quoteCurrency: second
|
|
177
|
+
};
|
|
178
|
+
case "FND":
|
|
179
|
+
if (!first) throw new Error("Missing isin");
|
|
180
|
+
if (!second) throw new Error("Missing currency");
|
|
181
|
+
return {
|
|
182
|
+
type: "FND",
|
|
183
|
+
isin: first,
|
|
184
|
+
currency: second
|
|
185
|
+
};
|
|
186
|
+
case "IDX":
|
|
187
|
+
if (!first) throw new Error("Missing ticker");
|
|
188
|
+
if (!second) throw new Error("Missing currency");
|
|
189
|
+
return {
|
|
190
|
+
type: "IDX",
|
|
191
|
+
ticker: first,
|
|
192
|
+
currency: second
|
|
193
|
+
};
|
|
194
|
+
case "STO":
|
|
195
|
+
if (!first) throw new Error("Missing isin");
|
|
196
|
+
if (!second) throw new Error("Missing mic");
|
|
197
|
+
if (!third) throw new Error("Missing currency");
|
|
198
|
+
return {
|
|
199
|
+
type: "STO",
|
|
200
|
+
isin: first,
|
|
201
|
+
mic: second,
|
|
202
|
+
currency: third
|
|
203
|
+
};
|
|
204
|
+
default: throw new Error("Invalid type");
|
|
142
205
|
}
|
|
143
|
-
throw new Error("Invalid type");
|
|
144
206
|
};
|
|
145
207
|
|
|
146
208
|
//#endregion
|
|
@@ -148,5 +210,5 @@ const parseId = (id) => {
|
|
|
148
210
|
const TickersTopic = "tradeinsight.tickers";
|
|
149
211
|
|
|
150
212
|
//#endregion
|
|
151
|
-
export { CloudSchema, TickersTopic, createForexId, createFundId, createIndexId, createStockId, parseId };
|
|
213
|
+
export { CloudSchema, TickersTopic, createBondExchangeId, createBondOTCId, createDerivativeId, createETFId, createETPId, createForexId, createFundId, createIndexId, createStockId, parseId, types };
|
|
152
214
|
//# sourceMappingURL=index.mjs.map
|
package/dist/index.mjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.mjs","names":[],"sources":["../src/generated/tickerMessage.ts","../src/instruments/createId.ts","../src/instruments/parseId.ts","../src/pubsub/main.ts"],"sourcesContent":["export interface InstrumentPrice {\n ask: null | number\n bid: null | number\n last: null | number\n lastInSek: null | number\n}\n\nexport interface Ticker {\n id: string\n mic: string\n isin: string\n ticker: string\n currencyCode: string\n price: InstrumentPrice\n}\n\nexport interface TickerMessage {\n tickers: Ticker[]\n}\n\nexport const CloudSchema = {\n schemaId: 'ticker-v1',\n\n avroDefinition: `{\n \"type\": \"record\",\n \"name\": \"TickerMessage\",\n \"namespace\": \"com.financial.api\",\n \"doc\": \"Real-time update containing the latest pricing details of financial instruments.\",\n \"fields\": [\n {\n \"name\": \"tickers\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"record\",\n \"name\": \"Ticker\",\n \"doc\": \"A real-time update containing the latest pricing details of a financial instrument.\",\n \"fields\": [\n {\n \"name\": \"id\",\n \"type\": \"string\",\n \"doc\": \"Unique identifier of the instrument. Consists of type followed by the least common denominators making it unique. Example: STOCK-SE0000148884;XSTO;SEK\"\n },\n {\n \"name\": \"mic\",\n \"type\": \"string\",\n \"doc\": \"The Market Identifier Code (MIC), specifying the financial market where the instrument is listed.\"\n },\n {\n \"name\": \"isin\",\n \"type\": \"string\",\n \"doc\": \"International Securities Identification Number (ISIN) uniquely identifying the financial instrument.\"\n },\n {\n \"name\": \"ticker\",\n \"type\": \"string\",\n \"doc\": \"The stock market symbol or abbreviation used to identify the financial instrument on the exchange.\"\n },\n {\n \"name\": \"currencyCode\",\n \"type\": \"string\",\n \"doc\": \"The code representing the currency in which the instrument's price is denominated.\"\n },\n {\n \"name\": \"price\",\n \"type\": {\n \"type\": \"record\",\n \"name\": \"InstrumentPrice\",\n \"doc\": \"A representation of the current pricing details for a financial instrument.\",\n \"fields\": [\n {\n \"name\": \"ask\",\n \"type\": [\"null\", \"double\"],\n \"doc\": \"The current ask price. If no ask price is available, this can be null.\",\n \"default\": null\n },\n {\n \"name\": \"bid\",\n \"type\": [\"null\", \"double\"],\n \"doc\": \"The current bid price. If no bid price is available, this can be null.\",\n \"default\": null\n },\n {\n \"name\": \"last\",\n \"type\": [\"null\", \"double\"],\n \"doc\": \"The last traded price. If there hasn't been any recent trade, this can be null.\",\n \"default\": null\n },\n {\n \"name\": \"lastInSek\",\n \"type\": [\"null\", \"double\"],\n \"doc\": \"The last traded price in SEK. If there hasn't been any recent trade, this can be null.\",\n \"default\": null\n }\n ]\n }\n }\n ]\n }\n }\n }\n ]\n}\n`,\n}\n","export const createStockId = ({\n isin,\n mic,\n currency,\n}: {\n isin: string\n currency: string\n mic: string\n}) => `STOCK-${isin}_${mic}_${currency}`.toUpperCase()\n\n/**\n * Create an ID for a FOREX instrument, i.e. a currency relationship.\n * The structure matches a currency pair:\n *\n * Base currency / quote currency = Exchange rate\n *\n * @see https://en.wikipedia.org/wiki/Currency_pair\n * @example\n * EUR/USD = 1.45\n * This means a person would need 1.45 US dollars to purchase one Euro.\n */\nexport const createForexId = ({\n quoteCurrency,\n baseCurrency,\n}: {\n baseCurrency: string\n quoteCurrency: string\n}) => `FOREX-${baseCurrency}_${quoteCurrency}`.toUpperCase()\n\nexport const createIndexId = ({ ticker }: { ticker: string }) =>\n `INDEX-${ticker}`.toUpperCase()\n\nexport const createFundId = ({ isin }: { isin: string }) =>\n `FUND-${isin}`.toUpperCase()\n","type StockId = {\n type: 'STOCK'\n isin: string\n mic: string\n currency: string\n}\n\ntype ForexId = {\n type: 'FOREX'\n baseCurrency: string\n quoteCurrency: string\n}\n\ntype IndexId = {\n type: 'INDEX'\n ticker: string\n}\n\ntype FundId = {\n type: 'FUND'\n isin: string\n}\n\ntype TradeInsightId = StockId | ForexId | IndexId | FundId\n\nexport const parseId = (id: string): TradeInsightId => {\n const [type, ...rest] = id.split('-')\n const [first, second, third] = rest.join().split('_')\n\n if (type === 'STOCK') {\n if (!second) {\n throw new Error('Missing MIC')\n }\n\n if (!third) {\n throw new Error('Missing currency')\n }\n\n return {\n type,\n isin: first,\n mic: second,\n currency: third,\n }\n }\n\n if (type === 'FOREX') {\n if (!first) {\n throw new Error('Missing baseCurrency')\n }\n\n if (!second) {\n throw new Error('Missing quoteCurrency')\n }\n\n return {\n type,\n baseCurrency: first,\n quoteCurrency: second,\n }\n }\n\n if (type === 'INDEX') {\n if (!first) {\n throw new Error('Missing ticker')\n }\n\n return {\n type,\n ticker: first,\n }\n }\n\n if (type === 'FUND') {\n if (!first) {\n throw new Error('Missing isin')\n }\n\n return {\n type,\n isin: first,\n }\n }\n\n throw new Error('Invalid type')\n}\n","import type { TickerMessage } from '../generated/tickerMessage'\n\nexport const TickersTopic = 'tradeinsight.tickers'\nexport type TickersPubSubChannels = {\n [TickersTopic]: TickerMessage\n}\n"],"mappings":";AAoBA,MAAa,cAAc;CACzB,UAAU;CAEV,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiFjB;;;;ACxGD,MAAa,iBAAiB,EAC5B,MACA,KACA,eAKI,SAAS,KAAK,GAAG,IAAI,GAAG,WAAW,aAAa;;;;;;;;;;;;AAatD,MAAa,iBAAiB,EAC5B,eACA,mBAII,SAAS,aAAa,GAAG,gBAAgB,aAAa;AAE5D,MAAa,iBAAiB,EAAE,aAC9B,SAAS,SAAS,aAAa;AAEjC,MAAa,gBAAgB,EAAE,WAC7B,QAAQ,OAAO,aAAa;;;;ACR9B,MAAa,WAAW,OAA+B;CACrD,MAAM,CAAC,MAAM,GAAG,QAAQ,GAAG,MAAM,IAAI;CACrC,MAAM,CAAC,OAAO,QAAQ,SAAS,KAAK,MAAM,CAAC,MAAM,IAAI;AAErD,KAAI,SAAS,SAAS;AACpB,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,cAAc;AAGhC,MAAI,CAAC,MACH,OAAM,IAAI,MAAM,mBAAmB;AAGrC,SAAO;GACL;GACA,MAAM;GACN,KAAK;GACL,UAAU;GACX;;AAGH,KAAI,SAAS,SAAS;AACpB,MAAI,CAAC,MACH,OAAM,IAAI,MAAM,uBAAuB;AAGzC,MAAI,CAAC,OACH,OAAM,IAAI,MAAM,wBAAwB;AAG1C,SAAO;GACL;GACA,cAAc;GACd,eAAe;GAChB;;AAGH,KAAI,SAAS,SAAS;AACpB,MAAI,CAAC,MACH,OAAM,IAAI,MAAM,iBAAiB;AAGnC,SAAO;GACL;GACA,QAAQ;GACT;;AAGH,KAAI,SAAS,QAAQ;AACnB,MAAI,CAAC,MACH,OAAM,IAAI,MAAM,eAAe;AAGjC,SAAO;GACL;GACA,MAAM;GACP;;AAGH,OAAM,IAAI,MAAM,eAAe;;;;;AClFjC,MAAa,eAAe"}
|
|
1
|
+
{"version":3,"file":"index.mjs","names":[],"sources":["../src/generated/tickerMessage.ts","../src/instruments/types.ts","../src/instruments/createId.ts","../src/instruments/parseId.ts","../src/pubsub/main.ts"],"sourcesContent":["export interface InstrumentPrice {\n ask: null | number\n bid: null | number\n last: null | number\n lastInSek: null | number\n}\n\nexport interface Ticker {\n id: string\n mic: string\n isin: string\n ticker: string\n currencyCode: string\n price: InstrumentPrice\n}\n\nexport interface TickerMessage {\n tickers: Ticker[]\n}\n\nexport const CloudSchema = {\n schemaId: 'ticker-v1',\n\n avroDefinition: `{\n \"type\": \"record\",\n \"name\": \"TickerMessage\",\n \"namespace\": \"com.financial.api\",\n \"doc\": \"Real-time update containing the latest pricing details of financial instruments.\",\n \"fields\": [\n {\n \"name\": \"tickers\",\n \"type\": {\n \"type\": \"array\",\n \"items\": {\n \"type\": \"record\",\n \"name\": \"Ticker\",\n \"doc\": \"A real-time update containing the latest pricing details of a financial instrument.\",\n \"fields\": [\n {\n \"name\": \"id\",\n \"type\": \"string\",\n \"doc\": \"Unique identifier of the instrument. Consists of type followed by the least common denominators making it unique. Example: STOCK-SE0000148884;XSTO;SEK\"\n },\n {\n \"name\": \"mic\",\n \"type\": \"string\",\n \"doc\": \"The Market Identifier Code (MIC), specifying the financial market where the instrument is listed.\"\n },\n {\n \"name\": \"isin\",\n \"type\": \"string\",\n \"doc\": \"International Securities Identification Number (ISIN) uniquely identifying the financial instrument.\"\n },\n {\n \"name\": \"ticker\",\n \"type\": \"string\",\n \"doc\": \"The stock market symbol or abbreviation used to identify the financial instrument on the exchange.\"\n },\n {\n \"name\": \"currencyCode\",\n \"type\": \"string\",\n \"doc\": \"The code representing the currency in which the instrument's price is denominated.\"\n },\n {\n \"name\": \"price\",\n \"type\": {\n \"type\": \"record\",\n \"name\": \"InstrumentPrice\",\n \"doc\": \"A representation of the current pricing details for a financial instrument.\",\n \"fields\": [\n {\n \"name\": \"ask\",\n \"type\": [\"null\", \"double\"],\n \"doc\": \"The current ask price. If no ask price is available, this can be null.\",\n \"default\": null\n },\n {\n \"name\": \"bid\",\n \"type\": [\"null\", \"double\"],\n \"doc\": \"The current bid price. If no bid price is available, this can be null.\",\n \"default\": null\n },\n {\n \"name\": \"last\",\n \"type\": [\"null\", \"double\"],\n \"doc\": \"The last traded price. If there hasn't been any recent trade, this can be null.\",\n \"default\": null\n },\n {\n \"name\": \"lastInSek\",\n \"type\": [\"null\", \"double\"],\n \"doc\": \"The last traded price in SEK. If there hasn't been any recent trade, this can be null.\",\n \"default\": null\n }\n ]\n }\n }\n ]\n }\n }\n }\n ]\n}\n`,\n}\n","export const types = {\n BNE: 'BNE',\n BND: 'BND',\n DER: 'DER',\n ETF: 'ETF',\n ETP: 'ETP',\n FXS: 'FXS',\n FND: 'FND',\n IDX: 'IDX',\n STO: 'STO',\n} as const\n\nexport type BondExchangeId = {\n type: (typeof types)['BNE']\n isin: string\n mic: string\n currency: string\n}\n\nexport type BondOTCId = {\n type: (typeof types)['BND']\n isin: string\n currency: string\n}\n\nexport type DerivativeId = {\n type: (typeof types)['DER']\n ticker: string\n mic: string\n currency: string\n strike: string\n expiry: string\n}\n\nexport type ETFId = {\n type: (typeof types)['ETF']\n isin: string\n mic: string\n currency: string\n}\n\nexport type ETPId = {\n type: (typeof types)['ETP']\n isin: string\n mic: string\n currency: string\n}\n\nexport type ForexId = {\n type: (typeof types)['FXS']\n baseCurrency: string\n quoteCurrency: string\n}\n\nexport type FundId = {\n type: (typeof types)['FND']\n isin: string\n currency: string\n}\n\nexport type IndexId = {\n type: (typeof types)['IDX']\n ticker: string\n currency: string\n}\n\nexport type StockId = {\n type: (typeof types)['STO']\n isin: string\n mic: string\n currency: string\n}\n\nexport type TradeInsightId =\n | BondExchangeId\n | BondOTCId\n | DerivativeId\n | ETFId\n | ETPId\n | ForexId\n | FundId\n | IndexId\n | StockId\n","import {\n type BondExchangeId,\n type BondOTCId,\n type DerivativeId,\n type ETFId,\n type ETPId,\n type ForexId,\n type FundId,\n type IndexId,\n type StockId,\n types,\n} from './types'\n\nexport const createBondExchangeId = ({\n isin,\n mic,\n currency,\n}: Omit<BondExchangeId, 'type'>) =>\n `${types.BNE}_${isin}_${mic}_${currency}`.toUpperCase()\n\nexport const createBondOTCId = ({ isin, currency }: Omit<BondOTCId, 'type'>) =>\n `${types.BND}_${isin}_${currency}`.toUpperCase()\n\nexport const createDerivativeId = ({\n ticker,\n mic,\n currency,\n strike,\n expiry,\n}: Omit<DerivativeId, 'type'>) =>\n `${types.DER}_${ticker}_${mic}_${currency}_${strike}_${expiry}`.toUpperCase()\n\nexport const createETFId = ({ mic, isin, currency }: Omit<ETFId, 'type'>) =>\n `${types.ETF}_${isin}_${mic}_${currency}`.toUpperCase()\n\nexport const createETPId = ({ mic, isin, currency }: Omit<ETPId, 'type'>) =>\n `${types.ETP}_${isin}_${mic}_${currency}`.toUpperCase()\n\nexport const createFundId = ({ isin, currency }: Omit<FundId, 'type'>) =>\n `${types.FND}_${isin}_${currency}`.toUpperCase()\n\nexport const createIndexId = ({ ticker, currency }: Omit<IndexId, 'type'>) =>\n `${types.IDX}_${ticker}_${currency}`.toUpperCase()\n\nexport const createForexId = ({\n quoteCurrency,\n baseCurrency,\n}: Omit<ForexId, 'type'>) =>\n `${types.FXS}_${baseCurrency}_${quoteCurrency}`.toUpperCase()\n\nexport const createStockId = ({ isin, mic, currency }: Omit<StockId, 'type'>) =>\n `${types.STO}_${isin}_${mic}_${currency}`.toUpperCase()\n","import type {\n BondExchangeId,\n BondOTCId,\n DerivativeId,\n ETFId,\n ETPId,\n ForexId,\n FundId,\n IndexId,\n StockId,\n TradeInsightId,\n types,\n} from './types'\n\nexport const parseId = (id: string): TradeInsightId => {\n const [initial, first, second, third, fourth, fifth] = id.split('_')\n const type = initial as keyof typeof types\n\n switch (type) {\n case 'BNE':\n if (!first) {\n throw new Error('Missing isin')\n }\n if (!second) {\n throw new Error('Missing mic')\n }\n if (!third) {\n throw new Error('Missing currency')\n }\n return {\n type: 'BNE',\n isin: first,\n mic: second,\n currency: third,\n } satisfies BondExchangeId as BondExchangeId\n\n case 'BND':\n if (!first) {\n throw new Error('Missing isin')\n }\n if (!second) {\n throw new Error('Missing currency')\n }\n return {\n type: 'BND',\n isin: first,\n currency: second,\n } satisfies BondOTCId as BondOTCId\n\n case 'DER': {\n if (!first) {\n throw new Error('Missing ticker')\n }\n if (!second) {\n throw new Error('Missing mic')\n }\n if (!third) {\n throw new Error('Missing currency')\n }\n if (!fourth) {\n throw new Error('Missing strike')\n }\n if (!fifth) {\n throw new Error('Missing expiry')\n }\n return {\n type: 'DER',\n ticker: first,\n mic: second,\n currency: third,\n strike: fourth,\n expiry: fifth,\n } satisfies DerivativeId as DerivativeId\n }\n\n case 'ETF': {\n if (!first) {\n throw new Error('Missing isin')\n }\n if (!second) {\n throw new Error('Missing mic')\n }\n if (!third) {\n throw new Error('Missing currency')\n }\n return {\n type: 'ETF',\n isin: first,\n mic: second,\n currency: third,\n } satisfies ETFId as ETFId\n }\n\n case 'ETP': {\n if (!first) {\n throw new Error('Missing isin')\n }\n if (!second) {\n throw new Error('Missing mic')\n }\n if (!third) {\n throw new Error('Missing currency')\n }\n return {\n type: 'ETP',\n isin: first,\n mic: second,\n currency: third,\n } satisfies ETPId as ETPId\n }\n\n case 'FXS': {\n if (!first) {\n throw new Error('Missing baseCurrency')\n }\n if (!second) {\n throw new Error('Missing quoteCurrency')\n }\n return {\n type: 'FXS',\n baseCurrency: first,\n quoteCurrency: second,\n } satisfies ForexId as ForexId\n }\n\n case 'FND': {\n if (!first) {\n throw new Error('Missing isin')\n }\n if (!second) {\n throw new Error('Missing currency')\n }\n return {\n type: 'FND',\n isin: first,\n currency: second,\n } satisfies FundId as FundId\n }\n\n case 'IDX': {\n if (!first) {\n throw new Error('Missing ticker')\n }\n if (!second) {\n throw new Error('Missing currency')\n }\n return {\n type: 'IDX',\n ticker: first,\n currency: second,\n } satisfies IndexId as IndexId\n }\n\n case 'STO': {\n if (!first) {\n throw new Error('Missing isin')\n }\n if (!second) {\n throw new Error('Missing mic')\n }\n if (!third) {\n throw new Error('Missing currency')\n }\n return {\n type: 'STO',\n isin: first,\n mic: second,\n currency: third,\n } satisfies StockId as StockId\n }\n\n default:\n throw new Error('Invalid type')\n }\n}\n","import type { TickerMessage } from '../generated/tickerMessage'\n\nexport const TickersTopic = 'tradeinsight.tickers'\nexport type TickersPubSubChannels = {\n [TickersTopic]: TickerMessage\n}\n"],"mappings":";AAoBA,MAAa,cAAc;CACzB,UAAU;CAEV,gBAAgB;;;;;;;;;;;;;;;;;;;;;;;;;;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AC,OACH,OAAM,IAAI,MAAM,wBAAwB;AAE1C,UAAO;IACL,MAAM;IACN,cAAc;IACd,eAAe;IAChB;EAGH,KAAK;AACH,OAAI,CAAC,MACH,OAAM,IAAI,MAAM,eAAe;AAEjC,OAAI,CAAC,OACH,OAAM,IAAI,MAAM,mBAAmB;AAErC,UAAO;IACL,MAAM;IACN,MAAM;IACN,UAAU;IACX;EAGH,KAAK;AACH,OAAI,CAAC,MACH,OAAM,IAAI,MAAM,iBAAiB;AAEnC,OAAI,CAAC,OACH,OAAM,IAAI,MAAM,mBAAmB;AAErC,UAAO;IACL,MAAM;IACN,QAAQ;IACR,UAAU;IACX;EAGH,KAAK;AACH,OAAI,CAAC,MACH,OAAM,IAAI,MAAM,eAAe;AAEjC,OAAI,CAAC,OACH,OAAM,IAAI,MAAM,cAAc;AAEhC,OAAI,CAAC,MACH,OAAM,IAAI,MAAM,mBAAmB;AAErC,UAAO;IACL,MAAM;IACN,MAAM;IACN,KAAK;IACL,UAAU;IACX;EAGH,QACE,OAAM,IAAI,MAAM,eAAe;;;;;;AC1KrC,MAAa,eAAe"}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@sebspark/tradeinsight",
|
|
3
|
-
"version": "
|
|
3
|
+
"version": "5.0.1",
|
|
4
4
|
"license": "Apache-2.0",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"exports": {
|
|
@@ -8,18 +8,13 @@
|
|
|
8
8
|
"types": "./dist/index.d.mts",
|
|
9
9
|
"import": "./dist/index.mjs",
|
|
10
10
|
"react-native": "./dist/index.mjs"
|
|
11
|
-
},
|
|
12
|
-
"./v2": {
|
|
13
|
-
"types": "./dist/index-v2.d.mts",
|
|
14
|
-
"import": "./dist/index-v2.mjs",
|
|
15
|
-
"react-native": "./dist/index-v2.mjs"
|
|
16
11
|
}
|
|
17
12
|
},
|
|
18
13
|
"files": [
|
|
19
14
|
"dist"
|
|
20
15
|
],
|
|
21
16
|
"scripts": {
|
|
22
|
-
"build": "spark-build src/index.ts
|
|
17
|
+
"build": "spark-build src/index.ts",
|
|
23
18
|
"depcheck": "depcheck",
|
|
24
19
|
"dev": "tsc --watch --noEmit",
|
|
25
20
|
"generate:avro": "ts-node ./scripts/avro-to-ts.ts",
|
|
@@ -31,6 +26,6 @@
|
|
|
31
26
|
"@sebspark/tsconfig": "*",
|
|
32
27
|
"avro-typescript": "1.3.0",
|
|
33
28
|
"ts-node": "10.9.2",
|
|
34
|
-
"vitest": "4.0.
|
|
29
|
+
"vitest": "4.0.16"
|
|
35
30
|
}
|
|
36
31
|
}
|
package/dist/index-v2.d.mts
DELETED
|
@@ -1,116 +0,0 @@
|
|
|
1
|
-
//#region src/instruments/types.d.ts
|
|
2
|
-
declare const types: {
|
|
3
|
-
readonly BNE: "BNE";
|
|
4
|
-
readonly BND: "BND";
|
|
5
|
-
readonly DER: "DER";
|
|
6
|
-
readonly ETF: "ETF";
|
|
7
|
-
readonly ETP: "ETP";
|
|
8
|
-
readonly FXS: "FXS";
|
|
9
|
-
readonly FND: "FND";
|
|
10
|
-
readonly IDX: "IDX";
|
|
11
|
-
readonly STO: "STO";
|
|
12
|
-
};
|
|
13
|
-
type BondExchangeId = {
|
|
14
|
-
type: (typeof types)['BNE'];
|
|
15
|
-
isin: string;
|
|
16
|
-
mic: string;
|
|
17
|
-
currency: string;
|
|
18
|
-
};
|
|
19
|
-
type BondOTCId = {
|
|
20
|
-
type: (typeof types)['BND'];
|
|
21
|
-
isin: string;
|
|
22
|
-
currency: string;
|
|
23
|
-
};
|
|
24
|
-
type DerivativeId = {
|
|
25
|
-
type: (typeof types)['DER'];
|
|
26
|
-
ticker: string;
|
|
27
|
-
mic: string;
|
|
28
|
-
currency: string;
|
|
29
|
-
strike: string;
|
|
30
|
-
expiry: string;
|
|
31
|
-
};
|
|
32
|
-
type ETFId = {
|
|
33
|
-
type: (typeof types)['ETF'];
|
|
34
|
-
isin: string;
|
|
35
|
-
mic: string;
|
|
36
|
-
currency: string;
|
|
37
|
-
};
|
|
38
|
-
type ETPId = {
|
|
39
|
-
type: (typeof types)['ETP'];
|
|
40
|
-
isin: string;
|
|
41
|
-
mic: string;
|
|
42
|
-
currency: string;
|
|
43
|
-
};
|
|
44
|
-
type ForexId = {
|
|
45
|
-
type: (typeof types)['FXS'];
|
|
46
|
-
baseCurrency: string;
|
|
47
|
-
quoteCurrency: string;
|
|
48
|
-
};
|
|
49
|
-
type FundId = {
|
|
50
|
-
type: (typeof types)['FND'];
|
|
51
|
-
isin: string;
|
|
52
|
-
currency: string;
|
|
53
|
-
};
|
|
54
|
-
type IndexId = {
|
|
55
|
-
type: (typeof types)['IDX'];
|
|
56
|
-
ticker: string;
|
|
57
|
-
currency: string;
|
|
58
|
-
};
|
|
59
|
-
type StockId = {
|
|
60
|
-
type: (typeof types)['STO'];
|
|
61
|
-
isin: string;
|
|
62
|
-
mic: string;
|
|
63
|
-
currency: string;
|
|
64
|
-
};
|
|
65
|
-
type TradeInsightId = BondExchangeId | BondOTCId | DerivativeId | ETFId | ETPId | ForexId | FundId | IndexId | StockId;
|
|
66
|
-
//#endregion
|
|
67
|
-
//#region src/instruments/v2/createId.d.ts
|
|
68
|
-
declare const createBondExchangeId: ({
|
|
69
|
-
isin,
|
|
70
|
-
mic,
|
|
71
|
-
currency
|
|
72
|
-
}: Omit<BondExchangeId, "type">) => string;
|
|
73
|
-
declare const createBondOTCId: ({
|
|
74
|
-
isin,
|
|
75
|
-
currency
|
|
76
|
-
}: Omit<BondOTCId, "type">) => string;
|
|
77
|
-
declare const createDerivativeId: ({
|
|
78
|
-
ticker,
|
|
79
|
-
mic,
|
|
80
|
-
currency,
|
|
81
|
-
strike,
|
|
82
|
-
expiry
|
|
83
|
-
}: Omit<DerivativeId, "type">) => string;
|
|
84
|
-
declare const createETFId: ({
|
|
85
|
-
mic,
|
|
86
|
-
isin,
|
|
87
|
-
currency
|
|
88
|
-
}: Omit<ETFId, "type">) => string;
|
|
89
|
-
declare const createETPId: ({
|
|
90
|
-
mic,
|
|
91
|
-
isin,
|
|
92
|
-
currency
|
|
93
|
-
}: Omit<ETPId, "type">) => string;
|
|
94
|
-
declare const createFundId: ({
|
|
95
|
-
isin,
|
|
96
|
-
currency
|
|
97
|
-
}: Omit<FundId, "type">) => string;
|
|
98
|
-
declare const createIndexId: ({
|
|
99
|
-
ticker,
|
|
100
|
-
currency
|
|
101
|
-
}: Omit<IndexId, "type">) => string;
|
|
102
|
-
declare const createForexId: ({
|
|
103
|
-
quoteCurrency,
|
|
104
|
-
baseCurrency
|
|
105
|
-
}: Omit<ForexId, "type">) => string;
|
|
106
|
-
declare const createStockId: ({
|
|
107
|
-
isin,
|
|
108
|
-
mic,
|
|
109
|
-
currency
|
|
110
|
-
}: Omit<StockId, "type">) => string;
|
|
111
|
-
//#endregion
|
|
112
|
-
//#region src/instruments/v2/parseId.d.ts
|
|
113
|
-
declare const parseId: (id: string) => TradeInsightId;
|
|
114
|
-
//#endregion
|
|
115
|
-
export { createBondExchangeId, createBondOTCId, createDerivativeId, createETFId, createETPId, createForexId, createFundId, createIndexId, createStockId, parseId };
|
|
116
|
-
//# sourceMappingURL=index-v2.d.mts.map
|
package/dist/index-v2.d.mts.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-v2.d.mts","names":[],"sources":["../src/instruments/types.ts","../src/instruments/v2/createId.ts","../src/instruments/v2/parseId.ts"],"sourcesContent":[],"mappings":";cAAa;EAAA,SAUH,GAAA,EAAA,KAAA;EAEE,SAAA,GAAA,EAAA,KAAc;EAOd,SAAA,GAAS,EAAA,KAAA;EAMT,SAAA,GAAA,EAAA,KAAY;EASZ,SAAK,GAAA,EAAA,KAAA;EAOL,SAAK,GAAA,EAAA,KAAA;EAOL,SAAA,GAAO,EAAA,KAAA;EAMP,SAAM,GAAA,EAAA,KAAA;EAMN,SAAA,GAAO,EAAA,KAAA;AAMnB,CAAA;AAOY,KA7DA,cAAA,GA6Dc;EACtB,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,EAAA,GAAA,MAAA;AAKT,cCVC,aDWQ,EAAA,CAAA;EAAA,aAAA;EAAA;AAAA,CAAA,ECRlB,IDQkB,CCRb,ODQa,EAAA,MAAA,CAAA,EAAA,GAAA,MAAA;AAKT,cCVC,aDWQ,EAAA,CAAA;EAAA,IAAA;EAAA,GAAA;EAAA;AAAA,CAAA,ECXkC,IDWlC,CCXuC,ODWvC,EAAA,MAAA,CAAA,EAAA,GAAA,MAAA;;;AA7DR,cEcA,OFJH,EAAA,CAAA,EAAA,EAAA,MAAA,EAAA,GEI2B,cFJ3B"}
|
package/dist/index-v2.mjs
DELETED
|
@@ -1,123 +0,0 @@
|
|
|
1
|
-
//#region src/instruments/types.ts
|
|
2
|
-
const types = {
|
|
3
|
-
BNE: "BNE",
|
|
4
|
-
BND: "BND",
|
|
5
|
-
DER: "DER",
|
|
6
|
-
ETF: "ETF",
|
|
7
|
-
ETP: "ETP",
|
|
8
|
-
FXS: "FXS",
|
|
9
|
-
FND: "FND",
|
|
10
|
-
IDX: "IDX",
|
|
11
|
-
STO: "STO"
|
|
12
|
-
};
|
|
13
|
-
|
|
14
|
-
//#endregion
|
|
15
|
-
//#region src/instruments/v2/createId.ts
|
|
16
|
-
const createBondExchangeId = ({ isin, mic, currency }) => `${types.BNE}_${isin}_${mic}_${currency}`.toUpperCase();
|
|
17
|
-
const createBondOTCId = ({ isin, currency }) => `${types.BND}_${isin}_${currency}`.toUpperCase();
|
|
18
|
-
const createDerivativeId = ({ ticker, mic, currency, strike, expiry }) => `${types.DER}_${ticker}_${mic}_${currency}_${strike}_${expiry}`.toUpperCase();
|
|
19
|
-
const createETFId = ({ mic, isin, currency }) => `${types.ETF}_${isin}_${mic}_${currency}`.toUpperCase();
|
|
20
|
-
const createETPId = ({ mic, isin, currency }) => `${types.ETP}_${isin}_${mic}_${currency}`.toUpperCase();
|
|
21
|
-
const createFundId = ({ isin, currency }) => `${types.FND}_${isin}_${currency}`.toUpperCase();
|
|
22
|
-
const createIndexId = ({ ticker, currency }) => `${types.IDX}_${ticker}_${currency}`.toUpperCase();
|
|
23
|
-
const createForexId = ({ quoteCurrency, baseCurrency }) => `${types.FXS}_${baseCurrency}_${quoteCurrency}`.toUpperCase();
|
|
24
|
-
const createStockId = ({ isin, mic, currency }) => `${types.STO}_${isin}_${mic}_${currency}`.toUpperCase();
|
|
25
|
-
|
|
26
|
-
//#endregion
|
|
27
|
-
//#region src/instruments/v2/parseId.ts
|
|
28
|
-
const parseId = (id) => {
|
|
29
|
-
const [initial, first, second, third, fourth, fifth] = id.split("_");
|
|
30
|
-
switch (initial) {
|
|
31
|
-
case "BNE":
|
|
32
|
-
if (!first) throw new Error("Missing isin");
|
|
33
|
-
if (!second) throw new Error("Missing mic");
|
|
34
|
-
if (!third) throw new Error("Missing currency");
|
|
35
|
-
return {
|
|
36
|
-
type: "BNE",
|
|
37
|
-
isin: first,
|
|
38
|
-
mic: second,
|
|
39
|
-
currency: third
|
|
40
|
-
};
|
|
41
|
-
case "BND":
|
|
42
|
-
if (!first) throw new Error("Missing isin");
|
|
43
|
-
if (!second) throw new Error("Missing currency");
|
|
44
|
-
return {
|
|
45
|
-
type: "BND",
|
|
46
|
-
isin: first,
|
|
47
|
-
currency: second
|
|
48
|
-
};
|
|
49
|
-
case "DER":
|
|
50
|
-
if (!first) throw new Error("Missing ticker");
|
|
51
|
-
if (!second) throw new Error("Missing mic");
|
|
52
|
-
if (!third) throw new Error("Missing currency");
|
|
53
|
-
if (!fourth) throw new Error("Missing strike");
|
|
54
|
-
if (!fifth) throw new Error("Missing expiry");
|
|
55
|
-
return {
|
|
56
|
-
type: "DER",
|
|
57
|
-
ticker: first,
|
|
58
|
-
mic: second,
|
|
59
|
-
currency: third,
|
|
60
|
-
strike: fourth,
|
|
61
|
-
expiry: fifth
|
|
62
|
-
};
|
|
63
|
-
case "ETF":
|
|
64
|
-
if (!first) throw new Error("Missing isin");
|
|
65
|
-
if (!second) throw new Error("Missing mic");
|
|
66
|
-
if (!third) throw new Error("Missing currency");
|
|
67
|
-
return {
|
|
68
|
-
type: "ETF",
|
|
69
|
-
isin: first,
|
|
70
|
-
mic: second,
|
|
71
|
-
currency: third
|
|
72
|
-
};
|
|
73
|
-
case "ETP":
|
|
74
|
-
if (!first) throw new Error("Missing isin");
|
|
75
|
-
if (!second) throw new Error("Missing mic");
|
|
76
|
-
if (!third) throw new Error("Missing currency");
|
|
77
|
-
return {
|
|
78
|
-
type: "ETP",
|
|
79
|
-
isin: first,
|
|
80
|
-
mic: second,
|
|
81
|
-
currency: third
|
|
82
|
-
};
|
|
83
|
-
case "FXS":
|
|
84
|
-
if (!first) throw new Error("Missing baseCurrency");
|
|
85
|
-
if (!second) throw new Error("Missing quoteCurrency");
|
|
86
|
-
return {
|
|
87
|
-
type: "FXS",
|
|
88
|
-
baseCurrency: first,
|
|
89
|
-
quoteCurrency: second
|
|
90
|
-
};
|
|
91
|
-
case "FND":
|
|
92
|
-
if (!first) throw new Error("Missing isin");
|
|
93
|
-
if (!second) throw new Error("Missing currency");
|
|
94
|
-
return {
|
|
95
|
-
type: "FND",
|
|
96
|
-
isin: first,
|
|
97
|
-
currency: second
|
|
98
|
-
};
|
|
99
|
-
case "IDX":
|
|
100
|
-
if (!first) throw new Error("Missing ticker");
|
|
101
|
-
if (!second) throw new Error("Missing currency");
|
|
102
|
-
return {
|
|
103
|
-
type: "IDX",
|
|
104
|
-
ticker: first,
|
|
105
|
-
currency: second
|
|
106
|
-
};
|
|
107
|
-
case "STO":
|
|
108
|
-
if (!first) throw new Error("Missing isin");
|
|
109
|
-
if (!second) throw new Error("Missing mic");
|
|
110
|
-
if (!third) throw new Error("Missing currency");
|
|
111
|
-
return {
|
|
112
|
-
type: "STO",
|
|
113
|
-
isin: first,
|
|
114
|
-
mic: second,
|
|
115
|
-
currency: third
|
|
116
|
-
};
|
|
117
|
-
default: throw new Error("Invalid type");
|
|
118
|
-
}
|
|
119
|
-
};
|
|
120
|
-
|
|
121
|
-
//#endregion
|
|
122
|
-
export { createBondExchangeId, createBondOTCId, createDerivativeId, createETFId, createETPId, createForexId, createFundId, createIndexId, createStockId, parseId };
|
|
123
|
-
//# sourceMappingURL=index-v2.mjs.map
|
package/dist/index-v2.mjs.map
DELETED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"index-v2.mjs","names":[],"sources":["../src/instruments/types.ts","../src/instruments/v2/createId.ts","../src/instruments/v2/parseId.ts"],"sourcesContent":["export const types = {\n BNE: 'BNE',\n BND: 'BND',\n DER: 'DER',\n ETF: 'ETF',\n ETP: 'ETP',\n FXS: 'FXS',\n FND: 'FND',\n IDX: 'IDX',\n STO: 'STO',\n} as const\n\nexport type BondExchangeId = {\n type: (typeof types)['BNE']\n isin: string\n mic: string\n currency: string\n}\n\nexport type BondOTCId = {\n type: (typeof types)['BND']\n isin: string\n currency: string\n}\n\nexport type DerivativeId = {\n type: (typeof types)['DER']\n ticker: string\n mic: string\n currency: string\n strike: string\n expiry: string\n}\n\nexport type ETFId = {\n type: (typeof types)['ETF']\n isin: string\n mic: string\n currency: string\n}\n\nexport type ETPId = {\n type: (typeof types)['ETP']\n isin: string\n mic: string\n currency: string\n}\n\nexport type ForexId = {\n type: (typeof types)['FXS']\n baseCurrency: string\n quoteCurrency: string\n}\n\nexport type FundId = {\n type: (typeof types)['FND']\n isin: string\n currency: string\n}\n\nexport type IndexId = {\n type: (typeof types)['IDX']\n ticker: string\n currency: string\n}\n\nexport type StockId = {\n type: (typeof types)['STO']\n isin: string\n mic: string\n currency: string\n}\n\nexport type TradeInsightId =\n | BondExchangeId\n | BondOTCId\n | DerivativeId\n | ETFId\n | ETPId\n | ForexId\n | FundId\n | IndexId\n | StockId\n","import {\n type BondExchangeId,\n type BondOTCId,\n type DerivativeId,\n type ETFId,\n type ETPId,\n type ForexId,\n type FundId,\n type IndexId,\n type StockId,\n types,\n} from '../types'\n\nexport const createBondExchangeId = ({\n isin,\n mic,\n currency,\n}: Omit<BondExchangeId, 'type'>) =>\n `${types.BNE}_${isin}_${mic}_${currency}`.toUpperCase()\n\nexport const createBondOTCId = ({ isin, currency }: Omit<BondOTCId, 'type'>) =>\n `${types.BND}_${isin}_${currency}`.toUpperCase()\n\nexport const createDerivativeId = ({\n ticker,\n mic,\n currency,\n strike,\n expiry,\n}: Omit<DerivativeId, 'type'>) =>\n `${types.DER}_${ticker}_${mic}_${currency}_${strike}_${expiry}`.toUpperCase()\n\nexport const createETFId = ({ mic, isin, currency }: Omit<ETFId, 'type'>) =>\n `${types.ETF}_${isin}_${mic}_${currency}`.toUpperCase()\n\nexport const createETPId = ({ mic, isin, currency }: Omit<ETPId, 'type'>) =>\n `${types.ETP}_${isin}_${mic}_${currency}`.toUpperCase()\n\nexport const createFundId = ({ isin, currency }: Omit<FundId, 'type'>) =>\n `${types.FND}_${isin}_${currency}`.toUpperCase()\n\nexport const createIndexId = ({ ticker, currency }: Omit<IndexId, 'type'>) =>\n `${types.IDX}_${ticker}_${currency}`.toUpperCase()\n\nexport const createForexId = ({\n quoteCurrency,\n baseCurrency,\n}: Omit<ForexId, 'type'>) =>\n `${types.FXS}_${baseCurrency}_${quoteCurrency}`.toUpperCase()\n\nexport const createStockId = ({ isin, mic, currency }: Omit<StockId, 'type'>) =>\n `${types.STO}_${isin}_${mic}_${currency}`.toUpperCase()\n","import type {\n BondExchangeId,\n BondOTCId,\n DerivativeId,\n ETFId,\n ETPId,\n ForexId,\n FundId,\n IndexId,\n StockId,\n TradeInsightId,\n types,\n} from '../types'\n\nexport const parseId = (id: string): TradeInsightId => {\n const [initial, first, second, third, fourth, fifth] = id.split('_')\n const type = initial as keyof typeof types\n\n switch (type) {\n case 'BNE':\n if (!first) {\n throw new Error('Missing isin')\n }\n if (!second) {\n throw new Error('Missing mic')\n }\n if (!third) {\n throw new Error('Missing currency')\n }\n return {\n type: 'BNE',\n isin: first,\n mic: second,\n currency: third,\n } satisfies BondExchangeId as BondExchangeId\n\n case 'BND':\n if (!first) {\n throw new Error('Missing isin')\n }\n if (!second) {\n throw new Error('Missing currency')\n }\n return {\n type: 'BND',\n isin: first,\n currency: second,\n } satisfies BondOTCId as BondOTCId\n\n case 'DER': {\n if (!first) {\n throw new Error('Missing ticker')\n }\n if (!second) {\n throw new Error('Missing mic')\n }\n if (!third) {\n throw new Error('Missing currency')\n }\n if (!fourth) {\n throw new Error('Missing strike')\n }\n if (!fifth) {\n throw new Error('Missing expiry')\n }\n return {\n type: 'DER',\n ticker: first,\n mic: second,\n currency: third,\n strike: fourth,\n expiry: fifth,\n } satisfies DerivativeId as DerivativeId\n }\n\n case 'ETF': {\n if (!first) {\n throw new Error('Missing isin')\n }\n if (!second) {\n throw new Error('Missing mic')\n }\n if (!third) {\n throw new Error('Missing currency')\n }\n return {\n type: 'ETF',\n isin: first,\n mic: second,\n currency: third,\n } satisfies ETFId as ETFId\n }\n\n case 'ETP': {\n if (!first) {\n throw new Error('Missing isin')\n }\n if (!second) {\n throw new Error('Missing mic')\n }\n if (!third) {\n throw new Error('Missing currency')\n }\n return {\n type: 'ETP',\n isin: first,\n mic: second,\n currency: third,\n } satisfies ETPId as ETPId\n }\n\n case 'FXS': {\n if (!first) {\n throw new Error('Missing baseCurrency')\n }\n if (!second) {\n throw new Error('Missing quoteCurrency')\n }\n return {\n type: 'FXS',\n baseCurrency: first,\n quoteCurrency: second,\n } satisfies ForexId as ForexId\n }\n\n case 'FND': {\n if (!first) {\n throw new Error('Missing isin')\n }\n if (!second) {\n throw new Error('Missing currency')\n }\n return {\n type: 'FND',\n isin: first,\n currency: second,\n } satisfies FundId as FundId\n }\n\n case 'IDX': {\n if (!first) {\n throw new Error('Missing ticker')\n }\n if (!second) {\n throw new Error('Missing currency')\n }\n return {\n type: 'IDX',\n ticker: first,\n currency: second,\n } satisfies IndexId as IndexId\n }\n\n case 'STO': {\n if (!first) {\n throw new Error('Missing isin')\n }\n if (!second) {\n throw new Error('Missing mic')\n }\n if (!third) {\n throw new Error('Missing currency')\n }\n return {\n type: 'STO',\n isin: first,\n mic: second,\n currency: third,\n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