@fin.cx/opendata 3.2.2 → 3.4.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/dist_ts/00_commitinfo_data.js +1 -1
- package/dist_ts/stocks/index.d.ts +1 -0
- package/dist_ts/stocks/index.js +2 -1
- package/dist_ts/stocks/providers/provider.coingecko.d.ts +101 -0
- package/dist_ts/stocks/providers/provider.coingecko.js +596 -0
- package/dist_ts/stocks/providers/provider.marketstack.d.ts +73 -12
- package/dist_ts/stocks/providers/provider.marketstack.js +336 -63
- package/package.json +1 -1
- package/readme.hints.md +45 -1
- package/readme.md +62 -2
- package/ts/00_commitinfo_data.ts +1 -1
- package/ts/stocks/index.ts +2 -1
- package/ts/stocks/providers/provider.coingecko.ts +757 -0
- package/ts/stocks/providers/provider.marketstack.ts +386 -69
|
@@ -3,7 +3,7 @@
|
|
|
3
3
|
*/
|
|
4
4
|
export const commitinfo = {
|
|
5
5
|
name: '@fin.cx/opendata',
|
|
6
|
-
version: '3.
|
|
6
|
+
version: '3.4.0',
|
|
7
7
|
description: 'A comprehensive TypeScript library for accessing business data and real-time financial information. Features include German company data management with MongoDB integration, JSONL bulk processing, automated Handelsregister interactions, and real-time stock market data from multiple providers.'
|
|
8
8
|
};
|
|
9
9
|
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiMDBfY29tbWl0aW5mb19kYXRhLmpzIiwic291cmNlUm9vdCI6IiIsInNvdXJjZXMiOlsiLi4vdHMvMDBfY29tbWl0aW5mb19kYXRhLnRzIl0sIm5hbWVzIjpbXSwibWFwcGluZ3MiOiJBQUFBOztHQUVHO0FBQ0gsTUFBTSxDQUFDLE1BQU0sVUFBVSxHQUFHO0lBQ3hCLElBQUksRUFBRSxrQkFBa0I7SUFDeEIsT0FBTyxFQUFFLE9BQU87SUFDaEIsV0FBVyxFQUFFLHVTQUF1UztDQUNyVCxDQUFBIn0=
|
package/dist_ts/stocks/index.js
CHANGED
|
@@ -13,4 +13,5 @@ export * from './classes.baseproviderservice.js';
|
|
|
13
13
|
export * from './providers/provider.yahoo.js';
|
|
14
14
|
export * from './providers/provider.marketstack.js';
|
|
15
15
|
export * from './providers/provider.secedgar.js';
|
|
16
|
-
|
|
16
|
+
export * from './providers/provider.coingecko.js';
|
|
17
|
+
//# sourceMappingURL=data:application/json;base64,eyJ2ZXJzaW9uIjozLCJmaWxlIjoiaW5kZXguanMiLCJzb3VyY2VSb290IjoiIiwic291cmNlcyI6WyIuLi8uLi90cy9zdG9ja3MvaW5kZXgudHMiXSwibmFtZXMiOltdLCJtYXBwaW5ncyI6IkFBQUEsd0JBQXdCO0FBQ3hCLGNBQWMsNEJBQTRCLENBQUM7QUFDM0MsY0FBYywwQkFBMEIsQ0FBQztBQUN6QyxjQUFjLDhCQUE4QixDQUFDO0FBQzdDLGNBQWMsMkJBQTJCLENBQUM7QUFFMUMsdUJBQXVCO0FBQ3ZCLGNBQWMsMkJBQTJCLENBQUM7QUFDMUMsY0FBYyxrQ0FBa0MsQ0FBQztBQUNqRCxjQUFjLCtCQUErQixDQUFDLENBQUMsd0JBQXdCO0FBRXZFLCtDQUErQztBQUMvQyxjQUFjLGtDQUFrQyxDQUFDO0FBRWpELG1CQUFtQjtBQUNuQixjQUFjLCtCQUErQixDQUFDO0FBQzlDLGNBQWMscUNBQXFDLENBQUM7QUFDcEQsY0FBYyxrQ0FBa0MsQ0FBQztBQUNqRCxjQUFjLG1DQUFtQyxDQUFDIn0=
|
|
@@ -0,0 +1,101 @@
|
|
|
1
|
+
import type { IStockProvider, IProviderConfig } from '../interfaces/provider.js';
|
|
2
|
+
import type { IStockPrice, IStockDataRequest } from '../interfaces/stockprice.js';
|
|
3
|
+
/**
|
|
4
|
+
* CoinGecko Crypto Price Provider
|
|
5
|
+
*
|
|
6
|
+
* Documentation: https://docs.coingecko.com/v3.0.1/reference/endpoint-overview
|
|
7
|
+
*
|
|
8
|
+
* Features:
|
|
9
|
+
* - Current crypto prices (single and batch)
|
|
10
|
+
* - Historical price data with OHLCV
|
|
11
|
+
* - 13M+ tokens, 240+ networks, 1600+ exchanges
|
|
12
|
+
* - Accepts both ticker symbols (BTC, ETH) and CoinGecko IDs (bitcoin, ethereum)
|
|
13
|
+
* - 24/7 market data (crypto never closes)
|
|
14
|
+
*
|
|
15
|
+
* Rate Limits:
|
|
16
|
+
* - Free tier (no key): 5-15 requests/minute
|
|
17
|
+
* - Demo plan (free with registration): ~30 requests/minute, 10,000/month
|
|
18
|
+
* - Paid plans: Higher limits
|
|
19
|
+
*
|
|
20
|
+
* API Authentication:
|
|
21
|
+
* - Optional API key for Demo/paid plans
|
|
22
|
+
* - Header: x-cg-demo-api-key (Demo) or x-cg-pro-api-key (paid)
|
|
23
|
+
*/
|
|
24
|
+
export declare class CoinGeckoProvider implements IStockProvider {
|
|
25
|
+
private config?;
|
|
26
|
+
name: string;
|
|
27
|
+
priority: number;
|
|
28
|
+
readonly requiresAuth = false;
|
|
29
|
+
readonly rateLimit: {
|
|
30
|
+
requestsPerMinute: number;
|
|
31
|
+
requestsPerDay: number;
|
|
32
|
+
};
|
|
33
|
+
private logger;
|
|
34
|
+
private baseUrl;
|
|
35
|
+
private apiKey?;
|
|
36
|
+
private rateLimiter;
|
|
37
|
+
private coinMapCache;
|
|
38
|
+
private coinListLoadedAt;
|
|
39
|
+
private readonly coinListCacheTTL;
|
|
40
|
+
private readonly priorityTickerMap;
|
|
41
|
+
constructor(apiKey?: string, config?: IProviderConfig);
|
|
42
|
+
/**
|
|
43
|
+
* Unified data fetching method supporting all request types
|
|
44
|
+
*/
|
|
45
|
+
fetchData(request: IStockDataRequest): Promise<IStockPrice | IStockPrice[]>;
|
|
46
|
+
/**
|
|
47
|
+
* Fetch current price for a single crypto
|
|
48
|
+
*/
|
|
49
|
+
private fetchCurrentPrice;
|
|
50
|
+
/**
|
|
51
|
+
* Fetch batch current prices for multiple cryptos
|
|
52
|
+
*/
|
|
53
|
+
private fetchBatchCurrentPrices;
|
|
54
|
+
/**
|
|
55
|
+
* Fetch historical prices with OHLCV data
|
|
56
|
+
*/
|
|
57
|
+
private fetchHistoricalPrices;
|
|
58
|
+
/**
|
|
59
|
+
* Fetch intraday prices with hourly intervals
|
|
60
|
+
*/
|
|
61
|
+
private fetchIntradayPrices;
|
|
62
|
+
/**
|
|
63
|
+
* Check if CoinGecko API is available
|
|
64
|
+
*/
|
|
65
|
+
isAvailable(): Promise<boolean>;
|
|
66
|
+
/**
|
|
67
|
+
* Check if a market/network is supported
|
|
68
|
+
* CoinGecko supports 240+ networks
|
|
69
|
+
*/
|
|
70
|
+
supportsMarket(market: string): boolean;
|
|
71
|
+
/**
|
|
72
|
+
* Check if a ticker format is supported
|
|
73
|
+
* Supports both ticker symbols (BTC) and CoinGecko IDs (bitcoin)
|
|
74
|
+
*/
|
|
75
|
+
supportsTicker(ticker: string): boolean;
|
|
76
|
+
/**
|
|
77
|
+
* Resolve ticker symbol or CoinGecko ID to canonical CoinGecko ID
|
|
78
|
+
* Supports both formats: "BTC" -> "bitcoin", "bitcoin" -> "bitcoin"
|
|
79
|
+
*/
|
|
80
|
+
private resolveCoinId;
|
|
81
|
+
/**
|
|
82
|
+
* Load complete coin list from CoinGecko API
|
|
83
|
+
*/
|
|
84
|
+
private loadCoinList;
|
|
85
|
+
/**
|
|
86
|
+
* Map CoinGecko simple/price response to IStockPrice
|
|
87
|
+
*/
|
|
88
|
+
private mapToStockPrice;
|
|
89
|
+
/**
|
|
90
|
+
* Build HTTP headers with optional API key
|
|
91
|
+
*/
|
|
92
|
+
private buildHeaders;
|
|
93
|
+
/**
|
|
94
|
+
* Check if response indicates a rate limit error (429)
|
|
95
|
+
*/
|
|
96
|
+
private isRateLimitError;
|
|
97
|
+
/**
|
|
98
|
+
* Wrapper for fetch operations with automatic rate limit retry and exponential backoff
|
|
99
|
+
*/
|
|
100
|
+
private fetchWithRateLimitRetry;
|
|
101
|
+
}
|