2020using System . IO ;
2121using QuantConnect . Data ;
2222using System . Collections . Generic ;
23+ using Newtonsoft . Json ;
2324
2425namespace QuantConnect . DataSource
2526{
2627 /// <summary>
27- /// Example custom data type
28+ /// Regalytics Regulatory articles
2829 /// </summary>
2930 [ ProtoContract ( SkipConstructor = true ) ]
30- public class MyCustomDataType : BaseData
31+ public class RegalyticsRegulatoryArticle : BaseData
3132 {
32- /// <summary>
33- /// Some custom data property
34- /// </summary>
35- [ ProtoMember ( 2000 ) ]
36- public string SomeCustomProperty { get ; set ; }
33+ [ JsonProperty ( PropertyName = "id" ) ]
34+ public int Id { get ; set ; }
35+
36+ [ JsonProperty ( PropertyName = "title" ) ]
37+ public string Title { get ; set ; }
38+
39+ [ JsonProperty ( PropertyName = "summary" ) ]
40+ public string Summary { get ; set ; }
41+
42+ [ JsonProperty ( PropertyName = "status" ) ]
43+ public string Status { get ; set ; }
44+
45+ [ JsonProperty ( PropertyName = "classification" ) ]
46+ public string Classificaiton { get ; set ; }
47+
48+ [ JsonProperty ( PropertyName = "filing_type" ) ]
49+ public string FilingType { get ; set ; }
50+
51+ [ JsonProperty ( PropertyName = "in_federal_register" ) ]
52+ public bool InFederalRegister { get ; set ; }
53+
54+ [ JsonProperty ( PropertyName = "federal_register_number" ) ]
55+ public string FederalRegisterNumber { get ; set ; }
56+
57+ //[JsonProperty(PropertyName = "regalytics_alert_id")]
58+ //public string AlertId { get; set; }
59+
60+ [ JsonProperty ( PropertyName = "proposed_comments_due_date" ) ]
61+ public DateTime ? ProposedCommentsDueDate { get ; set ; }
62+
63+ [ JsonProperty ( PropertyName = "original_publication_date" ) ]
64+ public DateTime ? OriginalPublicationDate { get ; set ; }
65+
66+ [ JsonProperty ( PropertyName = "federal_register_publication_date" ) ]
67+ public DateTime ? FederalRegisterPublicationDate { get ; set ; }
68+
69+ [ JsonProperty ( PropertyName = "rule_effective_date" ) ]
70+ public DateTime ? RuleEffectiveDate { get ; set ; }
71+
72+ [ JsonProperty ( PropertyName = "latest_update" ) ]
73+ public DateTime LatestUpdate { get ; set ; }
74+
75+ [ JsonProperty ( PropertyName = "alert_type" ) ]
76+ public string AlertType { get ; set ; }
77+
78+ [ JsonProperty ( PropertyName = "states" ) ]
79+ public Dictionary < string , List < string > > States { get ; set ; }
80+
81+ [ JsonProperty ( PropertyName = "agencies" ) ]
82+ public List < string > Agencies { get ; set ; }
83+
84+ [ JsonProperty ( PropertyName = "pdf_url" ) ]
85+ public string AnnouncementUrl { get ; set ; }
3786
3887 /// <summary>
3988 /// Return the URL string source of the file. This will be converted to a stream
@@ -48,8 +97,9 @@ public override SubscriptionDataSource GetSource(SubscriptionDataConfig config,
4897 Path . Combine (
4998 Globals . DataFolder ,
5099 "alternative" ,
51- "mycustomdatatype" ,
52- $ "{ config . Symbol . Value . ToLowerInvariant ( ) } .csv"
100+ "regalytics" ,
101+ "articles" ,
102+ $ "{ date : yyyyMMdd} .json"
53103 ) ,
54104 SubscriptionTransportMedium . LocalFile
55105 ) ;
@@ -65,16 +115,16 @@ public override SubscriptionDataSource GetSource(SubscriptionDataConfig config,
65115 /// <returns>New instance</returns>
66116 public override BaseData Reader ( SubscriptionDataConfig config , string line , DateTime date , bool isLiveMode )
67117 {
68- var csv = line . Split ( ',' ) ;
118+ var article = JsonConvert . DeserializeObject < RegalyticsRegulatoryArticle > ( line ) ;
69119
70- var parsedDate = Parse . DateTimeExact ( csv [ 0 ] , "yyyyMMdd" ) ;
71- return new MyCustomDataType
72- {
73- Symbol = config . Symbol ,
74- SomeCustomProperty = csv [ 1 ] ,
75- Time = parsedDate ,
76- EndTime = parsedDate + TimeSpan . FromDays ( 1 )
77- } ;
120+ // date == the day that the data was published (2021-05-21)
121+ // 2021-05-21 for example, contains aggregated data from 2021-05-19, 2021-05-20.
122+ // Regalytics publishes at 07:30:00 Eastern time, EndTime should be at that time.
123+
124+ article . Symbol = config . Symbol ;
125+ article . EndTime = date . Date . AddHours ( 7 ) . AddMinutes ( 30 ) ;
126+
127+ return article ;
78128 }
79129
80130 /// <summary>
@@ -83,12 +133,30 @@ public override BaseData Reader(SubscriptionDataConfig config, string line, Date
83133 /// <returns>A clone of the object</returns>
84134 public override BaseData Clone ( )
85135 {
86- return new MyCustomDataType
136+ return new RegalyticsRegulatoryArticle
87137 {
88138 Symbol = Symbol ,
89139 Time = Time ,
90140 EndTime = EndTime ,
91- SomeCustomProperty = SomeCustomProperty ,
141+
142+ Id = Id ,
143+ Title = Title ,
144+ Summary = Summary ,
145+ Status = Status ,
146+ Classificaiton = Classificaiton ,
147+ FilingType = FilingType ,
148+ InFederalRegister = InFederalRegister ,
149+ FederalRegisterNumber = FederalRegisterNumber ,
150+ // AlertId = AlertId,
151+ ProposedCommentsDueDate = ProposedCommentsDueDate ,
152+ OriginalPublicationDate = OriginalPublicationDate ,
153+ FederalRegisterPublicationDate = FederalRegisterPublicationDate ,
154+ RuleEffectiveDate = RuleEffectiveDate ,
155+ LatestUpdate = LatestUpdate ,
156+ AlertType = AlertType ,
157+ States = States ,
158+ Agencies = Agencies ,
159+ AnnouncementUrl = AnnouncementUrl ,
92160 } ;
93161 }
94162
@@ -98,7 +166,7 @@ public override BaseData Clone()
98166 /// <returns>false</returns>
99167 public override bool RequiresMapping ( )
100168 {
101- return true ;
169+ return false ;
102170 }
103171
104172 /// <summary>
@@ -116,7 +184,7 @@ public override bool IsSparseData()
116184 /// </summary>
117185 public override string ToString ( )
118186 {
119- return $ "{ Symbol } - { SomeCustomProperty } ";
187+ return $ "ID: { Id } - Title: { Title } - Summary: { Summary } ";
120188 }
121189
122190 /// <summary>
@@ -141,7 +209,7 @@ public override List<Resolution> SupportedResolutions()
141209 /// <returns>The <see cref="T:NodaTime.DateTimeZone" /> of this data type</returns>
142210 public override DateTimeZone DataTimeZone ( )
143211 {
144- return DateTimeZone . Utc ;
212+ return TimeZones . NewYork ;
145213 }
146214 }
147- }
215+ }
0 commit comments