@sebspark/tradeinsight 5.0.2 → 6.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -1 +1 @@
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;EAIjB,SAAA,EAAA,IAoFZ,GAAA,MAAA;;UAjGgB,MAAA;;ECPJ,GAAA,EAAA,MAUH;EAEE,IAAA,EAAA,MAAA;EAOA,MAAA,EAAA,MAAS;EAMT,YAAA,EAAA,MAAY;EASZ,KAAA,EDrBH,eCsBO;AAMhB;AAOY,UDhCK,aAAA,CCiCD;EAKJ,OAAA,EDrCD,MCqCO,EAAA;AAMlB;AAMY,cD9CC,WC+CQ,EAAA;EAMT,QAAA,EAAA,MAAA;EACR,cAAA,EAAA,MAAA;CACA;;;cA3ES;EDAI,SAAA,GAAA,EAAA,KAAe;EAOf,SAAM,GAAA,EAAA,KAAA;EASN,SAAA,GAAA,EAAA,KAAa;EAIjB,SAAA,GAAA,EAoFZ,KAAA;;;;ECxGY,SAUH,GAAA,EAAA,KAAA;EAEE,SAAA,GAAA,EAAA,KAAc;AAO1B,CAAA;AAMY,KAbA,cAAA,GAaY;EASZ,IAAA,EAAA,CAAA,OArBI,KAqBC,CACD,CAAA,KAAK,CAAA;EAMT,IAAA,EAAA,MAAK;EAOL,GAAA,EAAA,MAAO;EAMP,QAAA,EAAM,MAAA;AAMlB,CAAA;AAMY,KA/CA,SAAA,GA+CO;EAOP,IAAA,EAAA,CAAA,OArDI,KAqDU,CAAA,CAAA,KAAA,CAAA;EACtB,IAAA,EAAA,MAAA;EACA,QAAA,EAAA,M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EAAmB,IAAA;EAAA;AAAA,GAAoB,IAAA,CAAK,SAAA;AAAA,cAG5C,kBAAA;EAAsB,MAAA;EAAA,GAAA;EAAA,QAAA;EAAA,MAAA;EAAA;AAAA,GAMhC,IAAA,CAAK,YAAA;AAAA,cAGK,WAAA;EAAe,GAAA;EAAA,IAAA;EAAA;AAAA,GAAyB,IAAA,CAAK,KAAA;AAAA,cAG7C,WAAA;EAAe,GAAA;EAAA,IAAA;EAAA;AAAA,GAAyB,IAAA,CAAK,KAAA;AAAA,cAG7C,YAAA;EAAgB,IAAA;EAAA;AAAA,GAAoB,IAAA,CAAK,MAAA;AAAA,cAGzC,aAAA;EAAiB,MAAA;EAAA;AAAA,GAAsB,IAAA,CAAK,OAAA;AAAA,cAG5C,aAAA;EAAiB,aAAA;EAAA;AAAA,GAG3B,IAAA,CAAK,OAAA;AAAA,cAGK,aAAA;EAAiB,IAAA;EAAA,GAAA;EAAA;AAAA,GAAyB,IAAA,CAAK,OAAA;;;cCpC/C,OAAA,GAAW,EAAA,aAAa,cAAA;;;cCZxB,YAAA;AAAA,KACD,qBAAA;EAAA,CACT,YAAA,GAAe,aAAA;AAAA"}
package/dist/index.mjs CHANGED
@@ -108,7 +108,7 @@ const createETPId = ({ mic, isin, currency }) => `${types.ETP}_${isin}_${mic}_${
108
108
  const createFundId = ({ isin, currency }) => `${types.FND}_${isin}_${currency}`.toUpperCase();
109
109
  const createIndexId = ({ ticker, currency }) => `${types.IDX}_${ticker}_${currency}`.toUpperCase();
110
110
  const createForexId = ({ quoteCurrency, baseCurrency }) => `${types.FXS}_${baseCurrency}_${quoteCurrency}`.toUpperCase();
111
- const createStockId = ({ isin, mic, currency }) => `${types.STO}_${isin}_${mic}_${currency}`.toUpperCase();
111
+ const createStockId = ({ isin, mic, currency }) => `${types.STO}_${isin}_${currency}_${mic}`.toUpperCase();
112
112
 
113
113
  //#endregion
114
114
  //#region src/instruments/parseId.ts
@@ -193,13 +193,13 @@ const parseId = (id) => {
193
193
  };
194
194
  case "STO":
195
195
  if (!first) throw new Error("Missing isin");
196
- if (!second) throw new Error("Missing mic");
197
- if (!third) throw new Error("Missing currency");
196
+ if (!second) throw new Error("Missing currency");
197
+ if (!third) throw new Error("Missing mic");
198
198
  return {
199
199
  type: "STO",
200
200
  isin: first,
201
- mic: second,
202
- currency: third
201
+ mic: third,
202
+ currency: second
203
203
  };
204
204
  default: throw new Error("Invalid type");
205
205
  }
@@ -1 +1 @@
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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiFjB;;;;ACxGD,MAAa,QAAQ;CACnB,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACN;;;;ACGD,MAAa,wBAAwB,EACnC,MACA,KACA,eAEA,GAAG,MAAM,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,WAAW,aAAa;AAEzD,MAAa,mBAAmB,EAAE,MAAM,eACtC,GAAG,MAAM,IAAI,GAAG,KAAK,GAAG,WAAW,aAAa;AAElD,MAAa,sBAAsB,EACjC,QACA,KACA,UACA,QACA,aAEA,GAAG,MAAM,IAAI,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,aAAa;AAE/E,MAAa,eAAe,EAAE,KAAK,MAAM,eACvC,GAAG,MAAM,IAAI,GAAG,KAAK,GAA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L,UAAU;IACX;EAGH,QACE,OAAM,IAAI,MAAM,eAAe;;;;;;AC1KrC,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}_${currency}_${mic}`.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 currency')\n }\n if (!third) {\n throw new Error('Missing mic')\n }\n return {\n type: 'STO',\n isin: first,\n mic: third,\n currency: second,\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;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAiFjB;;;;ACxGD,MAAa,QAAQ;CACnB,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACL,KAAK;CACN;;;;ACGD,MAAa,wBAAwB,EACnC,MACA,KACA,eAEA,GAAG,MAAM,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,WAAW,aAAa;AAEzD,MAAa,mBAAmB,EAAE,MAAM,eACtC,GAAG,MAAM,IAAI,GAAG,KAAK,GAAG,WAAW,aAAa;AAElD,MAAa,sBAAsB,EACjC,QACA,KACA,UACA,QACA,aAEA,GAAG,MAAM,IAAI,GAAG,OAAO,GAAG,IAAI,GAAG,SAAS,GAAG,OAAO,GAAG,SAAS,aAAa;AAE/E,MAAa,eAAe,EAAE,KAAK,MAAM,eACvC,GAAG,MAAM,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,WAAW,aAAa;AAEzD,MAAa,eAAe,EAAE,KAAK,MAAM,eACvC,GAAG,MAAM,IAAI,GAAG,KAAK,GAAG,IAAI,GAAG,WAAW,aAAa;AAEzD,MAAa,gBAAgB,EAAE,MAAM,eACnC,GAAG,MAAM,IAAI,GAAG,KAAK,GA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IAAI,MAAM,cAAc;AAEhC,OAAI,CAAC,MACH,OAAM,IAAI,MAAM,mBAAmB;AAErC,UAAO;IACL,MAAM;IACN,MAAM;IACN,KAAK;IACL,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,KAAK;AACH,OAAI,CAAC,MACH,OAAM,IAAI,MAAM,uBAAuB;AAEzC,OAAI,CAAC,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,mBAAmB;AAErC,OAAI,CAAC,MACH,OAAM,IAAI,MAAM,cAAc;AAEhC,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": "5.0.2",
3
+ "version": "6.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "exports": {
@@ -23,9 +23,11 @@
23
23
  "typecheck": "vitest --typecheck.only --passWithNoTests"
24
24
  },
25
25
  "devDependencies": {
26
- "@sebspark/tsconfig": "3.0.5",
27
26
  "avro-typescript": "1.3.0",
28
- "ts-node": "10.9.2",
29
- "vitest": "4.0.16"
27
+ "ts-node": "10.9.2"
28
+ },
29
+ "repository": {
30
+ "type": "git",
31
+ "url": "https://github.com/seb-oss/Spark-packages.git"
30
32
  }
31
33
  }