@sebspark/tradeinsight 3.0.2 → 3.0.4

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.js CHANGED
@@ -149,3 +149,4 @@ export {
149
149
  createStockId,
150
150
  parseId
151
151
  };
152
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"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\nexport const parseId = (id: string): StockId | ForexId | IndexId => {\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 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":";AAoBO,IAAM,cAAc;AAAA,EACzB,UAAU;AAAA,EAEV,gBAAgB;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAAA;AAiFlB;;;ACxGO,IAAM,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AAAA,EACA;AACF,MAIM,SAAS,IAAI,IAAI,GAAG,IAAI,QAAQ,GAAG,YAAY;AAa9C,IAAM,gBAAgB,CAAC;AAAA,EAC5B;AAAA,EACA;AACF,MAGM,SAAS,YAAY,IAAI,aAAa,GAAG,YAAY;AAEpD,IAAM,gBAAgB,CAAC,EAAE,OAAO,MACrC,SAAS,MAAM,GAAG,YAAY;;;ACZzB,IAAM,UAAU,CAAC,OAA4C;AAClE,QAAM,CAAC,MAAM,GAAG,IAAI,IAAI,GAAG,MAAM,GAAG;AACpC,QAAM,CAAC,OAAO,QAAQ,KAAK,IAAI,KAAK,KAAK,EAAE,MAAM,GAAG;AAEpD,MAAI,SAAS,SAAS;AACpB,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,MAAM,aAAa;AAAA,IAC/B;AAEA,QAAI,CAAC,OAAO;AACV,YAAM,IAAI,MAAM,kBAAkB;AAAA,IACpC;AAEA,WAAO;AAAA,MACL;AAAA,MACA,MAAM;AAAA,MACN,KAAK;AAAA,MACL,UAAU;AAAA,IACZ;AAAA,EACF;AAEA,MAAI,SAAS,SAAS;AACpB,QAAI,CAAC,OAAO;AACV,YAAM,IAAI,MAAM,sBAAsB;AAAA,IACxC;AAEA,QAAI,CAAC,QAAQ;AACX,YAAM,IAAI,MAAM,uBAAuB;AAAA,IACzC;AAEA,WAAO;AAAA,MACL;AAAA,MACA,cAAc;AAAA,MACd,eAAe;AAAA,IACjB;AAAA,EACF;AAEA,MAAI,SAAS,SAAS;AACpB,QAAI,CAAC,OAAO;AACV,YAAM,IAAI,MAAM,gBAAgB;AAAA,IAClC;AAEA,WAAO;AAAA,MACL;AAAA,MACA,QAAQ;AAAA,IACV;AAAA,EACF;AAEA,QAAM,IAAI,MAAM,cAAc;AAChC;;;ACjEO,IAAM,eAAe;","names":[]}
package/package.json CHANGED
@@ -1,15 +1,22 @@
1
1
  {
2
2
  "name": "@sebspark/tradeinsight",
3
- "version": "3.0.2",
3
+ "version": "3.0.4",
4
4
  "license": "Apache-2.0",
5
5
  "type": "module",
6
6
  "main": "dist/index.js",
7
7
  "types": "dist/index.d.ts",
8
+ "exports": {
9
+ ".": {
10
+ "types": "./dist/index.d.ts",
11
+ "import": "./dist/index.js"
12
+ }
13
+ },
8
14
  "files": [
9
15
  "dist"
10
16
  ],
11
17
  "scripts": {
12
- "build": "tsup-node src/index.ts --format esm --target node22 --dts",
18
+ "build": "tsup src/index.ts --config ./tsup.config.ts",
19
+ "depcheck": "depcheck",
13
20
  "dev": "tsc --watch --noEmit",
14
21
  "generate:avro": "ts-node ./scripts/avro-to-ts.ts",
15
22
  "lint": "biome check .",
@@ -19,6 +26,8 @@
19
26
  "devDependencies": {
20
27
  "@sebspark/tsconfig": "*",
21
28
  "avro-typescript": "1.3.0",
22
- "ts-node": "10.9.2"
29
+ "ts-node": "10.9.2",
30
+ "tsup": "8.5.0",
31
+ "vitest": "4.0.6"
23
32
  }
24
33
  }