@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
|
@@ -1,28 +1,35 @@
|
|
|
1
1
|
import type { IStockProvider, IProviderConfig } from '../interfaces/provider.js';
|
|
2
2
|
import type { IStockPrice, IStockDataRequest } from '../interfaces/stockprice.js';
|
|
3
3
|
/**
|
|
4
|
-
* Marketstack API v2 Provider -
|
|
4
|
+
* Marketstack API v2 Provider - Professional Plan with Intelligent Intraday Support
|
|
5
5
|
* Documentation: https://docs.apilayer.com/marketstack/docs/marketstack-api-v2-v-2-0-0
|
|
6
6
|
*
|
|
7
7
|
* Features:
|
|
8
|
+
* - Intelligent endpoint selection based on market hours
|
|
9
|
+
* - Real-time intraday pricing with multiple intervals (1min, 5min, 10min, 15min, 30min, 1hour)
|
|
8
10
|
* - End-of-Day (EOD) stock prices with historical data
|
|
9
|
-
* -
|
|
11
|
+
* - Market state detection (PRE, REGULAR, POST, CLOSED)
|
|
10
12
|
* - Exchange filtering via MIC codes (XNAS, XNYS, XLON, etc.)
|
|
11
13
|
* - Supports 500,000+ tickers across 72+ exchanges worldwide
|
|
12
14
|
* - OHLCV data (Open, High, Low, Close, Volume)
|
|
13
15
|
* - Pagination for large datasets
|
|
16
|
+
* - Automatic fallback from intraday to EOD on errors
|
|
14
17
|
* - Requires API key authentication
|
|
15
18
|
*
|
|
19
|
+
* Intelligent Endpoint Selection:
|
|
20
|
+
* - During market hours (PRE/REGULAR/POST): Uses intraday endpoints for fresh data
|
|
21
|
+
* - After market close (CLOSED): Uses EOD endpoints to save API credits
|
|
22
|
+
* - Automatic fallback to EOD if intraday fails (rate limits, plan restrictions, etc.)
|
|
23
|
+
*
|
|
16
24
|
* Rate Limits:
|
|
17
25
|
* - Free Plan: 100 requests/month (EOD only)
|
|
18
|
-
* - Basic Plan: 10,000 requests/month
|
|
19
|
-
* - Professional Plan: 100,000 requests/month (intraday
|
|
26
|
+
* - Basic Plan: 10,000 requests/month (EOD only)
|
|
27
|
+
* - Professional Plan: 100,000 requests/month (intraday + EOD)
|
|
20
28
|
*
|
|
21
|
-
*
|
|
22
|
-
* -
|
|
23
|
-
* - Exchange
|
|
24
|
-
* -
|
|
25
|
-
* - Pagination handling
|
|
29
|
+
* Intraday Access:
|
|
30
|
+
* - Intervals below 15min (1min, 5min, 10min) require Professional Plan or higher
|
|
31
|
+
* - Real-time data from IEX Exchange for US tickers
|
|
32
|
+
* - Symbol formatting: Periods replaced with hyphens for intraday (BRK.B → BRK-B)
|
|
26
33
|
*/
|
|
27
34
|
export declare class MarketstackProvider implements IStockProvider {
|
|
28
35
|
private config?;
|
|
@@ -42,21 +49,44 @@ export declare class MarketstackProvider implements IStockProvider {
|
|
|
42
49
|
*/
|
|
43
50
|
fetchData(request: IStockDataRequest): Promise<IStockPrice[] | IStockPrice>;
|
|
44
51
|
/**
|
|
45
|
-
* Fetch current/latest
|
|
52
|
+
* Fetch current/latest price with intelligent endpoint selection
|
|
53
|
+
* Uses intraday during market hours (PRE, REGULAR, POST) for fresh data
|
|
54
|
+
* Uses EOD after market close (CLOSED) to save API credits
|
|
46
55
|
*/
|
|
47
56
|
private fetchCurrentPrice;
|
|
57
|
+
/**
|
|
58
|
+
* Fetch current price using intraday endpoint (during market hours)
|
|
59
|
+
* Uses 1min interval for most recent data
|
|
60
|
+
*/
|
|
61
|
+
private fetchCurrentPriceIntraday;
|
|
62
|
+
/**
|
|
63
|
+
* Fetch current price using EOD endpoint (after market close)
|
|
64
|
+
*/
|
|
65
|
+
private fetchCurrentPriceEod;
|
|
48
66
|
/**
|
|
49
67
|
* Fetch historical EOD prices for a ticker with date range
|
|
50
68
|
*/
|
|
51
69
|
private fetchHistoricalPrices;
|
|
52
70
|
/**
|
|
53
|
-
* Fetch intraday prices with specified interval
|
|
71
|
+
* Fetch intraday prices with specified interval
|
|
72
|
+
* Supports intervals: 1min, 5min, 10min, 15min, 30min, 1hour
|
|
73
|
+
* Note: Intervals below 15min require Professional Plan or higher
|
|
54
74
|
*/
|
|
55
75
|
private fetchIntradayPrices;
|
|
56
76
|
/**
|
|
57
|
-
* Fetch current prices for multiple tickers
|
|
77
|
+
* Fetch current prices for multiple tickers with intelligent endpoint selection
|
|
78
|
+
* Uses intraday during market hours (PRE, REGULAR, POST) for fresh data
|
|
79
|
+
* Uses EOD after market close (CLOSED) to save API credits
|
|
58
80
|
*/
|
|
59
81
|
private fetchBatchCurrentPrices;
|
|
82
|
+
/**
|
|
83
|
+
* Fetch batch current prices using intraday endpoint
|
|
84
|
+
*/
|
|
85
|
+
private fetchBatchCurrentPricesIntraday;
|
|
86
|
+
/**
|
|
87
|
+
* Fetch batch current prices using EOD endpoint
|
|
88
|
+
*/
|
|
89
|
+
private fetchBatchCurrentPricesEod;
|
|
60
90
|
/**
|
|
61
91
|
* Check if the Marketstack API is available and accessible
|
|
62
92
|
*/
|
|
@@ -72,6 +102,9 @@ export declare class MarketstackProvider implements IStockProvider {
|
|
|
72
102
|
supportsTicker(ticker: string): boolean;
|
|
73
103
|
/**
|
|
74
104
|
* Map Marketstack API response to IStockPrice interface
|
|
105
|
+
* @param data - API response data
|
|
106
|
+
* @param dataType - Type of data (eod, intraday, live)
|
|
107
|
+
* @param explicitMarketState - Override market state (used for intraday data fetched during known market hours)
|
|
75
108
|
*/
|
|
76
109
|
private mapToStockPrice;
|
|
77
110
|
/**
|
|
@@ -83,4 +116,32 @@ export declare class MarketstackProvider implements IStockProvider {
|
|
|
83
116
|
* Format date to YYYY-MM-DD for API requests
|
|
84
117
|
*/
|
|
85
118
|
private formatDate;
|
|
119
|
+
/**
|
|
120
|
+
* Get US market state based on Eastern Time
|
|
121
|
+
* Regular hours: 9:30 AM - 4:00 PM ET
|
|
122
|
+
* Pre-market: 4:00 AM - 9:30 AM ET
|
|
123
|
+
* After-hours: 4:00 PM - 8:00 PM ET
|
|
124
|
+
*
|
|
125
|
+
* @param timestampMs - Optional timestamp in milliseconds (defaults to current time)
|
|
126
|
+
* @returns Market state: PRE, REGULAR, POST, or CLOSED
|
|
127
|
+
*/
|
|
128
|
+
private getUsMarketState;
|
|
129
|
+
/**
|
|
130
|
+
* Determine if intraday endpoint should be used based on market state
|
|
131
|
+
* Uses intraday for PRE, REGULAR, and POST market states
|
|
132
|
+
* Uses EOD for CLOSED state to save API credits
|
|
133
|
+
*
|
|
134
|
+
* @param marketState - Current market state
|
|
135
|
+
* @returns true if intraday endpoint should be used
|
|
136
|
+
*/
|
|
137
|
+
private shouldUseIntradayEndpoint;
|
|
138
|
+
/**
|
|
139
|
+
* Format ticker symbol for intraday endpoints
|
|
140
|
+
* Marketstack intraday API requires periods to be replaced with hyphens
|
|
141
|
+
* Example: BRK.B → BRK-B
|
|
142
|
+
*
|
|
143
|
+
* @param symbol - Original ticker symbol
|
|
144
|
+
* @returns Formatted symbol for intraday endpoints
|
|
145
|
+
*/
|
|
146
|
+
private formatSymbolForIntraday;
|
|
86
147
|
}
|