@sebspark/tradeinsight 0.5.0 → 1.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.
package/README.md CHANGED
@@ -1,3 +1,25 @@
1
1
  # `@sebspark/tradeinsight`
2
2
 
3
- Trade Insight client library with helpers for instrument IDs.
3
+ TradeInsight client library with helpers for creating/parsing instrument IDs and consuming ticker feeds.
4
+
5
+ ## Instrument IDs
6
+
7
+ ### Create ID
8
+
9
+ ```javascript
10
+ const isin = 'SE0000108656'
11
+ const mic = 'XSTO'
12
+ const currency = 'SEK'
13
+ const id = createStockId({ isin, mic, currency })
14
+
15
+ console.log(id)
16
+ // STOCK-SE0000108656;XSTO;SEK
17
+ ```
18
+
19
+ ### Parse ID
20
+
21
+ ```javascript
22
+ const { type, fromCurrency, toCurrency } = parseId('FOREX-USD;EUR')
23
+ console.log(type, fromCurrency, toCurrency)
24
+ // FOREX, USD, EUR
25
+ ```
package/dist/index.d.mts CHANGED
@@ -25,9 +25,20 @@ declare const createStockId: ({ isin, mic, currency, }: {
25
25
  currency: string;
26
26
  mic: string;
27
27
  }) => string;
28
- declare const createForexId: ({ fromCurrency, toCurrency, }: {
29
- toCurrency: string;
30
- fromCurrency: string;
28
+ /**
29
+ * Create an ID for a FOREX instrument, i.e. a currency relationship.
30
+ * The structure matches a currency pair:
31
+ *
32
+ * Base currency / quote currency = Exchange rate
33
+ *
34
+ * @see https://en.wikipedia.org/wiki/Currency_pair
35
+ * @example
36
+ * EUR/USD = 1.45
37
+ * This means a person would need 1.45 US dollars to purchase one Euro.
38
+ */
39
+ declare const createForexId: ({ quoteCurrency, baseCurrency, }: {
40
+ baseCurrency: string;
41
+ quoteCurrency: string;
31
42
  }) => string;
32
43
 
33
44
  declare const parseId: (id: string) => {
package/dist/index.d.ts CHANGED
@@ -25,9 +25,20 @@ declare const createStockId: ({ isin, mic, currency, }: {
25
25
  currency: string;
26
26
  mic: string;
27
27
  }) => string;
28
- declare const createForexId: ({ fromCurrency, toCurrency, }: {
29
- toCurrency: string;
30
- fromCurrency: string;
28
+ /**
29
+ * Create an ID for a FOREX instrument, i.e. a currency relationship.
30
+ * The structure matches a currency pair:
31
+ *
32
+ * Base currency / quote currency = Exchange rate
33
+ *
34
+ * @see https://en.wikipedia.org/wiki/Currency_pair
35
+ * @example
36
+ * EUR/USD = 1.45
37
+ * This means a person would need 1.45 US dollars to purchase one Euro.
38
+ */
39
+ declare const createForexId: ({ quoteCurrency, baseCurrency, }: {
40
+ baseCurrency: string;
41
+ quoteCurrency: string;
31
42
  }) => string;
32
43
 
33
44
  declare const parseId: (id: string) => {
package/dist/index.js CHANGED
@@ -121,9 +121,9 @@ var createStockId = ({
121
121
  currency
122
122
  }) => `STOCK-${isin};${mic};${currency}`.toUpperCase();
123
123
  var createForexId = ({
124
- fromCurrency,
125
- toCurrency
126
- }) => `FOREX-${toCurrency};${fromCurrency}`.toUpperCase();
124
+ quoteCurrency,
125
+ baseCurrency
126
+ }) => `FOREX-${baseCurrency};${quoteCurrency}`.toUpperCase();
127
127
 
128
128
  // src/instruments/parseId.ts
129
129
  var parseId = (id) => {
package/dist/index.mjs CHANGED
@@ -91,9 +91,9 @@ var createStockId = ({
91
91
  currency
92
92
  }) => `STOCK-${isin};${mic};${currency}`.toUpperCase();
93
93
  var createForexId = ({
94
- fromCurrency,
95
- toCurrency
96
- }) => `FOREX-${toCurrency};${fromCurrency}`.toUpperCase();
94
+ quoteCurrency,
95
+ baseCurrency
96
+ }) => `FOREX-${baseCurrency};${quoteCurrency}`.toUpperCase();
97
97
 
98
98
  // src/instruments/parseId.ts
99
99
  var parseId = (id) => {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@sebspark/tradeinsight",
3
- "version": "0.5.0",
3
+ "version": "1.0.0",
4
4
  "license": "Apache-2.0",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",