@discomedia/utils 1.0.18 → 1.0.19
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/index-frontend.cjs +104 -304
- package/dist/index-frontend.cjs.map +1 -1
- package/dist/index-frontend.mjs +104 -304
- package/dist/index-frontend.mjs.map +1 -1
- package/dist/index.cjs +410 -579
- package/dist/index.cjs.map +1 -1
- package/dist/index.mjs +410 -579
- package/dist/index.mjs.map +1 -1
- package/dist/package.json +1 -1
- package/dist/test.js +13086 -475
- package/dist/test.js.map +1 -1
- package/dist/types/index.d.ts.map +1 -1
- package/dist/types/market-time.d.ts +15 -154
- package/dist/types/market-time.d.ts.map +1 -1
- package/dist/types/test.d.ts +1 -1
- package/dist/types/test.d.ts.map +1 -1
- package/dist/types-frontend/index.d.ts.map +1 -1
- package/dist/types-frontend/market-time.d.ts +15 -154
- package/dist/types-frontend/market-time.d.ts.map +1 -1
- package/dist/types-frontend/test.d.ts +1 -1
- package/dist/types-frontend/test.d.ts.map +1 -1
- package/package.json +1 -1
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,IAAI,MAAM,cAAc,CAAC;AACrC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAK3C,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC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P,CAAC;;;kBAAwjc,CAAC;qBAAuB,CAAC;uBAAkC,CAAC;wBAAmC,CAAC;uBAAkC,CAAC;wBAAmC,CAAC;iBAA4B,CAAC;iBAA2B,CAAC;gBAAkB,CAAC;;;;;eAA5/W,CAAC;;;iBAAiE,CAAC;;kBAAmC,CAAC;;;;;kBAA65Q,CAAC;oBAAsB,CAAC;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAD9zZ,CAAC"}
|
|
@@ -1,9 +1,8 @@
|
|
|
1
|
-
import {
|
|
2
|
-
/**
|
|
3
|
-
* Market configuration constants
|
|
4
|
-
*/
|
|
1
|
+
import { IntradayReporting, PeriodDates, MarketTimeParams, MarketOpenCloseResult, MarketStatus, MarketTimesConfig } from './types/market-time-types';
|
|
5
2
|
export declare const MARKET_CONFIG: {
|
|
6
3
|
readonly TIMEZONE: "America/New_York";
|
|
4
|
+
readonly UTC_OFFSET_STANDARD: -5;
|
|
5
|
+
readonly UTC_OFFSET_DST: -4;
|
|
7
6
|
readonly TIMES: {
|
|
8
7
|
readonly EXTENDED_START: {
|
|
9
8
|
readonly hour: 4;
|
|
@@ -35,140 +34,24 @@ export declare const MARKET_CONFIG: {
|
|
|
35
34
|
};
|
|
36
35
|
};
|
|
37
36
|
};
|
|
38
|
-
/**
|
|
39
|
-
* Service for handling market calendar operations (holidays, early closes, market days)
|
|
40
|
-
*/
|
|
41
|
-
export declare class MarketCalendar {
|
|
42
|
-
private timezone;
|
|
43
|
-
constructor(timezone?: string);
|
|
44
|
-
/**
|
|
45
|
-
* Check if a date is a weekend
|
|
46
|
-
*/
|
|
47
|
-
isWeekend(date: Date): boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Check if a date is a market holiday
|
|
50
|
-
*/
|
|
51
|
-
isHoliday(date: Date): boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Check if a date is an early close day
|
|
54
|
-
*/
|
|
55
|
-
isEarlyCloseDay(date: Date): boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Get the early close time for a date (in minutes from midnight)
|
|
58
|
-
*/
|
|
59
|
-
getEarlyCloseTime(date: Date): number | null;
|
|
60
|
-
/**
|
|
61
|
-
* Check if a date is a market day (not weekend or holiday)
|
|
62
|
-
*/
|
|
63
|
-
isMarketDay(date: Date): boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Get the next market day from a given date
|
|
66
|
-
*/
|
|
67
|
-
getNextMarketDay(date: Date): Date;
|
|
68
|
-
/**
|
|
69
|
-
* Get the previous market day from a given date
|
|
70
|
-
*/
|
|
71
|
-
getPreviousMarketDay(date: Date): Date;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Service for formatting time outputs
|
|
75
|
-
*/
|
|
76
|
-
export declare class TimeFormatter {
|
|
77
|
-
private timezone;
|
|
78
|
-
constructor(timezone?: string);
|
|
79
|
-
/**
|
|
80
|
-
* Format a date based on the output format
|
|
81
|
-
*/
|
|
82
|
-
formatDate(date: Date, outputFormat?: OutputFormat): string | number;
|
|
83
|
-
/**
|
|
84
|
-
* Get New York timezone offset
|
|
85
|
-
*/
|
|
86
|
-
getNYTimeZone(date?: Date): '-04:00' | '-05:00';
|
|
87
|
-
/**
|
|
88
|
-
* Get trading date in YYYY-MM-DD format
|
|
89
|
-
*/
|
|
90
|
-
getTradingDate(time: string | number | Date): string;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Service for core market time calculations
|
|
94
|
-
*/
|
|
95
|
-
export declare class MarketTimeCalculator {
|
|
96
|
-
private calendar;
|
|
97
|
-
private timezone;
|
|
98
|
-
constructor(timezone?: string);
|
|
99
|
-
/**
|
|
100
|
-
* Get market open/close times for a date
|
|
101
|
-
*/
|
|
102
|
-
getMarketTimes(date: Date): MarketOpenCloseResult;
|
|
103
|
-
/**
|
|
104
|
-
* Check if a time is within market hours based on intraday reporting mode
|
|
105
|
-
*/
|
|
106
|
-
isWithinMarketHours(date: Date, intradayReporting?: IntradayReporting): boolean;
|
|
107
|
-
/**
|
|
108
|
-
* Get the last full trading date
|
|
109
|
-
*/
|
|
110
|
-
getLastFullTradingDate(currentDate?: Date, extendedHours?: boolean): Date;
|
|
111
|
-
/**
|
|
112
|
-
* Get day boundaries based on intraday reporting mode
|
|
113
|
-
*/
|
|
114
|
-
getDayBoundaries(date: Date, intradayReporting?: IntradayReporting): {
|
|
115
|
-
start: Date;
|
|
116
|
-
end: Date;
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Service for calculating time periods
|
|
121
|
-
*/
|
|
122
|
-
export declare class PeriodCalculator {
|
|
123
|
-
private calendar;
|
|
124
|
-
private timeCalculator;
|
|
125
|
-
private formatter;
|
|
126
|
-
constructor(timezone?: string);
|
|
127
|
-
/**
|
|
128
|
-
* Calculate the start date for a given period
|
|
129
|
-
*/
|
|
130
|
-
calculatePeriodStartDate(endDate: Date, period: Period): Date;
|
|
131
|
-
/**
|
|
132
|
-
* Get period dates for market time calculations
|
|
133
|
-
*/
|
|
134
|
-
getMarketTimePeriod(params: MarketTimeParams): PeriodDates;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Service for determining market status
|
|
138
|
-
*/
|
|
139
|
-
export declare class MarketStatusService {
|
|
140
|
-
private calendar;
|
|
141
|
-
private timeCalculator;
|
|
142
|
-
private timezone;
|
|
143
|
-
constructor(timezone?: string);
|
|
144
|
-
/**
|
|
145
|
-
* Get current market status
|
|
146
|
-
*/
|
|
147
|
-
getMarketStatus(date?: Date): MarketStatus;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Get market open/close times for a given date
|
|
151
|
-
*/
|
|
152
37
|
export declare function getMarketOpenClose(options?: {
|
|
153
38
|
date?: Date;
|
|
154
39
|
}): MarketOpenCloseResult;
|
|
155
|
-
/**
|
|
156
|
-
* Get start and end dates for a given market time period
|
|
157
|
-
*/
|
|
158
40
|
export declare function getStartAndEndDates(params?: MarketTimeParams): {
|
|
159
41
|
start: Date;
|
|
160
42
|
end: Date;
|
|
161
43
|
};
|
|
162
44
|
/**
|
|
163
|
-
*
|
|
45
|
+
* Returns the last full trading date as a Date object.
|
|
46
|
+
*/
|
|
47
|
+
export declare function getLastFullTradingDate(currentDate?: Date): Date;
|
|
48
|
+
/**
|
|
49
|
+
* Returns the last full trading date and formatted YYYYMMDD string.
|
|
164
50
|
*/
|
|
165
|
-
export declare function
|
|
51
|
+
export declare function getLastFullTradingDateInfo(currentDate?: Date): {
|
|
166
52
|
date: Date;
|
|
167
53
|
YYYYMMDD: string;
|
|
168
54
|
};
|
|
169
|
-
/**
|
|
170
|
-
* Get the next market day
|
|
171
|
-
*/
|
|
172
55
|
export declare function getNextMarketDay({ referenceDate }?: {
|
|
173
56
|
referenceDate?: Date;
|
|
174
57
|
}): {
|
|
@@ -177,35 +60,21 @@ export declare function getNextMarketDay({ referenceDate }?: {
|
|
|
177
60
|
dateISOString: string;
|
|
178
61
|
};
|
|
179
62
|
/**
|
|
180
|
-
*
|
|
63
|
+
* Returns the trading date for a given time. Note: Just trims the date string; does not validate if the date is a market day.
|
|
64
|
+
* @param time - a string, number (unix timestamp), or Date object representing the time
|
|
65
|
+
* @returns the trading date as a string in YYYY-MM-DD format
|
|
181
66
|
*/
|
|
182
67
|
export declare function getTradingDate(time: string | number | Date): string;
|
|
183
|
-
/**
|
|
184
|
-
* Get New York timezone offset
|
|
185
|
-
*/
|
|
186
68
|
export declare function getNYTimeZone(date?: Date): '-04:00' | '-05:00';
|
|
187
|
-
/**
|
|
188
|
-
* Get current market status
|
|
189
|
-
*/
|
|
190
69
|
export declare function getMarketStatus(options?: {
|
|
191
70
|
date?: Date;
|
|
192
71
|
}): MarketStatus;
|
|
193
|
-
/**
|
|
194
|
-
* Check if a date is a market day
|
|
195
|
-
*/
|
|
196
72
|
export declare function isMarketDay(date: Date): boolean;
|
|
197
|
-
/**
|
|
198
|
-
* Check if a date is within market hours
|
|
199
|
-
*/
|
|
200
73
|
export declare function isWithinMarketHours(date: Date, intradayReporting?: IntradayReporting): boolean;
|
|
201
74
|
/**
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
* and to go back x days before, e.g. 7 would just subtract raw 7 days, giving us 4-5 trading days (depending on holidays).
|
|
206
|
-
* @param options.endDate - The end date to use, defaults to today
|
|
207
|
-
* @param options.days - The number of days to go back, defaults to 1
|
|
208
|
-
* @returns The start and end dates with proper market open/close times
|
|
75
|
+
* Returns full trading days from market open to market close.
|
|
76
|
+
* endDate is always the most recent market close (previous day's close if before open, today's close if after open).
|
|
77
|
+
* days: 1 or not specified = that day's open; 2 = previous market day's open, etc.
|
|
209
78
|
*/
|
|
210
79
|
export declare function getTradingStartAndEndDates(options?: {
|
|
211
80
|
endDate?: Date;
|
|
@@ -214,9 +83,6 @@ export declare function getTradingStartAndEndDates(options?: {
|
|
|
214
83
|
startDate: Date;
|
|
215
84
|
endDate: Date;
|
|
216
85
|
};
|
|
217
|
-
/**
|
|
218
|
-
* Create a market time utility instance with custom timezone
|
|
219
|
-
*/
|
|
220
86
|
export declare function createMarketTimeUtil(timezone?: string, intradayReporting?: IntradayReporting): {
|
|
221
87
|
isMarketDay: (date: Date) => boolean;
|
|
222
88
|
isWithinMarketHours: (date: Date) => boolean;
|
|
@@ -231,11 +97,6 @@ export declare function createMarketTimeUtil(timezone?: string, intradayReportin
|
|
|
231
97
|
getEarlyCloseTime: (date: Date) => number | null;
|
|
232
98
|
};
|
|
233
99
|
export declare class MarketTimeUtil {
|
|
234
|
-
private calculator;
|
|
235
|
-
private calendar;
|
|
236
|
-
private formatter;
|
|
237
|
-
private periodCalc;
|
|
238
|
-
private statusService;
|
|
239
100
|
private intradayReporting;
|
|
240
101
|
constructor(timezone?: string, intradayReporting?: IntradayReporting);
|
|
241
102
|
isMarketDay(date: Date): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"market-time.d.ts","sourceRoot":"","sources":["../../src/market-time.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file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
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=test.d.ts.map
|
package/dist/types/test.d.ts.map
CHANGED
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/test.ts"],"names":[],"mappings":""}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../../src/index.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,MAAM,eAAe,CAAC;AACpC,OAAO,KAAK,EAAE,MAAM,gBAAgB,CAAC;AACrC,OAAO,KAAK,KAAK,MAAM,SAAS,CAAC;AACjC,OAAO,KAAK,IAAI,MAAM,cAAc,CAAC;AACrC,OAAO,KAAK,OAAO,MAAM,WAAW,CAAC;AAErC,OAAO,KAAK,GAAG,MAAM,cAAc,CAAC;AACpC,OAAO,KAAK,SAAS,MAAM,cAAc,CAAC;AAE1C,OAAO,EAAE,gBAAgB,EAAE,MAAM,qBAAqB,CAAC;AAEvD,OAAO,KAAK,EAAE,MAAM,sBAAsB,CAAC;AAK3C,cAAc,SAAS,CAAC;AAGxB,OAAO,EAAE,gBAAgB,EAAE,MAAM,sBAAsB,CAAC;AACxD,OAAO,EAAE,mBAAmB,EAAE,MAAM,0BAA0B,CAAC;AAE/D,eAAO,MAAM,KAAK;;;;;;;;;;;;;;;kBA4Bd,CAAF;;;kBAoCmL,CAAC;;;kBAA4zC,CAAC;;;kBAAkwC,CAAC;;;kBAAisD,CAAC;gBAAkB,CAAC;iBAAmB,CAAC;iBAAmB,CAAC;gBAAkB,CAAC;;;;;;;;;;;;;;;;;;kBAjDl/I,CAAC;;;kBAiD4rS,CAAC;oBAAsB,CAAC;sBAAyB,CAAC;;;kBAAhxP,CAAC;;;
|
|
1
|
+
{"version":3,"file":"index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
*/
|
|
1
|
+
import { IntradayReporting, PeriodDates, MarketTimeParams, MarketOpenCloseResult, MarketStatus, MarketTimesConfig } from './types/market-time-types';
|
|
5
2
|
export declare const MARKET_CONFIG: {
|
|
6
3
|
readonly TIMEZONE: "America/New_York";
|
|
4
|
+
readonly UTC_OFFSET_STANDARD: -5;
|
|
5
|
+
readonly UTC_OFFSET_DST: -4;
|
|
7
6
|
readonly TIMES: {
|
|
8
7
|
readonly EXTENDED_START: {
|
|
9
8
|
readonly hour: 4;
|
|
@@ -35,140 +34,24 @@ export declare const MARKET_CONFIG: {
|
|
|
35
34
|
};
|
|
36
35
|
};
|
|
37
36
|
};
|
|
38
|
-
/**
|
|
39
|
-
* Service for handling market calendar operations (holidays, early closes, market days)
|
|
40
|
-
*/
|
|
41
|
-
export declare class MarketCalendar {
|
|
42
|
-
private timezone;
|
|
43
|
-
constructor(timezone?: string);
|
|
44
|
-
/**
|
|
45
|
-
* Check if a date is a weekend
|
|
46
|
-
*/
|
|
47
|
-
isWeekend(date: Date): boolean;
|
|
48
|
-
/**
|
|
49
|
-
* Check if a date is a market holiday
|
|
50
|
-
*/
|
|
51
|
-
isHoliday(date: Date): boolean;
|
|
52
|
-
/**
|
|
53
|
-
* Check if a date is an early close day
|
|
54
|
-
*/
|
|
55
|
-
isEarlyCloseDay(date: Date): boolean;
|
|
56
|
-
/**
|
|
57
|
-
* Get the early close time for a date (in minutes from midnight)
|
|
58
|
-
*/
|
|
59
|
-
getEarlyCloseTime(date: Date): number | null;
|
|
60
|
-
/**
|
|
61
|
-
* Check if a date is a market day (not weekend or holiday)
|
|
62
|
-
*/
|
|
63
|
-
isMarketDay(date: Date): boolean;
|
|
64
|
-
/**
|
|
65
|
-
* Get the next market day from a given date
|
|
66
|
-
*/
|
|
67
|
-
getNextMarketDay(date: Date): Date;
|
|
68
|
-
/**
|
|
69
|
-
* Get the previous market day from a given date
|
|
70
|
-
*/
|
|
71
|
-
getPreviousMarketDay(date: Date): Date;
|
|
72
|
-
}
|
|
73
|
-
/**
|
|
74
|
-
* Service for formatting time outputs
|
|
75
|
-
*/
|
|
76
|
-
export declare class TimeFormatter {
|
|
77
|
-
private timezone;
|
|
78
|
-
constructor(timezone?: string);
|
|
79
|
-
/**
|
|
80
|
-
* Format a date based on the output format
|
|
81
|
-
*/
|
|
82
|
-
formatDate(date: Date, outputFormat?: OutputFormat): string | number;
|
|
83
|
-
/**
|
|
84
|
-
* Get New York timezone offset
|
|
85
|
-
*/
|
|
86
|
-
getNYTimeZone(date?: Date): '-04:00' | '-05:00';
|
|
87
|
-
/**
|
|
88
|
-
* Get trading date in YYYY-MM-DD format
|
|
89
|
-
*/
|
|
90
|
-
getTradingDate(time: string | number | Date): string;
|
|
91
|
-
}
|
|
92
|
-
/**
|
|
93
|
-
* Service for core market time calculations
|
|
94
|
-
*/
|
|
95
|
-
export declare class MarketTimeCalculator {
|
|
96
|
-
private calendar;
|
|
97
|
-
private timezone;
|
|
98
|
-
constructor(timezone?: string);
|
|
99
|
-
/**
|
|
100
|
-
* Get market open/close times for a date
|
|
101
|
-
*/
|
|
102
|
-
getMarketTimes(date: Date): MarketOpenCloseResult;
|
|
103
|
-
/**
|
|
104
|
-
* Check if a time is within market hours based on intraday reporting mode
|
|
105
|
-
*/
|
|
106
|
-
isWithinMarketHours(date: Date, intradayReporting?: IntradayReporting): boolean;
|
|
107
|
-
/**
|
|
108
|
-
* Get the last full trading date
|
|
109
|
-
*/
|
|
110
|
-
getLastFullTradingDate(currentDate?: Date, extendedHours?: boolean): Date;
|
|
111
|
-
/**
|
|
112
|
-
* Get day boundaries based on intraday reporting mode
|
|
113
|
-
*/
|
|
114
|
-
getDayBoundaries(date: Date, intradayReporting?: IntradayReporting): {
|
|
115
|
-
start: Date;
|
|
116
|
-
end: Date;
|
|
117
|
-
};
|
|
118
|
-
}
|
|
119
|
-
/**
|
|
120
|
-
* Service for calculating time periods
|
|
121
|
-
*/
|
|
122
|
-
export declare class PeriodCalculator {
|
|
123
|
-
private calendar;
|
|
124
|
-
private timeCalculator;
|
|
125
|
-
private formatter;
|
|
126
|
-
constructor(timezone?: string);
|
|
127
|
-
/**
|
|
128
|
-
* Calculate the start date for a given period
|
|
129
|
-
*/
|
|
130
|
-
calculatePeriodStartDate(endDate: Date, period: Period): Date;
|
|
131
|
-
/**
|
|
132
|
-
* Get period dates for market time calculations
|
|
133
|
-
*/
|
|
134
|
-
getMarketTimePeriod(params: MarketTimeParams): PeriodDates;
|
|
135
|
-
}
|
|
136
|
-
/**
|
|
137
|
-
* Service for determining market status
|
|
138
|
-
*/
|
|
139
|
-
export declare class MarketStatusService {
|
|
140
|
-
private calendar;
|
|
141
|
-
private timeCalculator;
|
|
142
|
-
private timezone;
|
|
143
|
-
constructor(timezone?: string);
|
|
144
|
-
/**
|
|
145
|
-
* Get current market status
|
|
146
|
-
*/
|
|
147
|
-
getMarketStatus(date?: Date): MarketStatus;
|
|
148
|
-
}
|
|
149
|
-
/**
|
|
150
|
-
* Get market open/close times for a given date
|
|
151
|
-
*/
|
|
152
37
|
export declare function getMarketOpenClose(options?: {
|
|
153
38
|
date?: Date;
|
|
154
39
|
}): MarketOpenCloseResult;
|
|
155
|
-
/**
|
|
156
|
-
* Get start and end dates for a given market time period
|
|
157
|
-
*/
|
|
158
40
|
export declare function getStartAndEndDates(params?: MarketTimeParams): {
|
|
159
41
|
start: Date;
|
|
160
42
|
end: Date;
|
|
161
43
|
};
|
|
162
44
|
/**
|
|
163
|
-
*
|
|
45
|
+
* Returns the last full trading date as a Date object.
|
|
46
|
+
*/
|
|
47
|
+
export declare function getLastFullTradingDate(currentDate?: Date): Date;
|
|
48
|
+
/**
|
|
49
|
+
* Returns the last full trading date and formatted YYYYMMDD string.
|
|
164
50
|
*/
|
|
165
|
-
export declare function
|
|
51
|
+
export declare function getLastFullTradingDateInfo(currentDate?: Date): {
|
|
166
52
|
date: Date;
|
|
167
53
|
YYYYMMDD: string;
|
|
168
54
|
};
|
|
169
|
-
/**
|
|
170
|
-
* Get the next market day
|
|
171
|
-
*/
|
|
172
55
|
export declare function getNextMarketDay({ referenceDate }?: {
|
|
173
56
|
referenceDate?: Date;
|
|
174
57
|
}): {
|
|
@@ -177,35 +60,21 @@ export declare function getNextMarketDay({ referenceDate }?: {
|
|
|
177
60
|
dateISOString: string;
|
|
178
61
|
};
|
|
179
62
|
/**
|
|
180
|
-
*
|
|
63
|
+
* Returns the trading date for a given time. Note: Just trims the date string; does not validate if the date is a market day.
|
|
64
|
+
* @param time - a string, number (unix timestamp), or Date object representing the time
|
|
65
|
+
* @returns the trading date as a string in YYYY-MM-DD format
|
|
181
66
|
*/
|
|
182
67
|
export declare function getTradingDate(time: string | number | Date): string;
|
|
183
|
-
/**
|
|
184
|
-
* Get New York timezone offset
|
|
185
|
-
*/
|
|
186
68
|
export declare function getNYTimeZone(date?: Date): '-04:00' | '-05:00';
|
|
187
|
-
/**
|
|
188
|
-
* Get current market status
|
|
189
|
-
*/
|
|
190
69
|
export declare function getMarketStatus(options?: {
|
|
191
70
|
date?: Date;
|
|
192
71
|
}): MarketStatus;
|
|
193
|
-
/**
|
|
194
|
-
* Check if a date is a market day
|
|
195
|
-
*/
|
|
196
72
|
export declare function isMarketDay(date: Date): boolean;
|
|
197
|
-
/**
|
|
198
|
-
* Check if a date is within market hours
|
|
199
|
-
*/
|
|
200
73
|
export declare function isWithinMarketHours(date: Date, intradayReporting?: IntradayReporting): boolean;
|
|
201
74
|
/**
|
|
202
|
-
*
|
|
203
|
-
*
|
|
204
|
-
*
|
|
205
|
-
* and to go back x days before, e.g. 7 would just subtract raw 7 days, giving us 4-5 trading days (depending on holidays).
|
|
206
|
-
* @param options.endDate - The end date to use, defaults to today
|
|
207
|
-
* @param options.days - The number of days to go back, defaults to 1
|
|
208
|
-
* @returns The start and end dates with proper market open/close times
|
|
75
|
+
* Returns full trading days from market open to market close.
|
|
76
|
+
* endDate is always the most recent market close (previous day's close if before open, today's close if after open).
|
|
77
|
+
* days: 1 or not specified = that day's open; 2 = previous market day's open, etc.
|
|
209
78
|
*/
|
|
210
79
|
export declare function getTradingStartAndEndDates(options?: {
|
|
211
80
|
endDate?: Date;
|
|
@@ -214,9 +83,6 @@ export declare function getTradingStartAndEndDates(options?: {
|
|
|
214
83
|
startDate: Date;
|
|
215
84
|
endDate: Date;
|
|
216
85
|
};
|
|
217
|
-
/**
|
|
218
|
-
* Create a market time utility instance with custom timezone
|
|
219
|
-
*/
|
|
220
86
|
export declare function createMarketTimeUtil(timezone?: string, intradayReporting?: IntradayReporting): {
|
|
221
87
|
isMarketDay: (date: Date) => boolean;
|
|
222
88
|
isWithinMarketHours: (date: Date) => boolean;
|
|
@@ -231,11 +97,6 @@ export declare function createMarketTimeUtil(timezone?: string, intradayReportin
|
|
|
231
97
|
getEarlyCloseTime: (date: Date) => number | null;
|
|
232
98
|
};
|
|
233
99
|
export declare class MarketTimeUtil {
|
|
234
|
-
private calculator;
|
|
235
|
-
private calendar;
|
|
236
|
-
private formatter;
|
|
237
|
-
private periodCalc;
|
|
238
|
-
private statusService;
|
|
239
100
|
private intradayReporting;
|
|
240
101
|
constructor(timezone?: string, intradayReporting?: IntradayReporting);
|
|
241
102
|
isMarketDay(date: Date): boolean;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"market-time.d.ts","sourceRoot":"","sources":["../../src/market-time.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"market-time.d.ts","sourceRoot":"","sources":["../../src/market-time.ts"],"names":[],"mappings":"AAEA,OAAO,EAEL,iBAAiB,EACjB,WAAW,EACX,gBAAgB,EAEhB,qBAAqB,EACrB,YAAY,EACZ,iBAAiB,EAClB,MAAM,2BAA2B,CAAC;AAInC,eAAO,MAAM,aAAa;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;CAahB,CAAC;AAicX,wBAAgB,kBAAkB,CAAC,OAAO,GAAE;IAAE,IAAI,CAAC,EAAE,IAAI,CAAA;CAAO,GAAG,qBAAqB,CAGvF;AAED,wBAAgB,mB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M,EAAE,iBAAiB,CAAC,EAAE,iBAAiB;wBAErE,IAAI;gCACI,IAAI;oCACA,IAAI;6BACX,IAAI;mCACE;QAAE,IAAI,CAAC,EAAE,IAAI,CAAA;KAAE;kCAChB,gBAAgB;6BACrB,IAAI;4BACL,IAAI;8BACF,IAAI;EAEjC;AAGD,qBAAa,cAAc;IACzB,OAAO,CAAC,iBAAiB,CAAoB;gBACjC,QAAQ,GAAE,MAA+B,EAAE,iBAAiB,GAAE,iBAAkC;IAG5G,WAAW,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAGhC,mBAAmB,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAGxC,sBAAsB,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,IAAI;IAGzC,gBAAgB,CAAC,IAAI,EAAE,IAAI,GAAG,IAAI;IAGlC,kBAAkB,CAAC,OAAO,CAAC,EAAE;QAAE,IAAI,CAAC,EAAE,IAAI,CAAA;KAAE,GAAG,qBAAqB;IAGpE,mBAAmB,CAAC,MAAM,EAAE,gBAAgB,GAAG,WAAW;IAG1D,eAAe,CAAC,IAAI,EAAE,IAAI,GAAG,OAAO;IAGpC,iBAAiB,CAAC,IAAI,EAAE,IAAI,GAAG,MAAM,GAAG,IAAI;CAG7C;AAGD,eAAO,MAAM,YAAY,EAAE,iBA0B1B,CAAC"}
|
|
@@ -1,2 +1,2 @@
|
|
|
1
|
-
|
|
1
|
+
export {};
|
|
2
2
|
//# sourceMappingURL=test.d.ts.map
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/test.ts"],"names":[],"mappings":"
|
|
1
|
+
{"version":3,"file":"test.d.ts","sourceRoot":"","sources":["../../src/test.ts"],"names":[],"mappings":""}
|