Skip to content

Commit 3f1fe3a

Browse files
committed
Remove n-day delta, move loading logic into BaseData implementation
1 parent 26f81be commit 3f1fe3a

2 files changed

Lines changed: 18 additions & 9 deletions

File tree

RegalyticsRegulatoryArticle.cs

Lines changed: 16 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -21,6 +21,7 @@
2121
using QuantConnect.Data;
2222
using System.Collections.Generic;
2323
using Newtonsoft.Json;
24+
using DateTimeUtilityFunctions = QuantConnect.Securities.Future.FuturesExpiryUtilityFunctions;
2425

2526
namespace QuantConnect.DataSource
2627
{
@@ -30,6 +31,8 @@ namespace QuantConnect.DataSource
3031
[ProtoContract(SkipConstructor = true)]
3132
public class RegalyticsRegulatoryArticle : BaseData
3233
{
34+
private DateTime _endTime;
35+
3336
/// <summary>
3437
/// Data source ID
3538
/// </summary>
@@ -89,6 +92,12 @@ public class RegalyticsRegulatoryArticle : BaseData
8992
[JsonProperty(PropertyName = "pdf_url")]
9093
public string AnnouncementUrl { get; set; }
9194

95+
public override DateTime EndTime
96+
{
97+
get { return _endTime; }
98+
set { _endTime = value; }
99+
}
100+
92101
/// <summary>
93102
/// Return the URL string source of the file. This will be converted to a stream
94103
/// </summary>
@@ -98,13 +107,15 @@ public class RegalyticsRegulatoryArticle : BaseData
98107
/// <returns>String URL of source file.</returns>
99108
public override SubscriptionDataSource GetSource(SubscriptionDataConfig config, DateTime date, bool isLiveMode)
100109
{
110+
var publicationDate = DateTimeUtilityFunctions.AddBusinessDays(date.Date, -1, false);
111+
101112
return new SubscriptionDataSource(
102113
Path.Combine(
103114
Globals.DataFolder,
104115
"alternative",
105116
"regalytics",
106117
"articles",
107-
$"{date:yyyyMMdd}.json"
118+
$"{publicationDate:yyyyMMdd}.json"
108119
),
109120
SubscriptionTransportMedium.LocalFile
110121
);
@@ -124,10 +135,12 @@ public override BaseData Reader(SubscriptionDataConfig config, string line, Date
124135

125136
// date == the day that the data was published (2021-05-21)
126137
// 2021-05-21 for example, contains aggregated data from 2021-05-19, 2021-05-20.
127-
// Regalytics publishes at 07:30:00 Eastern time, EndTime should be at that time.
138+
// Regalytics publishes at around 07:30:00 Eastern Time, but is downloaded by
139+
// us around 08:00:00 Eastern Time.
128140

129141
article.Symbol = config.Symbol;
130-
article.EndTime = date.Date.AddHours(7).AddMinutes(30);
142+
article.Time = article.LatestUpdate;
143+
article.EndTime = DateTimeUtilityFunctions.AddBusinessDays(article.LatestUpdate.Date, 1, false).AddHours(8);
131144

132145
return article;
133146
}

process.py

Lines changed: 2 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -55,14 +55,10 @@
5555

5656
country_states.append(state['name'])
5757

58-
agencies = [agency['name'] for agency in article['agencies']]
5958
article['states'] = states
60-
article['agencies'] = agencies
61-
# If friday or weekend, the delta will make the date land on Tuesday
59+
article['agencies'] = [agency['name'] for agency in article['agencies']]
60+
6261
date = datetime.strptime(article['latest_update'], '%Y-%m-%d')
63-
weekday = date.weekday()
64-
delta = (8 - weekday) if weekday >= 3 else 2
65-
date = date + timedelta(days=delta)
6662
date_key = date.strftime('%Y%m%d')
6763

6864
if date_key not in articles_by_date:

0 commit comments

Comments
 (0)