@sebspark/tradeinsight 3.0.10 → 3.0.11
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.cjs +9 -0
- package/dist/index.cjs.map +1 -1
- package/dist/index.d.cts +12 -2
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.mts +12 -2
- package/dist/index.d.mts.map +1 -1
- package/dist/index.mjs +9 -1
- package/dist/index.mjs.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -101,6 +101,7 @@ const createStockId = ({ isin, mic, currency }) => `STOCK-${isin}_${mic}_${curre
|
|
|
101
101
|
*/
|
|
102
102
|
const createForexId = ({ quoteCurrency, baseCurrency }) => `FOREX-${baseCurrency}_${quoteCurrency}`.toUpperCase();
|
|
103
103
|
const createIndexId = ({ ticker }) => `INDEX-${ticker}`.toUpperCase();
|
|
104
|
+
const createFundId = ({ isin }) => `FUND-${isin}`.toUpperCase();
|
|
104
105
|
|
|
105
106
|
//#endregion
|
|
106
107
|
//#region src/instruments/parseId.ts
|
|
@@ -133,6 +134,13 @@ const parseId = (id) => {
|
|
|
133
134
|
ticker: first
|
|
134
135
|
};
|
|
135
136
|
}
|
|
137
|
+
if (type === "FUND") {
|
|
138
|
+
if (!first) throw new Error("Missing isin");
|
|
139
|
+
return {
|
|
140
|
+
type,
|
|
141
|
+
isin: first
|
|
142
|
+
};
|
|
143
|
+
}
|
|
136
144
|
throw new Error("Invalid type");
|
|
137
145
|
};
|
|
138
146
|
|
|
@@ -144,6 +152,7 @@ const TickersTopic = "tradeinsight.tickers";
|
|
|
144
152
|
exports.CloudSchema = CloudSchema;
|
|
145
153
|
exports.TickersTopic = TickersTopic;
|
|
146
154
|
exports.createForexId = createForexId;
|
|
155
|
+
exports.createFundId = createFundId;
|
|
147
156
|
exports.createIndexId = createIndexId;
|
|
148
157
|
exports.createStockId = createStockId;
|
|
149
158
|
exports.parseId = parseId;
|
package/dist/index.cjs.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.cjs","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","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\
|
|
1
|
+
{"version":3,"file":"index.cjs","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"}
|
package/dist/index.d.cts
CHANGED
|
@@ -54,6 +54,11 @@ declare const createIndexId: ({
|
|
|
54
54
|
}: {
|
|
55
55
|
ticker: string;
|
|
56
56
|
}) => string;
|
|
57
|
+
declare const createFundId: ({
|
|
58
|
+
isin
|
|
59
|
+
}: {
|
|
60
|
+
isin: string;
|
|
61
|
+
}) => string;
|
|
57
62
|
//#endregion
|
|
58
63
|
//#region src/instruments/parseId.d.ts
|
|
59
64
|
type StockId = {
|
|
@@ -71,7 +76,12 @@ type IndexId = {
|
|
|
71
76
|
type: 'INDEX';
|
|
72
77
|
ticker: string;
|
|
73
78
|
};
|
|
74
|
-
|
|
79
|
+
type FundId = {
|
|
80
|
+
type: 'FUND';
|
|
81
|
+
isin: string;
|
|
82
|
+
};
|
|
83
|
+
type TradeInsightId = StockId | ForexId | IndexId | FundId;
|
|
84
|
+
declare const parseId: (id: string) => TradeInsightId;
|
|
75
85
|
//#endregion
|
|
76
86
|
//#region src/pubsub/main.d.ts
|
|
77
87
|
declare const TickersTopic = "tradeinsight.tickers";
|
|
@@ -79,5 +89,5 @@ type TickersPubSubChannels = {
|
|
|
79
89
|
[TickersTopic]: TickerMessage;
|
|
80
90
|
};
|
|
81
91
|
//#endregion
|
|
82
|
-
export { CloudSchema, InstrumentPrice, Ticker, TickerMessage, TickersPubSubChannels, TickersTopic, createForexId, createIndexId, createStockId, parseId };
|
|
92
|
+
export { CloudSchema, InstrumentPrice, Ticker, TickerMessage, TickersPubSubChannels, TickersTopic, createForexId, createFundId, createIndexId, createStockId, parseId };
|
|
83
93
|
//# sourceMappingURL=index.d.cts.map
|
package/dist/index.d.cts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.cts","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,MAAA;EAAiB,IAAA,EAAA,MAAA;EAAA,MAAA,EAAA,MAAA;EAAA,YAAA,EAAA,MAAA;EAAA,KAAA,EDarB,eCbqB;AAqB9B;AAQa,UDbI,aAAA,CCaa;
|
|
1
|
+
{"version":3,"file":"index.d.cts","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,MAAA;EAAiB,IAAA,EAAA,MAAA;EAAA,MAAA,EAAA,MAAA;EAAA,YAAA,EAAA,MAAA;EAAA,KAAA,EDarB,eCbqB;AAqB9B;AAQa,UDbI,aAAA,CCaa;EAGjB,OAAA,EDfF,MCgBmB,EAAA;;cDbjB;;EEpBR,cAAO,EAAA,MAAA;AAAA,CAAA;;;cDAC;;;;ADoBb;EApBiB,IAAA,EAAA,MAAA;EAOA,QAAA,EAAM,MAAA;EASN,GAAA,EAAA,MAAA;AAIjB,CAAA,EAAA,GAAa,MAAA;;;;ACpBb;;;;;AAqBA;AAQA;AAGA;cAXa;;;;;;MCrBR,MAAA;AAOA,cDsBQ,aCtBD,EAAA,CAAA;EAAA;AAMA,CANA,EAAA;EAMP,MAAA,EAAA,MAAO;AAAA,CAAA,EAAA,GAKP,MAAA;AAKA,cDSQ,YCTM,EAAA,CAAA;EAAA;CAAA,EAAA;EAAG,IAAA,EAAA,MAAA;CAAU,EAAA,GAAA,MAAA;;;KAvB3B,OAAA;EFAY,IAAA,EAAA,OAAA;EAOA,IAAA,EAAA,MAAM;EASN,GAAA,EAAA,MAAA;EAIJ,QAAA,EAAA,MAoFZ;;KEjGI,OAAA;;EDPQ,YAAA,EAAA,MAQyC;EARxB,aAAA,EAAA,MAAA;CAAA;KCazB,OAAA,GDbyB;EAAA,IAAA,EAAA,OAAA;EAqBjB,MAAA,EAAA,MAAA;AAQb,CAAA;AAGA,KCdK,MAAA,GDcQ;;;;KCTR,cAAA,GAAiB,OAvBV,GAuBoB,OAvBpB,GAuB8B,OAvB9B,GAuBwC,MAvBxC;AAOP,cAkBQ,OAlBD,EAAA,CAAA,EAAA,EAAA,MAAA,EAAA,GAkByB,cAlBzB;;;AFPK,cGEJ,YAAA,GHFmB,sBAAA;AAOf,KGJL,qBAAA,GHUH;EAGQ,CGZd,YAAA,CHYc,EGZC,aHaP;AAGX,CAAA"}
|
package/dist/index.d.mts
CHANGED
|
@@ -54,6 +54,11 @@ declare const createIndexId: ({
|
|
|
54
54
|
}: {
|
|
55
55
|
ticker: string;
|
|
56
56
|
}) => string;
|
|
57
|
+
declare const createFundId: ({
|
|
58
|
+
isin
|
|
59
|
+
}: {
|
|
60
|
+
isin: string;
|
|
61
|
+
}) => string;
|
|
57
62
|
//#endregion
|
|
58
63
|
//#region src/instruments/parseId.d.ts
|
|
59
64
|
type StockId = {
|
|
@@ -71,7 +76,12 @@ type IndexId = {
|
|
|
71
76
|
type: 'INDEX';
|
|
72
77
|
ticker: string;
|
|
73
78
|
};
|
|
74
|
-
|
|
79
|
+
type FundId = {
|
|
80
|
+
type: 'FUND';
|
|
81
|
+
isin: string;
|
|
82
|
+
};
|
|
83
|
+
type TradeInsightId = StockId | ForexId | IndexId | FundId;
|
|
84
|
+
declare const parseId: (id: string) => TradeInsightId;
|
|
75
85
|
//#endregion
|
|
76
86
|
//#region src/pubsub/main.d.ts
|
|
77
87
|
declare const TickersTopic = "tradeinsight.tickers";
|
|
@@ -79,5 +89,5 @@ type TickersPubSubChannels = {
|
|
|
79
89
|
[TickersTopic]: TickerMessage;
|
|
80
90
|
};
|
|
81
91
|
//#endregion
|
|
82
|
-
export { CloudSchema, InstrumentPrice, Ticker, TickerMessage, TickersPubSubChannels, TickersTopic, createForexId, createIndexId, createStockId, parseId };
|
|
92
|
+
export { CloudSchema, InstrumentPrice, Ticker, TickerMessage, TickersPubSubChannels, TickersTopic, createForexId, createFundId, createIndexId, createStockId, parseId };
|
|
83
93
|
//# 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,MAAA;EAAiB,IAAA,EAAA,MAAA;EAAA,MAAA,EAAA,MAAA;EAAA,YAAA,EAAA,MAAA;EAAA,KAAA,EDarB,eCbqB;AAqB9B;AAQa,UDbI,aAAA,CCaa;
|
|
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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B,sBAAA;AAOf,KGJL,qBAAA,GHUH;EAGQ,CGZd,YAAA,CHYc,EGZC,aHaP;AAGX,CAAA"}
|
package/dist/index.mjs
CHANGED
|
@@ -100,6 +100,7 @@ const createStockId = ({ isin, mic, currency }) => `STOCK-${isin}_${mic}_${curre
|
|
|
100
100
|
*/
|
|
101
101
|
const createForexId = ({ quoteCurrency, baseCurrency }) => `FOREX-${baseCurrency}_${quoteCurrency}`.toUpperCase();
|
|
102
102
|
const createIndexId = ({ ticker }) => `INDEX-${ticker}`.toUpperCase();
|
|
103
|
+
const createFundId = ({ isin }) => `FUND-${isin}`.toUpperCase();
|
|
103
104
|
|
|
104
105
|
//#endregion
|
|
105
106
|
//#region src/instruments/parseId.ts
|
|
@@ -132,6 +133,13 @@ const parseId = (id) => {
|
|
|
132
133
|
ticker: first
|
|
133
134
|
};
|
|
134
135
|
}
|
|
136
|
+
if (type === "FUND") {
|
|
137
|
+
if (!first) throw new Error("Missing isin");
|
|
138
|
+
return {
|
|
139
|
+
type,
|
|
140
|
+
isin: first
|
|
141
|
+
};
|
|
142
|
+
}
|
|
135
143
|
throw new Error("Invalid type");
|
|
136
144
|
};
|
|
137
145
|
|
|
@@ -140,5 +148,5 @@ const parseId = (id) => {
|
|
|
140
148
|
const TickersTopic = "tradeinsight.tickers";
|
|
141
149
|
|
|
142
150
|
//#endregion
|
|
143
|
-
export { CloudSchema, TickersTopic, createForexId, createIndexId, createStockId, parseId };
|
|
151
|
+
export { CloudSchema, TickersTopic, createForexId, createFundId, createIndexId, createStockId, parseId };
|
|
144
152
|
//# 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","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\
|
|
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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