@tasenor/common-plugins 1.9.125 → 1.9.127
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/.turbo/turbo-build.log +1 -1
- package/.turbo/turbo-ci.log +2 -2
- package/data/TickerData.mjs +8 -0
- package/dist/AssetReport/backend/index.d.ts +2 -2
- package/dist/AssetReport/backend/index.js +17 -7
- package/dist/AssetReport/backend/index.js.map +1 -1
- package/dist/FinnishBalanceSheetReport/backend/index.d.ts +2 -2
- package/dist/FinnishBalanceSheetReport/backend/index.js +2 -2
- package/dist/FinnishBalanceSheetReport/backend/index.js.map +1 -1
- package/dist/FinnishBalanceSheetReportLite/backend/index.d.ts +2 -2
- package/dist/FinnishBalanceSheetReportLite/backend/index.js +2 -2
- package/dist/FinnishBalanceSheetReportLite/backend/index.js.map +1 -1
- package/dist/FinnishIncomeStatementReport/backend/index.d.ts +2 -2
- package/dist/FinnishIncomeStatementReport/backend/index.js +2 -2
- package/dist/FinnishIncomeStatementReport/backend/index.js.map +1 -1
- package/dist/FinnishIncomeStatementReportLite/backend/index.d.ts +2 -2
- package/dist/FinnishIncomeStatementReportLite/backend/index.js +2 -2
- package/dist/FinnishIncomeStatementReportLite/backend/index.js.map +1 -1
- package/dist/IncomeAndExpenses/backend/index.js +1 -1
- package/dist/IncomeAndExpenses/backend/index.js.map +1 -1
- package/dist/JournalReport/backend/index.d.ts +1 -1
- package/dist/JournalReport/backend/index.js +1 -1
- package/dist/JournalReport/backend/index.js.map +1 -1
- package/dist/LedgerReport/backend/index.d.ts +1 -1
- package/dist/LedgerReport/backend/index.js +1 -1
- package/dist/LedgerReport/backend/index.js.map +1 -1
- package/dist/TickerData/backend/index.d.ts +57 -0
- package/dist/TickerData/backend/index.js +212 -0
- package/dist/TickerData/backend/index.js.map +1 -0
- package/dist/VATFinland/backend/index.js +1 -1
- package/dist/VATFinland/backend/index.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +1 -0
- package/dist/index.js.map +1 -1
- package/package.json +7 -6
- package/src/AssetReport/backend/index.ts +19 -7
- package/src/FinnishBalanceSheetReport/backend/index.ts +2 -2
- package/src/FinnishBalanceSheetReportLite/backend/index.ts +2 -2
- package/src/FinnishIncomeStatementReport/backend/index.ts +2 -2
- package/src/FinnishIncomeStatementReportLite/backend/index.ts +2 -2
- package/src/IncomeAndExpenses/backend/index.ts +1 -1
- package/src/JournalReport/backend/index.ts +1 -1
- package/src/LedgerReport/backend/index.ts +1 -1
- package/src/TickerData/backend/cryptocurrencies.json +3762 -0
- package/src/TickerData/backend/currencies.json +181 -0
- package/src/TickerData/backend/etf.json +3339 -0
- package/src/TickerData/backend/hel.json +144 -0
- package/src/TickerData/backend/index.ts +241 -0
- package/src/TickerData/backend/nasdaq.json +505 -0
- package/src/TickerData/backend/nyse.json +514 -0
- package/src/TickerData/backend/otc.json +3 -0
- package/src/TickerData/backend/tal.json +36 -0
- package/src/TickerData/backend/tsx.json +421 -0
- package/src/TickerData/backend/xetra.json +15 -0
- package/src/VATFinland/backend/index.ts +1 -1
- package/src/index.ts +1 -0
|
@@ -0,0 +1,144 @@
|
|
|
1
|
+
{
|
|
2
|
+
"ACG1V": "Aspocomp Group Oyj",
|
|
3
|
+
"AFAGR": "Afarak Group",
|
|
4
|
+
"AKTIA": "Aktia Bank Abp",
|
|
5
|
+
"ALBAV": "Ålandsbanken Abp A",
|
|
6
|
+
"ALBBV": "Ålandsbanken Abp B",
|
|
7
|
+
"ALISA": "Alisa Pankki Oyj",
|
|
8
|
+
"ALMA": "Alma Media Oyj",
|
|
9
|
+
"ANORA": "Anora Group Oyj",
|
|
10
|
+
"APETIT": "Apetit Oyj",
|
|
11
|
+
"ASPO": "Aspo Oyj",
|
|
12
|
+
"ATRAV": "Atria Oyj A",
|
|
13
|
+
"BIOBV": "Biohit Oyj B",
|
|
14
|
+
"BITTI": "Bittium Oyj",
|
|
15
|
+
"BOREO": "Boreo Oyj",
|
|
16
|
+
"CAPMAN": "CapMan Oyj",
|
|
17
|
+
"CAV1V": "Caverion Oyj",
|
|
18
|
+
"CGCBV": "Cargotec Oyj",
|
|
19
|
+
"CONSTI": "Consti Oyj",
|
|
20
|
+
"CTH1V": "Componenta Oyj",
|
|
21
|
+
"CTY1S": "Citycon Oyj",
|
|
22
|
+
"DIGIA": "Digia Oyj",
|
|
23
|
+
"DIGIGR": "Digitalist Group Oyj",
|
|
24
|
+
"DOV1V": "Dovre Group Oyj",
|
|
25
|
+
"EEZY": "Eezy Oyj",
|
|
26
|
+
"ELEAV": "Elecster Oyj A",
|
|
27
|
+
"ELISA": "Elisa Oyj",
|
|
28
|
+
"ENENTO": "Enento Group Oyj",
|
|
29
|
+
"EQV1V": "eQ Oyj",
|
|
30
|
+
"ESENSE": "Enersense International Oyj",
|
|
31
|
+
"ETTE": "Etteplan Oyj",
|
|
32
|
+
"EVLI": "Evli Oyj",
|
|
33
|
+
"EXL1V": "Exel Composites Oyj",
|
|
34
|
+
"FIA1S": "Finnair Oyj",
|
|
35
|
+
"FORTUM": "Fortum Oyj",
|
|
36
|
+
"FSECURE": "F-Secure Oyj",
|
|
37
|
+
"FSKRS": "Fiskars Oyj Abp",
|
|
38
|
+
"GLA1V": "Glaston Oyj Abp",
|
|
39
|
+
"GOFORE": "Gofore Oyj",
|
|
40
|
+
"HARVIA": "Harvia Oyj",
|
|
41
|
+
"HKSAV": "HKScan Oyj A",
|
|
42
|
+
"HONBS": "Honkarakenne Oyj B",
|
|
43
|
+
"HUH1V": "Huhtamäki Oyj",
|
|
44
|
+
"ICP1V": "Incap Oyj",
|
|
45
|
+
"IFA1V": "Innofactor Plc",
|
|
46
|
+
"ILKKA2": "Ilkka Oyj 2",
|
|
47
|
+
"INVEST": "Investors House Oyj",
|
|
48
|
+
"KAMUX": "Kamux Oyj",
|
|
49
|
+
"KCR": "Konecranes Oyj",
|
|
50
|
+
"KELAS": "Kesla Oyj A",
|
|
51
|
+
"KEMIRA": "Kemira Oyj",
|
|
52
|
+
"KESKOA": "Kesko Oyj A",
|
|
53
|
+
"KESKOB": "Kesko Oyj B",
|
|
54
|
+
"KHG": "KH Group Oyj",
|
|
55
|
+
"KNEBV": "KONE Oyj",
|
|
56
|
+
"KOJAMO": "Kojamo Oyj",
|
|
57
|
+
"KOSKI": "Koskisen Oyj",
|
|
58
|
+
"KREATE": "Kreate Group Oyj",
|
|
59
|
+
"KSLAV": "Keskisuomalainen Oyj A",
|
|
60
|
+
"LAMOR": "Lamor Corporation Oyj",
|
|
61
|
+
"LAT1V": "Lassila & Tikanoja Oyj",
|
|
62
|
+
"LEHTO": "Lehto Group Oyj",
|
|
63
|
+
"MANTA": "Mandatum",
|
|
64
|
+
"MARAS": "Martela Oyj A",
|
|
65
|
+
"MEKKO": "Marimekko Oyj",
|
|
66
|
+
"METSA": "Metsä Board Oyj A",
|
|
67
|
+
"METSB": "Metsä Board Oyj B",
|
|
68
|
+
"METSO": "Metso Oyj",
|
|
69
|
+
"MUSTI": "Musti Group Oyj",
|
|
70
|
+
"NDA_FI": "Nordea Bank Abp",
|
|
71
|
+
"NESTE": "Neste Oyj",
|
|
72
|
+
"NLG1V": "Nurminen Logistics Oyj",
|
|
73
|
+
"NOHO": "NoHo Partners Oyj",
|
|
74
|
+
"NOKIA": "Nokia Oyj",
|
|
75
|
+
"OKDAV": "Oriola Oyj A",
|
|
76
|
+
"OKDBV": "Oriola Oyj B",
|
|
77
|
+
"OLVAS": "Olvi Oyj A",
|
|
78
|
+
"OMASP": "Oma Säästöpankki Oyj",
|
|
79
|
+
"OPTOMED": "Optomed Oyj",
|
|
80
|
+
"ORNAV": "Orion Oyj A",
|
|
81
|
+
"ORNBV": "Orion Oyj B",
|
|
82
|
+
"ORTHEX": "Orthex Oyj",
|
|
83
|
+
"OUT1V": "Outokumpu Oyj",
|
|
84
|
+
"OVARO": "Ovaro Kiinteistösijoitus Oyj",
|
|
85
|
+
"PAMPALO": "Endomines Finland Oyj",
|
|
86
|
+
"PIHLIS": "Pihlajalinna Oyj",
|
|
87
|
+
"PNA1V": "Panostaja Oyj",
|
|
88
|
+
"PON1V": "Ponsse Oyj 1",
|
|
89
|
+
"PUMU": "PunaMusta Media Oyj",
|
|
90
|
+
"PURMO": "Purmo Group Oyj C",
|
|
91
|
+
"PUUILO": "Puuilo Oyj",
|
|
92
|
+
"QPR1V": "QPR Software Oyj",
|
|
93
|
+
"QTCOM": "Qt Group Oyj",
|
|
94
|
+
"RAIVV": "Raisio Oyj Vaihto-osake",
|
|
95
|
+
"RAP1V": "Rapala VMC Oyj",
|
|
96
|
+
"RAUTE": "Raute Oyj",
|
|
97
|
+
"REG1V": "Revenio Group Oyj",
|
|
98
|
+
"REKA": "Reka Industrial Oyj",
|
|
99
|
+
"RELAIS": "Relais Group Oyj",
|
|
100
|
+
"REMEDY": "Remedy Entertainment Oyj",
|
|
101
|
+
"ROBIT": "Robit Oyj",
|
|
102
|
+
"ROVIO": "Rovio Entertainment Oyj",
|
|
103
|
+
"SAGCV": "Saga Furs Oyj C",
|
|
104
|
+
"SAMPO": "Sampo Oyj A",
|
|
105
|
+
"SANOMA": "Sanoma Oyj",
|
|
106
|
+
"SCANFL": "Scanfil Oyj",
|
|
107
|
+
"SIILI": "Siili Solutions Oyj",
|
|
108
|
+
"SITOWS": "Sitowise Group Oyj",
|
|
109
|
+
"SOLTEQ": "Solteq Oyj",
|
|
110
|
+
"SOSI1": "Sotkamo Silver AB",
|
|
111
|
+
"SRV1V": "SRV Yhtiöt Oyj",
|
|
112
|
+
"SSABAH": "SSAB A",
|
|
113
|
+
"SSABBH": "SSAB B",
|
|
114
|
+
"SSH1V": "SSH Communications Security",
|
|
115
|
+
"STEAV": "Stora Enso Oyj A",
|
|
116
|
+
"STERV": "Stora Enso Oyj R",
|
|
117
|
+
"STOCKA": "Stockmann Oyj Abp",
|
|
118
|
+
"SUY1V": "Suominen Oyj",
|
|
119
|
+
"TAALA": "Taaleri Oyj",
|
|
120
|
+
"TALLINK": "AS Tallink Grupp FDR",
|
|
121
|
+
"TELIA1": "Telia Company",
|
|
122
|
+
"TEM1V": "Tecnotree Oyj",
|
|
123
|
+
"TIETO": "TietoEVRY Oyj",
|
|
124
|
+
"TLT1V": "Teleste Oyj",
|
|
125
|
+
"TNOM": "Talenom Oyj",
|
|
126
|
+
"TOKMAN": "Tokmanni Group Oyj",
|
|
127
|
+
"TRH1V": "Trainers´ House Oyj",
|
|
128
|
+
"TTALO": "Terveystalo Oyj",
|
|
129
|
+
"TULAV": "Tulikivi Oyj A",
|
|
130
|
+
"TYRES": "Nokian Renkaat Oyj",
|
|
131
|
+
"UNITED": "United Bankers Oyj",
|
|
132
|
+
"UPM": "UPM-Kymmene Oyj",
|
|
133
|
+
"UPONOR": "Uponor Oyj",
|
|
134
|
+
"VAIAS": "Vaisala Oyj A",
|
|
135
|
+
"VALMT": "Valmet Oyj",
|
|
136
|
+
"VALOE": "Valoe Oyj",
|
|
137
|
+
"VERK": "Verkkokauppa.com Oyj",
|
|
138
|
+
"VIK1V": "Viking Line Abp",
|
|
139
|
+
"WETTERI": "Wetteri Oyj",
|
|
140
|
+
"WITH": "WithSecure Oyj",
|
|
141
|
+
"WRT1V": "Wärtsilä Oyj Abp",
|
|
142
|
+
"WUF1V": "Wulff-Yhtiöt Oyj",
|
|
143
|
+
"YIT": "YIT Oyj"
|
|
144
|
+
}
|
|
@@ -0,0 +1,241 @@
|
|
|
1
|
+
import { DataPlugin } from '@tasenor/common-node'
|
|
2
|
+
import { ALL, PluginCode, Version, error } from '@tasenor/common'
|
|
3
|
+
|
|
4
|
+
interface ExchangeInfo {
|
|
5
|
+
code: string
|
|
6
|
+
name: string
|
|
7
|
+
aliases: string[]
|
|
8
|
+
file: string
|
|
9
|
+
type: 'stock' | 'crypto' | 'currency'
|
|
10
|
+
}
|
|
11
|
+
|
|
12
|
+
interface TickerInfo {
|
|
13
|
+
exchange: Omit<Omit<ExchangeInfo, 'file'>, 'type'>
|
|
14
|
+
ticker: string
|
|
15
|
+
name: string
|
|
16
|
+
aliases: string[]
|
|
17
|
+
}
|
|
18
|
+
|
|
19
|
+
/**
|
|
20
|
+
* Data sets for stock tickers and crypto currencies.
|
|
21
|
+
*
|
|
22
|
+
* Backend Queries:
|
|
23
|
+
*
|
|
24
|
+
* * (*exchange*, ALL) - List of all known exhanges.
|
|
25
|
+
* * (*exchange*, *code*) - Exchange data if code, name or alias match, null otherwise.
|
|
26
|
+
* * (*ticker*, *type*:*code*) - Lookup from all exchanges the specific ticker of the given type.
|
|
27
|
+
* * (*ticker*, *type*:*exchange*:*code*) - Lookup from the given exchange the specific ticker.
|
|
28
|
+
*
|
|
29
|
+
* Data sources and/or ideas:
|
|
30
|
+
*
|
|
31
|
+
* * HEL - Manually constructed from public Nasdaq Helsinki data.
|
|
32
|
+
* * TAL - Manually constructed from public Nasdaq Helsinki data.
|
|
33
|
+
* * crypto - https://github.com/crypti/cryptocurrencies/blob/master/cryptocurrencies.json
|
|
34
|
+
*
|
|
35
|
+
* ...others done manually so far (need some source and conversion tool)...
|
|
36
|
+
*
|
|
37
|
+
* Note: there is useful tool to generate from CSV in `tasenor-bookkeeper/apps/cli/bin/convert-csv-to-map.mjs`.
|
|
38
|
+
*
|
|
39
|
+
* Data file is simply a mapping from ticker to its name. If the ticker has aliases, it can be expressed
|
|
40
|
+
* as an array like
|
|
41
|
+
* {
|
|
42
|
+
* ...
|
|
43
|
+
* "MAIN": ["Name of the main", "ALIAS1", "ALIAS2"]
|
|
44
|
+
* ...
|
|
45
|
+
* }
|
|
46
|
+
*/
|
|
47
|
+
class TickerData extends DataPlugin {
|
|
48
|
+
|
|
49
|
+
// TODO: Currency name data.
|
|
50
|
+
|
|
51
|
+
constructor() {
|
|
52
|
+
super({ common: [], backend: ['exchange', 'ticker'] })
|
|
53
|
+
|
|
54
|
+
this.code = 'TickerData'as PluginCode
|
|
55
|
+
this.title = 'Asset ticker names'
|
|
56
|
+
this.version = '1.0.0' as Version
|
|
57
|
+
this.icon = '<svg xmlns="http://www.w3.org/2000/svg" height="24px" viewBox="0 0 24 24" width="24px" fill="#000000"><path d="M0 0h24v24H0V0z" fill="none"/><path d="M16 7H5v10h11l3.55-5z" opacity=".3"/><path d="M17.63 5.84C17.27 5.33 16.67 5 16 5L5 5.01C3.9 5.01 3 5.9 3 7v10c0 1.1.9 1.99 2 1.99L16 19c.67 0 1.27-.33 1.63-.84L22 12l-4.37-6.16zM16 17H5V7h11l3.55 5L16 17z"/></svg>'
|
|
58
|
+
this.releaseDate = '2024-01-15'
|
|
59
|
+
this.use = 'backend'
|
|
60
|
+
this.type = 'data'
|
|
61
|
+
this.description = 'List of stock tickers and exchanges and their names. Lookup services for those.'
|
|
62
|
+
|
|
63
|
+
this.languages = {
|
|
64
|
+
}
|
|
65
|
+
}
|
|
66
|
+
|
|
67
|
+
async queryBackend<T>(dataSet: string, query: typeof ALL | string): Promise<undefined | T> {
|
|
68
|
+
if (dataSet === 'exchange') {
|
|
69
|
+
return this.queryExchange(query) as T
|
|
70
|
+
}
|
|
71
|
+
if (dataSet === 'ticker' && query !== ALL) {
|
|
72
|
+
return this.queryTicker(query) as T
|
|
73
|
+
}
|
|
74
|
+
return undefined
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
async queryExchange(query: typeof ALL | string): Promise<undefined | ExchangeInfo | ExchangeInfo[]> {
|
|
78
|
+
if (query === ALL) {
|
|
79
|
+
// This also priority order if there is no better knowledge for ticker exchange, when queried.
|
|
80
|
+
return [
|
|
81
|
+
{
|
|
82
|
+
code: 'ETF',
|
|
83
|
+
name: 'List of ETFs',
|
|
84
|
+
aliases: [],
|
|
85
|
+
file: 'etf.json',
|
|
86
|
+
type: 'stock'
|
|
87
|
+
},
|
|
88
|
+
{
|
|
89
|
+
code: 'NYSE',
|
|
90
|
+
name: 'New York Stock Exchange',
|
|
91
|
+
aliases: [],
|
|
92
|
+
file: 'nyse.json',
|
|
93
|
+
type: 'stock'
|
|
94
|
+
},
|
|
95
|
+
{
|
|
96
|
+
code: 'NASDAQ',
|
|
97
|
+
name: 'The Nasdaq Stock Market',
|
|
98
|
+
aliases: ['Nasdaq', 'National Association of Securities Dealers Automated Quotations'],
|
|
99
|
+
file: 'nasdaq.json',
|
|
100
|
+
type: 'stock'
|
|
101
|
+
},
|
|
102
|
+
{
|
|
103
|
+
code: 'XETRA',
|
|
104
|
+
name: 'Deutsche Börse',
|
|
105
|
+
aliases: [],
|
|
106
|
+
file: 'xetra.json',
|
|
107
|
+
type: 'stock'
|
|
108
|
+
},
|
|
109
|
+
{
|
|
110
|
+
code: 'HEL',
|
|
111
|
+
name: 'Nasdaq Helsinki',
|
|
112
|
+
aliases: ['HE'],
|
|
113
|
+
file: 'hel.json',
|
|
114
|
+
type: 'stock'
|
|
115
|
+
},
|
|
116
|
+
{
|
|
117
|
+
code: 'TAL',
|
|
118
|
+
name: 'Nasdaq Tallinn',
|
|
119
|
+
aliases: ['TL'],
|
|
120
|
+
file: 'tal.json',
|
|
121
|
+
type: 'stock'
|
|
122
|
+
},
|
|
123
|
+
{
|
|
124
|
+
code: 'OTC',
|
|
125
|
+
name: 'Over the Counter',
|
|
126
|
+
aliases: ['PINK', 'Pink Sheets'],
|
|
127
|
+
file: 'otc.json',
|
|
128
|
+
type: 'stock'
|
|
129
|
+
},
|
|
130
|
+
{
|
|
131
|
+
code: 'TSX',
|
|
132
|
+
name: 'Toronto Stock Exchange',
|
|
133
|
+
aliases: ['TO'],
|
|
134
|
+
file: 'tsx.json',
|
|
135
|
+
type: 'stock'
|
|
136
|
+
},
|
|
137
|
+
{
|
|
138
|
+
code: 'CRYPTO',
|
|
139
|
+
name: 'Crypto Currency',
|
|
140
|
+
aliases: [],
|
|
141
|
+
file: 'cryptocurrencies.json',
|
|
142
|
+
type: 'crypto'
|
|
143
|
+
},
|
|
144
|
+
{
|
|
145
|
+
code: 'CURRENCY',
|
|
146
|
+
name: 'Currency',
|
|
147
|
+
aliases: [],
|
|
148
|
+
file: 'currencies.json',
|
|
149
|
+
type: 'currency'
|
|
150
|
+
},
|
|
151
|
+
]
|
|
152
|
+
}
|
|
153
|
+
const all = await this.queryExchange(ALL) as ExchangeInfo[]
|
|
154
|
+
for (const ex of all) {
|
|
155
|
+
if (ex.code === query || ex.name === query || ex.aliases.includes(query)) {
|
|
156
|
+
return ex
|
|
157
|
+
}
|
|
158
|
+
}
|
|
159
|
+
return undefined
|
|
160
|
+
}
|
|
161
|
+
|
|
162
|
+
/**
|
|
163
|
+
* Fill in aliases.
|
|
164
|
+
*/
|
|
165
|
+
afterLoad<T>(fileName: string, data: Record<string, T>): Record<string, T> {
|
|
166
|
+
Object.keys(data).forEach(ticker => {
|
|
167
|
+
if (data[ticker] instanceof Array) {
|
|
168
|
+
for (const alias of (data[ticker] as Array<unknown>).splice(1)) {
|
|
169
|
+
if (data[`${alias}`] !== undefined) {
|
|
170
|
+
error(`${this.code}: Cannot re-use '${alias}' as an alias since it has already used as ${JSON.stringify(data[`${alias}`])}.`)
|
|
171
|
+
} else {
|
|
172
|
+
data[`${alias}`] = data[ticker][0]
|
|
173
|
+
}
|
|
174
|
+
}
|
|
175
|
+
data[ticker] = data[ticker][0]
|
|
176
|
+
}
|
|
177
|
+
})
|
|
178
|
+
|
|
179
|
+
return data
|
|
180
|
+
}
|
|
181
|
+
|
|
182
|
+
/**
|
|
183
|
+
* If the result is ambiquous, all results are returned.
|
|
184
|
+
*/
|
|
185
|
+
async queryTicker(query: string): Promise<undefined | TickerInfo[]> {
|
|
186
|
+
if (query.indexOf(':') < 0) {
|
|
187
|
+
error(`${this.code}: Invalid query '${query}' for plugin '${this.code}'.`)
|
|
188
|
+
return undefined
|
|
189
|
+
}
|
|
190
|
+
|
|
191
|
+
const parts = query.split(':')
|
|
192
|
+
const type = parts[0]
|
|
193
|
+
const exchange = parts.length >= 3 ? parts[1] : null
|
|
194
|
+
const ticker = parts.length >= 3 ? parts[2] : parts[1]
|
|
195
|
+
|
|
196
|
+
// Single exchange.
|
|
197
|
+
if (exchange !== null) {
|
|
198
|
+
const ex = await this.queryExchange(exchange) as ExchangeInfo | undefined
|
|
199
|
+
if (ex === undefined) {
|
|
200
|
+
return undefined
|
|
201
|
+
}
|
|
202
|
+
if (ex.type !== type) {
|
|
203
|
+
error(`${this.code}: Invalid type '${type}' when queried from exchange '${exchange}'.`)
|
|
204
|
+
return undefined
|
|
205
|
+
}
|
|
206
|
+
const tickers: Record<string, string> = this.loadCached(ex.file)
|
|
207
|
+
if (tickers[ticker] === undefined) {
|
|
208
|
+
return undefined
|
|
209
|
+
}
|
|
210
|
+
return [{
|
|
211
|
+
exchange: { code: ex.code, name: ex.name, aliases: ex.aliases },
|
|
212
|
+
ticker,
|
|
213
|
+
name: tickers[ticker],
|
|
214
|
+
aliases: []
|
|
215
|
+
}]
|
|
216
|
+
}
|
|
217
|
+
|
|
218
|
+
// Scan all exchanges.
|
|
219
|
+
let result: TickerInfo[] = []
|
|
220
|
+
let typeFound = false
|
|
221
|
+
for (const ex of await this.queryExchange(ALL) as ExchangeInfo[]) {
|
|
222
|
+
if (ex.type === type) {
|
|
223
|
+
typeFound = true
|
|
224
|
+
const match = await this.queryTicker(`${type}:${ex.code}:${ticker}`)
|
|
225
|
+
if (match !== undefined) {
|
|
226
|
+
result = result.concat(match)
|
|
227
|
+
}
|
|
228
|
+
}
|
|
229
|
+
}
|
|
230
|
+
if (result.length) {
|
|
231
|
+
return result
|
|
232
|
+
}
|
|
233
|
+
if (!typeFound) {
|
|
234
|
+
error(`${this.code}: Cannot find any exchange to provide data for type '${type}'.`)
|
|
235
|
+
}
|
|
236
|
+
|
|
237
|
+
return undefined
|
|
238
|
+
}
|
|
239
|
+
}
|
|
240
|
+
|
|
241
|
+
export default TickerData
|