Lean  $LEAN_TAG$
LinkedData.cs
1 /*
2  * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
3  * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14 */
15 
16 using NodaTime;
17 using QuantConnect.Data;
18 using System;
19 using System.Collections.Generic;
20 using System.IO;
21 using ProtoBuf;
22 
24 {
25  /// <summary>
26  /// Data source that is linked (tickers that can have renames or be delisted)
27  /// </summary>
28  [ProtoContract(SkipConstructor = true)]
29  public class LinkedData : BaseData
30  {
31  /// <summary>
32  /// Example data
33  /// </summary>
34  [ProtoMember(55)]
35  public int Count { get; set; }
36 
37  public override SubscriptionDataSource GetSource(SubscriptionDataConfig config, DateTime date, bool isLiveMode)
38  {
39  return new SubscriptionDataSource(
40  Path.Combine(
41  "TestData",
42  "linked",
43  $"{config.Symbol.Underlying.Value.ToLowerInvariant()}.csv"
44  ),
46  FileFormat.Csv);
47  }
48 
49  public override BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, bool isLiveMode)
50  {
51  return new LinkedData
52  {
53  Count = 10,
54  Symbol = config.Symbol,
55  EndTime = date
56  };
57  }
58 
59  /// <summary>
60  /// Indicates whether the data source is sparse.
61  /// If false, it will disable missing file logging.
62  /// </summary>
63  /// <returns>true</returns>
64  public override bool IsSparseData()
65  {
66  return true;
67  }
68 
69  /// <summary>
70  /// Indicates whether the data source can undergo
71  /// rename events/is tied to equities.
72  /// </summary>
73  /// <returns>true</returns>
74  public override bool RequiresMapping()
75  {
76  return true;
77  }
78 
79  /// <summary>
80  /// Set the data time zone to UTC
81  /// </summary>
82  /// <returns>Time zone as UTC</returns>
83  public override DateTimeZone DataTimeZone()
84  {
85  return TimeZones.Utc;
86  }
87 
88  /// <summary>
89  /// Sets the default resolution to Second
90  /// </summary>
91  /// <returns>Resolution.Second</returns>
92  public override Resolution DefaultResolution()
93  {
94  return Resolution.Daily;
95  }
96 
97  /// <summary>
98  /// Gets a list of all the supported Resolutions
99  /// </summary>
100  /// <returns>All resolutions</returns>
101  public override List<Resolution> SupportedResolutions()
102  {
103  return DailyResolution;
104  }
105  }
106 }