@fin.cx/opendata 3.5.0 → 3.6.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/{npmextra.json → .smartconfig.json} +12 -6
- package/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/classes.businessrecord.js +86 -43
- package/dist_ts/classes.handelsregister.d.ts +2 -0
- package/dist_ts/classes.handelsregister.js +126 -107
- package/dist_ts/classes.jsonldata.js +9 -6
- package/dist_ts/classes.main.opendata.d.ts +2 -1
- package/dist_ts/classes.main.opendata.js +59 -26
- package/dist_ts/index.d.ts +1 -0
- package/dist_ts/index.js +2 -1
- package/dist_ts/laws/classes.lawrecord.d.ts +24 -0
- package/dist_ts/laws/classes.lawrecord.js +181 -0
- package/dist_ts/laws/classes.lawservice.d.ts +52 -0
- package/dist_ts/laws/classes.lawservice.js +740 -0
- package/dist_ts/laws/index.d.ts +3 -0
- package/dist_ts/laws/index.js +4 -0
- package/dist_ts/laws/interfaces.law.d.ts +35 -0
- package/dist_ts/laws/interfaces.law.js +2 -0
- package/dist_ts/plugins.d.ts +8 -2
- package/dist_ts/plugins.js +14 -3
- package/dist_ts/stocks/classes.baseproviderservice.js +8 -8
- package/dist_ts/stocks/classes.fundamentalsservice.js +9 -9
- package/dist_ts/stocks/classes.stockdataservice.js +23 -23
- package/dist_ts/stocks/classes.stockservice.js +9 -9
- package/dist_ts/stocks/providers/provider.coingecko.d.ts +1 -1
- package/dist_ts/stocks/providers/provider.coingecko.js +45 -39
- package/dist_ts/stocks/providers/provider.marketstack.d.ts +3 -3
- package/dist_ts/stocks/providers/provider.marketstack.js +20 -16
- package/dist_ts/stocks/providers/provider.secedgar.d.ts +1 -1
- package/dist_ts/stocks/providers/provider.secedgar.js +22 -22
- package/dist_ts/stocks/providers/provider.yahoo.d.ts +2 -2
- package/dist_ts/stocks/providers/provider.yahoo.js +14 -13
- package/package.json +22 -19
- package/readme.md +280 -676
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/classes.businessrecord.ts +1 -1
- package/ts/classes.handelsregister.ts +45 -20
- package/ts/classes.jsonldata.ts +7 -6
- package/ts/classes.main.opendata.ts +63 -30
- package/ts/index.ts +1 -0
- package/ts/laws/classes.lawrecord.ts +81 -0
- package/ts/laws/classes.lawservice.ts +1010 -0
- package/ts/laws/index.ts +3 -0
- package/ts/laws/interfaces.law.ts +48 -0
- package/ts/plugins.ts +19 -0
- package/ts/stocks/classes.fundamentalsservice.ts +1 -1
- package/ts/stocks/classes.stockdataservice.ts +17 -7
- package/ts/stocks/classes.stockservice.ts +2 -2
- package/ts/stocks/providers/provider.marketstack.ts +9 -7
- package/ts/stocks/providers/provider.secedgar.ts +2 -2
- package/ts/stocks/providers/provider.yahoo.ts +3 -3
- package/dist_ts/classes.germanbusinessdata.d.ts +0 -9
- package/dist_ts/classes.germanbusinessdata.js +0 -78
- package/readme.plan.md +0 -193
package/ts/laws/index.ts
ADDED
|
@@ -0,0 +1,48 @@
|
|
|
1
|
+
export type TJurisdiction = 'de' | 'eu' | 'us';
|
|
2
|
+
|
|
3
|
+
export type TLawSource =
|
|
4
|
+
| 'gesetze-im-internet'
|
|
5
|
+
| 'eur-lex'
|
|
6
|
+
| 'law-cornell-lii'
|
|
7
|
+
| 'govinfo-plaw'
|
|
8
|
+
| 'govinfo-uscode';
|
|
9
|
+
|
|
10
|
+
export type TRawLawFormat = 'xml' | 'html' | 'text' | 'json';
|
|
11
|
+
|
|
12
|
+
export type TUsLawCollection = 'PLAW' | 'USCODE';
|
|
13
|
+
|
|
14
|
+
export interface ILawServiceConfig {
|
|
15
|
+
dbFolderPath?: string;
|
|
16
|
+
dbName?: string;
|
|
17
|
+
govInfoApiKey?: string;
|
|
18
|
+
}
|
|
19
|
+
|
|
20
|
+
export interface ILawLookupRequest {
|
|
21
|
+
jurisdiction: TJurisdiction;
|
|
22
|
+
identifier: string;
|
|
23
|
+
language?: string;
|
|
24
|
+
usCollection?: TUsLawCollection;
|
|
25
|
+
forceSync?: boolean;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
export interface ILawSyncRequest {
|
|
29
|
+
jurisdiction: TJurisdiction;
|
|
30
|
+
limit?: number;
|
|
31
|
+
offset?: number;
|
|
32
|
+
language?: string;
|
|
33
|
+
govInfoApiKey?: string;
|
|
34
|
+
usCollection?: TUsLawCollection;
|
|
35
|
+
since?: Date;
|
|
36
|
+
}
|
|
37
|
+
|
|
38
|
+
export interface ILawSearchRequest {
|
|
39
|
+
query: string;
|
|
40
|
+
jurisdiction?: TJurisdiction;
|
|
41
|
+
limit?: number;
|
|
42
|
+
}
|
|
43
|
+
|
|
44
|
+
export interface ILawSyncResult {
|
|
45
|
+
jurisdiction: TJurisdiction;
|
|
46
|
+
syncedCount: number;
|
|
47
|
+
identifiers: string[];
|
|
48
|
+
}
|
package/ts/plugins.ts
CHANGED
|
@@ -1,7 +1,9 @@
|
|
|
1
1
|
// node native scope
|
|
2
|
+
import * as fs from 'node:fs/promises';
|
|
2
3
|
import * as path from 'node:path';
|
|
3
4
|
|
|
4
5
|
export {
|
|
6
|
+
fs,
|
|
5
7
|
path,
|
|
6
8
|
}
|
|
7
9
|
|
|
@@ -14,23 +16,40 @@ import * as smartbrowser from '@push.rocks/smartbrowser';
|
|
|
14
16
|
import * as smartdata from '@push.rocks/smartdata';
|
|
15
17
|
import * as smartdelay from '@push.rocks/smartdelay';
|
|
16
18
|
import * as smartfile from '@push.rocks/smartfile';
|
|
19
|
+
import { SmartFs, SmartFsProviderNode } from '@push.rocks/smartfs';
|
|
17
20
|
import * as smartlog from '@push.rocks/smartlog';
|
|
18
21
|
import * as smartpath from '@push.rocks/smartpath';
|
|
19
22
|
import * as smartpromise from '@push.rocks/smartpromise';
|
|
20
23
|
import * as smartrequest from '@push.rocks/smartrequest';
|
|
24
|
+
import * as smartdb from '@push.rocks/smartdb';
|
|
21
25
|
import * as smartstream from '@push.rocks/smartstream';
|
|
22
26
|
import * as smartunique from '@push.rocks/smartunique';
|
|
23
27
|
import * as smartxml from '@push.rocks/smartxml';
|
|
24
28
|
|
|
29
|
+
const smartfs = new SmartFs(new SmartFsProviderNode());
|
|
30
|
+
const smartfileFactory = new smartfile.SmartFileFactory(smartfs);
|
|
31
|
+
|
|
32
|
+
const getErrorMessage = (error: unknown) => {
|
|
33
|
+
if (error instanceof Error) {
|
|
34
|
+
return error.message;
|
|
35
|
+
}
|
|
36
|
+
|
|
37
|
+
return String(error);
|
|
38
|
+
};
|
|
39
|
+
|
|
25
40
|
export {
|
|
41
|
+
getErrorMessage,
|
|
26
42
|
lik,
|
|
27
43
|
qenv,
|
|
28
44
|
smartarchive,
|
|
29
45
|
smartarray,
|
|
30
46
|
smartbrowser,
|
|
47
|
+
smartdb,
|
|
31
48
|
smartdata,
|
|
32
49
|
smartdelay,
|
|
33
50
|
smartfile,
|
|
51
|
+
smartfileFactory,
|
|
52
|
+
smartfs,
|
|
34
53
|
smartlog,
|
|
35
54
|
smartpath,
|
|
36
55
|
smartpromise,
|
|
@@ -166,7 +166,7 @@ export class FundamentalsService implements IFundamentalsProviderRegistry {
|
|
|
166
166
|
lastError = error as Error;
|
|
167
167
|
|
|
168
168
|
console.warn(
|
|
169
|
-
`Provider ${provider.name} failed for ${this.getRequestDescription(request)}: ${error
|
|
169
|
+
`Provider ${provider.name} failed for ${this.getRequestDescription(request)}: ${plugins.getErrorMessage(error)}`
|
|
170
170
|
);
|
|
171
171
|
}
|
|
172
172
|
}
|
|
@@ -32,7 +32,17 @@ export class StockDataService {
|
|
|
32
32
|
|
|
33
33
|
private logger = console;
|
|
34
34
|
|
|
35
|
-
private config:
|
|
35
|
+
private config: {
|
|
36
|
+
cache: {
|
|
37
|
+
priceTTL: number;
|
|
38
|
+
fundamentalsTTL: number;
|
|
39
|
+
maxEntries: number;
|
|
40
|
+
};
|
|
41
|
+
timeout: {
|
|
42
|
+
price: number;
|
|
43
|
+
fundamentals: number;
|
|
44
|
+
};
|
|
45
|
+
} = {
|
|
36
46
|
cache: {
|
|
37
47
|
priceTTL: 24 * 60 * 60 * 1000, // 24 hours
|
|
38
48
|
fundamentalsTTL: 90 * 24 * 60 * 60 * 1000, // 90 days
|
|
@@ -200,7 +210,7 @@ export class StockDataService {
|
|
|
200
210
|
entry.lastErrorTime = new Date();
|
|
201
211
|
lastError = error as Error;
|
|
202
212
|
|
|
203
|
-
console.warn(`Provider ${provider.name} failed for ${ticker}: ${error
|
|
213
|
+
console.warn(`Provider ${provider.name} failed for ${ticker}: ${plugins.getErrorMessage(error)}`);
|
|
204
214
|
}
|
|
205
215
|
}
|
|
206
216
|
|
|
@@ -250,7 +260,7 @@ export class StockDataService {
|
|
|
250
260
|
entry.lastErrorTime = new Date();
|
|
251
261
|
lastError = error as Error;
|
|
252
262
|
|
|
253
|
-
console.warn(`Provider ${provider.name} failed for batch prices: ${error
|
|
263
|
+
console.warn(`Provider ${provider.name} failed for batch prices: ${plugins.getErrorMessage(error)}`);
|
|
254
264
|
}
|
|
255
265
|
}
|
|
256
266
|
|
|
@@ -301,7 +311,7 @@ export class StockDataService {
|
|
|
301
311
|
entry.lastErrorTime = new Date();
|
|
302
312
|
lastError = error as Error;
|
|
303
313
|
|
|
304
|
-
console.warn(`Provider ${provider.name} failed for ${ticker} fundamentals: ${error
|
|
314
|
+
console.warn(`Provider ${provider.name} failed for ${ticker} fundamentals: ${plugins.getErrorMessage(error)}`);
|
|
305
315
|
}
|
|
306
316
|
}
|
|
307
317
|
|
|
@@ -352,7 +362,7 @@ export class StockDataService {
|
|
|
352
362
|
entry.lastErrorTime = new Date();
|
|
353
363
|
lastError = error as Error;
|
|
354
364
|
|
|
355
|
-
console.warn(`Provider ${provider.name} failed for batch fundamentals: ${error
|
|
365
|
+
console.warn(`Provider ${provider.name} failed for batch fundamentals: ${plugins.getErrorMessage(error)}`);
|
|
356
366
|
}
|
|
357
367
|
}
|
|
358
368
|
|
|
@@ -382,7 +392,7 @@ export class StockDataService {
|
|
|
382
392
|
fundamentals = this.enrichWithPrice(fundamentals, price.price);
|
|
383
393
|
}
|
|
384
394
|
} catch (error) {
|
|
385
|
-
console.warn(`Failed to fetch fundamentals for ${normalizedRequest.ticker}: ${error
|
|
395
|
+
console.warn(`Failed to fetch fundamentals for ${normalizedRequest.ticker}: ${plugins.getErrorMessage(error)}`);
|
|
386
396
|
// Continue without fundamentals
|
|
387
397
|
}
|
|
388
398
|
}
|
|
@@ -426,7 +436,7 @@ export class StockDataService {
|
|
|
426
436
|
fundamentalsMap = new Map(fundamentals.map(f => [f.ticker, f]));
|
|
427
437
|
}
|
|
428
438
|
} catch (error) {
|
|
429
|
-
console.warn(`Failed to fetch batch fundamentals: ${error
|
|
439
|
+
console.warn(`Failed to fetch batch fundamentals: ${plugins.getErrorMessage(error)}`);
|
|
430
440
|
// Continue without fundamentals
|
|
431
441
|
}
|
|
432
442
|
}
|
|
@@ -205,7 +205,7 @@ export class StockPriceService implements IProviderRegistry {
|
|
|
205
205
|
lastError = error as Error;
|
|
206
206
|
|
|
207
207
|
console.warn(
|
|
208
|
-
`Provider ${provider.name} failed for ${this.getRequestDescription(request)}: ${error
|
|
208
|
+
`Provider ${provider.name} failed for ${this.getRequestDescription(request)}: ${plugins.getErrorMessage(error)}`
|
|
209
209
|
);
|
|
210
210
|
}
|
|
211
211
|
}
|
|
@@ -522,4 +522,4 @@ export class StockPriceService implements IProviderRegistry {
|
|
|
522
522
|
ttl: ttl || this.cacheConfig.ttl
|
|
523
523
|
});
|
|
524
524
|
}
|
|
525
|
-
}
|
|
525
|
+
}
|
|
@@ -45,7 +45,7 @@ export class MarketstackProvider implements IStockProvider {
|
|
|
45
45
|
public priority = 90; // Increased from 80 - now supports real-time intraday data during market hours
|
|
46
46
|
public readonly requiresAuth = true;
|
|
47
47
|
public readonly rateLimit = {
|
|
48
|
-
requestsPerMinute:
|
|
48
|
+
requestsPerMinute: 0, // No per-minute limit specified
|
|
49
49
|
requestsPerDay: undefined // Varies by plan
|
|
50
50
|
};
|
|
51
51
|
|
|
@@ -99,8 +99,9 @@ export class MarketstackProvider implements IStockProvider {
|
|
|
99
99
|
}
|
|
100
100
|
} catch (error) {
|
|
101
101
|
// If intraday fails, fallback to EOD with warning
|
|
102
|
-
|
|
103
|
-
|
|
102
|
+
const errorMessage = plugins.getErrorMessage(error);
|
|
103
|
+
if (errorMessage.includes('intraday') || errorMessage.includes('Marketstack API error')) {
|
|
104
|
+
this.logger.warn(`Intraday endpoint failed for ${request.ticker}, falling back to EOD:`, errorMessage);
|
|
104
105
|
try {
|
|
105
106
|
return await this.fetchCurrentPriceEod(request);
|
|
106
107
|
} catch (eodError) {
|
|
@@ -245,7 +246,7 @@ export class MarketstackProvider implements IStockProvider {
|
|
|
245
246
|
return allPrices;
|
|
246
247
|
} catch (error) {
|
|
247
248
|
this.logger.error(`Failed to fetch historical prices for ${request.ticker}:`, error);
|
|
248
|
-
throw new Error(`Marketstack: Failed to fetch historical prices for ${request.ticker}: ${error
|
|
249
|
+
throw new Error(`Marketstack: Failed to fetch historical prices for ${request.ticker}: ${plugins.getErrorMessage(error)}`);
|
|
249
250
|
}
|
|
250
251
|
}
|
|
251
252
|
|
|
@@ -337,7 +338,7 @@ export class MarketstackProvider implements IStockProvider {
|
|
|
337
338
|
return allPrices;
|
|
338
339
|
} catch (error) {
|
|
339
340
|
this.logger.error(`Failed to fetch intraday prices for ${request.ticker}:`, error);
|
|
340
|
-
throw new Error(`Marketstack: Failed to fetch intraday prices for ${request.ticker}: ${error
|
|
341
|
+
throw new Error(`Marketstack: Failed to fetch intraday prices for ${request.ticker}: ${plugins.getErrorMessage(error)}`);
|
|
341
342
|
}
|
|
342
343
|
}
|
|
343
344
|
|
|
@@ -359,8 +360,9 @@ export class MarketstackProvider implements IStockProvider {
|
|
|
359
360
|
}
|
|
360
361
|
} catch (error) {
|
|
361
362
|
// Fallback to EOD if intraday fails
|
|
362
|
-
|
|
363
|
-
|
|
363
|
+
const errorMessage = plugins.getErrorMessage(error);
|
|
364
|
+
if (errorMessage.includes('intraday') || errorMessage.includes('Marketstack API error')) {
|
|
365
|
+
this.logger.warn(`Intraday batch endpoint failed, falling back to EOD:`, errorMessage);
|
|
364
366
|
try {
|
|
365
367
|
return await this.fetchBatchCurrentPricesEod(request);
|
|
366
368
|
} catch (eodError) {
|
|
@@ -141,7 +141,7 @@ export class SecEdgarProvider implements IFundamentalsProvider {
|
|
|
141
141
|
return this.parseCompanyFacts(request.ticker, cik, companyFacts);
|
|
142
142
|
} catch (error) {
|
|
143
143
|
this.logger.error(`Failed to fetch fundamentals for ${request.ticker}:`, error);
|
|
144
|
-
throw new Error(`SEC EDGAR: Failed to fetch fundamentals for ${request.ticker}: ${error
|
|
144
|
+
throw new Error(`SEC EDGAR: Failed to fetch fundamentals for ${request.ticker}: ${plugins.getErrorMessage(error)}`);
|
|
145
145
|
}
|
|
146
146
|
}
|
|
147
147
|
|
|
@@ -163,7 +163,7 @@ export class SecEdgarProvider implements IFundamentalsProvider {
|
|
|
163
163
|
results.push(fundamentals);
|
|
164
164
|
} catch (error) {
|
|
165
165
|
this.logger.warn(`Failed to fetch fundamentals for ${ticker}:`, error);
|
|
166
|
-
errors.push(`${ticker}: ${error
|
|
166
|
+
errors.push(`${ticker}: ${plugins.getErrorMessage(error)}`);
|
|
167
167
|
// Continue with other tickers
|
|
168
168
|
}
|
|
169
169
|
}
|
|
@@ -86,7 +86,7 @@ export class YahooFinanceProvider implements IStockProvider {
|
|
|
86
86
|
return stockPrice;
|
|
87
87
|
} catch (error) {
|
|
88
88
|
console.error(`Failed to fetch price for ${request.ticker}:`, error);
|
|
89
|
-
throw new Error(`Yahoo Finance: Failed to fetch price for ${request.ticker}: ${error
|
|
89
|
+
throw new Error(`Yahoo Finance: Failed to fetch price for ${request.ticker}: ${plugins.getErrorMessage(error)}`);
|
|
90
90
|
}
|
|
91
91
|
}
|
|
92
92
|
|
|
@@ -145,7 +145,7 @@ export class YahooFinanceProvider implements IStockProvider {
|
|
|
145
145
|
return prices;
|
|
146
146
|
} catch (error) {
|
|
147
147
|
console.error(`Failed to fetch batch prices:`, error);
|
|
148
|
-
throw new Error(`Yahoo Finance: Failed to fetch batch prices: ${error
|
|
148
|
+
throw new Error(`Yahoo Finance: Failed to fetch batch prices: ${plugins.getErrorMessage(error)}`);
|
|
149
149
|
}
|
|
150
150
|
}
|
|
151
151
|
|
|
@@ -191,4 +191,4 @@ export class YahooFinanceProvider implements IStockProvider {
|
|
|
191
191
|
return timeDiff > 3600 ? 'CLOSED' : 'REGULAR';
|
|
192
192
|
}
|
|
193
193
|
}
|
|
194
|
-
}
|
|
194
|
+
}
|
|
@@ -1,9 +0,0 @@
|
|
|
1
|
-
import type { OpenData } from './classes.main.opendata.js';
|
|
2
|
-
export declare class GermanBusinessData {
|
|
3
|
-
openDataRef: OpenData;
|
|
4
|
-
constructor(openDataRefArg: OpenData);
|
|
5
|
-
start(): Promise<void>;
|
|
6
|
-
stop(): Promise<void>;
|
|
7
|
-
update(): Promise<void>;
|
|
8
|
-
getBusinessRecordByName(nameArg: string): Promise<import("./classes.businessrecord.js").BusinessRecord>;
|
|
9
|
-
}
|
|
@@ -1,78 +0,0 @@
|
|
|
1
|
-
import * as plugins from './plugins.js';
|
|
2
|
-
import * as paths from './paths.js';
|
|
3
|
-
export class GermanBusinessData {
|
|
4
|
-
constructor(openDataRefArg) {
|
|
5
|
-
this.openDataRef = openDataRefArg;
|
|
6
|
-
}
|
|
7
|
-
async start() {
|
|
8
|
-
await this.update();
|
|
9
|
-
}
|
|
10
|
-
async stop() { }
|
|
11
|
-
async update() {
|
|
12
|
-
const done = plugins.smartpromise.defer();
|
|
13
|
-
const promiseArray = [];
|
|
14
|
-
const dataUrl = 'https://daten.offeneregister.de/de_companies_ocdata.jsonl.bz2';
|
|
15
|
-
const dataExists = await plugins.smartfile.fs.isDirectory(paths.germanBusinessDataDir);
|
|
16
|
-
if (!dataExists) {
|
|
17
|
-
await plugins.smartfile.fs.ensureDir(paths.germanBusinessDataDir);
|
|
18
|
-
}
|
|
19
|
-
else {
|
|
20
|
-
}
|
|
21
|
-
const smartarchive = await plugins.smartarchive.SmartArchive.fromArchiveUrl(dataUrl);
|
|
22
|
-
promiseArray
|
|
23
|
-
.push();
|
|
24
|
-
const jsonlDataStream = await smartarchive.exportToStreamOfStreamFiles();
|
|
25
|
-
let totalRecordsCounter = 0;
|
|
26
|
-
let nextRest = '';
|
|
27
|
-
jsonlDataStream.pipe(new plugins.smartstream.SmartDuplex({
|
|
28
|
-
objectMode: true,
|
|
29
|
-
writeFunction: async (chunkArg, streamToolsArg) => {
|
|
30
|
-
const readStream = await chunkArg.createReadStream();
|
|
31
|
-
readStream.pipe(new plugins.smartstream.SmartDuplex({
|
|
32
|
-
objectMode: true,
|
|
33
|
-
writeFunction: async (chunkArg, streamToolsArg) => {
|
|
34
|
-
const currentString = nextRest + chunkArg.toString();
|
|
35
|
-
const lines = currentString.split('\n');
|
|
36
|
-
nextRest = lines.pop();
|
|
37
|
-
console.log(`Got another ${lines.length} records.`);
|
|
38
|
-
for (const line of lines) {
|
|
39
|
-
let entry;
|
|
40
|
-
if (!line)
|
|
41
|
-
continue;
|
|
42
|
-
try {
|
|
43
|
-
entry = JSON.parse(line);
|
|
44
|
-
}
|
|
45
|
-
catch (err) {
|
|
46
|
-
console.log(line);
|
|
47
|
-
await plugins.smartdelay.delayFor(10000);
|
|
48
|
-
}
|
|
49
|
-
if (!entry)
|
|
50
|
-
continue;
|
|
51
|
-
totalRecordsCounter++;
|
|
52
|
-
if (totalRecordsCounter % 10000 === 0)
|
|
53
|
-
console.log(`${totalRecordsCounter} total records.`);
|
|
54
|
-
const businessRecord = new this.openDataRef.CBusinessRecord();
|
|
55
|
-
businessRecord.data.name = entry.name;
|
|
56
|
-
await businessRecord.save();
|
|
57
|
-
// console.log(`stored ${businessRecord.data.name}`);
|
|
58
|
-
}
|
|
59
|
-
},
|
|
60
|
-
finalFunction: async (streamToolsArg) => {
|
|
61
|
-
if (!nextRest)
|
|
62
|
-
return;
|
|
63
|
-
JSON.parse(nextRest);
|
|
64
|
-
}
|
|
65
|
-
}));
|
|
66
|
-
},
|
|
67
|
-
}));
|
|
68
|
-
}
|
|
69
|
-
async getBusinessRecordByName(nameArg) {
|
|
70
|
-
const businessRecord = await this.openDataRef.CBusinessRecord.getInstance({
|
|
71
|
-
data: {
|
|
72
|
-
name: { $regex: `${nameArg}`, $options: "i" },
|
|
73
|
-
}
|
|
74
|
-
});
|
|
75
|
-
return businessRecord;
|
|
76
|
-
}
|
|
77
|
-
}
|
|
78
|
-
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiY2xhc3Nlcy5nZXJtYW5idXNpbmVzc2RhdGEuanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi90cy9jbGFzc2VzLmdlcm1hbmJ1c2luZXNzZGF0YS50cyJdLCJuYW1lcyI6W10sIm1hcHBpbmdzIjoiQUFBQSxPQUFPLEtBQUssT0FBTyxNQUFNLGNBQWMsQ0FBQztBQUN4QyxPQUFPLEtBQUssS0FBSyxNQUFNLFlBQVksQ0FBQztBQUdwQyxNQUFNLE9BQU8sa0JBQWtCO0lBRTdCLFlBQVksY0FBd0I7UUFDbEMsSUFBSSxDQUFDLFdBQVcsR0FBRyxjQUFjLENBQUM7SUFDcEMsQ0FBQztJQUVNLEtBQUssQ0FBQyxLQUFLO1FBQ2hCLE1BQU0sSUFBSSxDQUFDLE1BQU0sRUFBRSxDQUFDO0lBQ3RCLENBQUM7SUFDTSxLQUFLLENBQUMsSUFBSSxLQUFJLENBQUM7SUFFZixLQUFLLENBQUMsTUFBTTtRQUNqQixNQUFNLElBQUksR0FBRyxPQUFPLENBQUMsWUFBWSxDQUFDLEtBQUssRUFBRSxDQUFDO1FBQzFDLE1BQU0sWUFBWSxHQUFtQixFQUFFLENBQUM7UUFDeEMsTUFBTSxPQUFPLEdBQUcsK0RBQStELENBQUM7UUFDaEYsTUFBTSxVQUFVLEdBQUcsTUFBTSxPQUFPLENBQUMsU0FBUyxDQUFDL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M7b0JBQ0QsYUFBYSxFQUFFLEtBQUssRUFBRSxjQUFjLEVBQUUsRUFBRTt3QkFDdEMsSUFBSSxDQUFDLFFBQVE7NEJBQUUsT0FBTzt3QkFDdEIsSUFBSSxDQUFDLEtBQUssQ0FBQyxRQUFRLENBQUMsQ0FBQztvQkFDdkIsQ0FBQztpQkFDRixDQUFDLENBQ0gsQ0FBQztZQUNKLENBQUM7U0FDRixDQUFDLENBQ0gsQ0FBQztJQUNKLENBQUM7SUFFTSxLQUFLLENBQUMsdUJBQXVCLENBQUMsT0FBZTtRQUNsRCxNQUFNLGNBQWMsR0FBRyxNQUFNLElBQUksQ0FBQyxXQUFXLENBQUMsZUFBZSxDQUFDLFdBQVcsQ0FBQztZQUN4RSxJQUFJLEVBQUU7Z0JBQ0osSUFBSSxFQUFFLEVBQUUsTUFBTSxFQUFFLEdBQUcsT0FBTyxFQUFFLEVBQUUsUUFBUSxFQUFFLEdBQUcsRUFBUzthQUNyRDtTQUNGLENBQUMsQ0FBQztRQUNILE9BQU8sY0FBYyxDQUFDO0lBQ3hCLENBQUM7Q0FDRiJ9
|
package/readme.plan.md
DELETED
|
@@ -1,193 +0,0 @@
|
|
|
1
|
-
# Stock Prices Module Implementation Plan
|
|
2
|
-
|
|
3
|
-
Command to reread guidelines: Read /home/philkunz/.claude/CLAUDE.md
|
|
4
|
-
|
|
5
|
-
## Overview
|
|
6
|
-
Implementation of a stocks module for fetching current stock prices using various APIs. The architecture will support multiple providers, but we'll start with implementing only Yahoo Finance API. The design will make it easy to add additional providers (Alpha Vantage, IEX Cloud, etc.) in the future without changing the core architecture.
|
|
7
|
-
|
|
8
|
-
## Phase 1: Yahoo Finance Implementation
|
|
9
|
-
|
|
10
|
-
### 1.1 Research & Documentation
|
|
11
|
-
- [ ] Research Yahoo Finance API endpoints (no official API, using public endpoints)
|
|
12
|
-
- [ ] Document available data fields and formats
|
|
13
|
-
- [ ] Identify rate limits and restrictions
|
|
14
|
-
- [ ] Test endpoints manually with curl
|
|
15
|
-
|
|
16
|
-
### 1.2 Module Structure
|
|
17
|
-
```
|
|
18
|
-
ts/
|
|
19
|
-
├── index.ts # Main exports
|
|
20
|
-
├── plugins.ts # External dependencies
|
|
21
|
-
└── stocks/
|
|
22
|
-
├── index.ts # Stocks module exports
|
|
23
|
-
├── classes.stockservice.ts # Main StockPriceService class
|
|
24
|
-
├── interfaces/
|
|
25
|
-
│ ├── stockprice.ts # IStockPrice interface
|
|
26
|
-
│ └── provider.ts # IStockProvider interface (for all providers)
|
|
27
|
-
└── providers/
|
|
28
|
-
├── provider.yahoo.ts # Yahoo Finance implementation
|
|
29
|
-
└── (future: provider.alphavantage.ts, provider.iex.ts, etc.)
|
|
30
|
-
```
|
|
31
|
-
|
|
32
|
-
### 1.3 Core Interfaces
|
|
33
|
-
```typescript
|
|
34
|
-
// IStockPrice - Standardized stock price data
|
|
35
|
-
interface IStockPrice {
|
|
36
|
-
ticker: string;
|
|
37
|
-
price: number;
|
|
38
|
-
currency: string;
|
|
39
|
-
change: number;
|
|
40
|
-
changePercent: number;
|
|
41
|
-
timestamp: Date;
|
|
42
|
-
provider: string;
|
|
43
|
-
}
|
|
44
|
-
|
|
45
|
-
// IStockProvider - Provider implementation contract
|
|
46
|
-
interface IStockProvider {
|
|
47
|
-
name: string;
|
|
48
|
-
fetchPrice(ticker: string): Promise<IStockPrice>;
|
|
49
|
-
fetchPrices(tickers: string[]): Promise<IStockPrice[]>;
|
|
50
|
-
isAvailable(): Promise<boolean>;
|
|
51
|
-
}
|
|
52
|
-
```
|
|
53
|
-
|
|
54
|
-
### 1.4 Yahoo Finance Provider Implementation
|
|
55
|
-
- [ ] Create YahooFinanceProvider class
|
|
56
|
-
- [ ] Implement HTTP requests to Yahoo Finance endpoints
|
|
57
|
-
- [ ] Parse response data into IStockPrice format
|
|
58
|
-
- [ ] Handle errors and edge cases
|
|
59
|
-
- [ ] Add request throttling/rate limiting
|
|
60
|
-
|
|
61
|
-
### 1.5 Main Service Class
|
|
62
|
-
- [ ] Create StockPriceService class with provider registry
|
|
63
|
-
- [ ] Implement provider interface for pluggable providers
|
|
64
|
-
- [ ] Register Yahoo provider (with ability to add more later)
|
|
65
|
-
- [ ] Add method for single ticker lookup
|
|
66
|
-
- [ ] Add method for batch ticker lookup
|
|
67
|
-
- [ ] Implement error handling with graceful degradation
|
|
68
|
-
- [ ] Design fallback mechanism (ready for multiple providers)
|
|
69
|
-
|
|
70
|
-
## Phase 2: Core Features
|
|
71
|
-
|
|
72
|
-
### 2.1 Service Architecture
|
|
73
|
-
- [ ] Create provider registry pattern for managing multiple providers
|
|
74
|
-
- [ ] Implement provider priority and selection logic
|
|
75
|
-
- [ ] Design provider health check interface
|
|
76
|
-
- [ ] Create provider configuration system
|
|
77
|
-
- [ ] Implement provider discovery mechanism
|
|
78
|
-
- [ ] Add provider capability querying (which tickers/markets supported)
|
|
79
|
-
|
|
80
|
-
## Phase 3: Advanced Features
|
|
81
|
-
|
|
82
|
-
### 3.1 Caching System
|
|
83
|
-
- [ ] Design cache interface
|
|
84
|
-
- [ ] Implement in-memory cache with TTL
|
|
85
|
-
- [ ] Add cache invalidation logic
|
|
86
|
-
- [ ] Make cache configurable per ticker
|
|
87
|
-
|
|
88
|
-
### 3.2 Configuration
|
|
89
|
-
- [ ] Provider configuration (timeout, retry settings)
|
|
90
|
-
- [ ] Cache configuration (TTL, max entries)
|
|
91
|
-
- [ ] Request timeout configuration
|
|
92
|
-
- [ ] Error handling configuration
|
|
93
|
-
|
|
94
|
-
### 3.3 Error Handling
|
|
95
|
-
- [ ] Define custom error types
|
|
96
|
-
- [ ] Implement retry logic with exponential backoff
|
|
97
|
-
- [ ] Add circuit breaker pattern for failing providers
|
|
98
|
-
- [ ] Comprehensive error logging
|
|
99
|
-
|
|
100
|
-
## Phase 4: Testing
|
|
101
|
-
|
|
102
|
-
### 4.1 Unit Tests
|
|
103
|
-
- [ ] Test each provider independently
|
|
104
|
-
- [ ] Mock HTTP requests for predictable testing
|
|
105
|
-
- [ ] Test error scenarios
|
|
106
|
-
- [ ] Test data transformation logic
|
|
107
|
-
|
|
108
|
-
### 4.2 Integration Tests
|
|
109
|
-
- [ ] Test with real API calls (rate limit aware)
|
|
110
|
-
- [ ] Test provider fallback scenarios
|
|
111
|
-
- [ ] Test batch operations
|
|
112
|
-
- [ ] Test cache behavior
|
|
113
|
-
|
|
114
|
-
### 4.3 Performance Tests
|
|
115
|
-
- [ ] Measure response times
|
|
116
|
-
- [ ] Test concurrent request handling
|
|
117
|
-
- [ ] Validate cache effectiveness
|
|
118
|
-
|
|
119
|
-
## Implementation Order
|
|
120
|
-
|
|
121
|
-
1. **Week 1: Yahoo Finance Provider**
|
|
122
|
-
- Research and test Yahoo endpoints
|
|
123
|
-
- Implement basic provider and service
|
|
124
|
-
- Create core interfaces
|
|
125
|
-
- Basic error handling
|
|
126
|
-
|
|
127
|
-
2. **Week 2: Service Architecture**
|
|
128
|
-
- Create extensible provider system
|
|
129
|
-
- Implement provider interface
|
|
130
|
-
- Add provider registration
|
|
131
|
-
|
|
132
|
-
3. **Week 3: Advanced Features**
|
|
133
|
-
- Implement caching system
|
|
134
|
-
- Add configuration management
|
|
135
|
-
- Enhance error handling
|
|
136
|
-
|
|
137
|
-
4. **Week 4: Testing & Documentation**
|
|
138
|
-
- Write comprehensive tests
|
|
139
|
-
- Create usage documentation
|
|
140
|
-
- Performance optimization
|
|
141
|
-
|
|
142
|
-
## Dependencies
|
|
143
|
-
|
|
144
|
-
### Required
|
|
145
|
-
- `@push.rocks/smartrequest` - HTTP requests
|
|
146
|
-
- `@push.rocks/smartpromise` - Promise utilities
|
|
147
|
-
- `@push.rocks/smartlog` - Logging
|
|
148
|
-
|
|
149
|
-
### Development
|
|
150
|
-
- `@git.zone/tstest` - Testing framework
|
|
151
|
-
- `@git.zone/tsrun` - TypeScript execution
|
|
152
|
-
|
|
153
|
-
## API Endpoints Research
|
|
154
|
-
|
|
155
|
-
### Yahoo Finance
|
|
156
|
-
- Base URL: `https://query1.finance.yahoo.com/v8/finance/chart/{ticker}`
|
|
157
|
-
- No authentication required
|
|
158
|
-
- Returns JSON with price data
|
|
159
|
-
- Rate limits unknown (need to test)
|
|
160
|
-
- Alternative endpoints to explore:
|
|
161
|
-
- `/v7/finance/quote` - Simplified quote data
|
|
162
|
-
- `/v10/finance/quoteSummary` - Detailed company data
|
|
163
|
-
|
|
164
|
-
## Success Criteria
|
|
165
|
-
|
|
166
|
-
1. Can fetch current stock prices for any valid ticker
|
|
167
|
-
2. Extensible architecture for future providers
|
|
168
|
-
3. Response time < 1 second for cached data
|
|
169
|
-
4. Response time < 3 seconds for fresh data
|
|
170
|
-
5. Proper error handling and recovery
|
|
171
|
-
6. Comprehensive test coverage (>80%)
|
|
172
|
-
|
|
173
|
-
## Notes
|
|
174
|
-
|
|
175
|
-
- Yahoo Finance provides free stock data without authentication
|
|
176
|
-
- **Architecture designed for multiple providers**: While only implementing Yahoo Finance initially, all interfaces, classes, and patterns are designed to support multiple stock data providers
|
|
177
|
-
- The provider registry pattern allows adding new providers without modifying existing code
|
|
178
|
-
- Each provider implements the same IStockProvider interface for consistency
|
|
179
|
-
- Future providers can be added by simply creating a new provider class and registering it
|
|
180
|
-
- Implement proper TypeScript types for all data structures
|
|
181
|
-
- Follow the project's coding standards (prefix interfaces with 'I')
|
|
182
|
-
- Use plugins.ts for all external dependencies
|
|
183
|
-
- Keep filenames lowercase
|
|
184
|
-
- Write tests using @git.zone/tstest with smartexpect syntax
|
|
185
|
-
- Focus on clean, extensible architecture for future growth
|
|
186
|
-
|
|
187
|
-
## Future Provider Addition Example
|
|
188
|
-
|
|
189
|
-
When ready to add a new provider (e.g., Alpha Vantage), the process will be:
|
|
190
|
-
1. Create `ts/stocks/providers/provider.alphavantage.ts`
|
|
191
|
-
2. Implement the `IStockProvider` interface
|
|
192
|
-
3. Register the provider in the StockPriceService
|
|
193
|
-
4. No changes needed to existing code or interfaces
|