@@ -31,6 +31,8 @@ export interface ResponseSchema {
31
31
}
32
32
33
33
const TZ = 'America/New_York'
34
+ const START_TIME = '09:08:00'
35
+ const END_TIME = '12:00:00'
34
36
35
37
type ReportValueType = typeof inputParameters . validated . reportValue
36
38
@@ -78,11 +80,13 @@ export class NavTransport implements Transport<BaseEndpointTypes> {
78
80
return this . execute ( fundId , reportValue )
79
81
}
80
82
81
- // Runs 'execute' function every day at 9:09 AM ET (if fundIdsSet is not empty)
83
+ // Runs 'execute' function every day at START_TIME (if fundIdsSet is not empty)
82
84
runScheduler ( ) {
83
85
const rule = new schedule . RecurrenceRule ( )
84
- rule . hour = 9
85
- rule . minute = 9
86
+ const startTimeSegments = START_TIME . split ( ':' ) . map ( ( s ) => parseInt ( s ) )
87
+ rule . hour = startTimeSegments [ 0 ]
88
+ rule . minute = startTimeSegments [ 1 ]
89
+ rule . second = startTimeSegments [ 2 ]
86
90
rule . tz = TZ
87
91
88
92
schedule . scheduleJob ( rule , ( ) => {
@@ -122,16 +126,16 @@ export class NavTransport implements Transport<BaseEndpointTypes> {
122
126
result = Number ( data . assets_under_management )
123
127
}
124
128
125
- // DP updates previous working day's price on the next working day at 9:09 AM ET
126
- // If there is no fresh price data, we try to re-fetch the API until 10:30 AM ET
129
+ // DP updates previous working day's price on the next working day at START_TIME ET
130
+ // If there is no fresh price data, we try to re-fetch the API until END_TIME ET
127
131
// Skips checks and re-running on weekends
128
132
if ( this . shouldCheckForExpectedData ( ) ) {
129
133
// At this point we know that conditions are met, and we should check for stale data and retry if it's not updated.
130
134
// If the most recent update from DP is not from previous working day, the data might be stale
131
135
const expectedDate = getPreviousNonWeekendDay ( TZ )
132
136
if ( data . net_asset_value_date !== expectedDate ) {
133
- // We should retry fetching DP until we get fresh data or the time is after 10:30 AM ET
134
- if ( isBeforeTime ( '10:30:00' , TZ ) ) {
137
+ // We should retry fetching DP until we get fresh data or the time is after END_TIME ET
138
+ if ( isBeforeTime ( END_TIME , TZ ) ) {
135
139
logger . warn (
136
140
`Expected last update - ${ expectedDate } , actual ${
137
141
data . net_asset_value_date
@@ -149,7 +153,7 @@ export class NavTransport implements Transport<BaseEndpointTypes> {
149
153
// while it tries to get a fresh update.
150
154
} else {
151
155
logger . warn (
152
- `Max retires reached. Expected update - ${ expectedDate } . Latest update - ${ data . net_asset_value_date } .` ,
156
+ `Max retries reached. Expected update - ${ expectedDate } . Latest update - ${ data . net_asset_value_date } .` ,
153
157
)
154
158
}
155
159
}
@@ -202,10 +206,10 @@ export class NavTransport implements Transport<BaseEndpointTypes> {
202
206
if ( isWeekend ( toTimezoneDate ( new Date ( ) , TZ ) ) ) return false
203
207
204
208
// If it's a business day we need to check for stale data only if the current ET time is within certain time range (retry period).
205
- // If it's before 09:09 AM we don't need to check as it's too soon and there will be no update from DP,
206
- // the scheduler will call the execute function once it's 09:09 .
207
- // If it's after 10:30 AM , it's too late, and we won't update the value until the next business day.
209
+ // If it's before START_TIME we don't need to check as it's too soon and there will be no update from DP,
210
+ // the scheduler will call the execute function once it's START_TIME .
211
+ // If it's after END_TIME , it's too late, and we won't update the value until the next business day.
208
212
// This is needed for EA restarts as the EA still has to make retries during retry period
209
- return isInTimeRange ( '09:09:00' , '10:30:00' , TZ )
213
+ return isInTimeRange ( START_TIME , END_TIME , TZ )
210
214
}
211
215
}
0 commit comments