/* * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals. * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation. * * Licensed under the Apache License, Version 2.0 (the "License"); * you may not use this file except in compliance with the License. * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0 * * Unless required by applicable law or agreed to in writing, software * distributed under the License is distributed on an "AS IS" BASIS, * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. * See the License for the specific language governing permissions and * limitations under the License. */ using NodaTime; using QuantConnect.Data; using System; using System.Collections.Generic; using System.IO; using ProtoBuf; namespace QuantConnect.Data.Custom.IconicTypes { /// /// Data source that is linked (tickers that can have renames or be delisted) /// [ProtoContract(SkipConstructor = true)] public class LinkedData : BaseData { /// /// Example data /// [ProtoMember(55)] public int Count { get; set; } /// /// Return the URL string source of the file. This will be converted to a stream /// public override SubscriptionDataSource GetSource(SubscriptionDataConfig config, DateTime date, bool isLiveMode) { return new SubscriptionDataSource( Path.Combine( "TestData", "linked", $"{config.Symbol.Underlying.Value.ToLowerInvariant()}.csv" ), SubscriptionTransportMedium.LocalFile, FileFormat.Csv); } /// /// Reader converts each line of the data source into BaseData objects. Each data type creates its own factory method, and returns a new instance of the object /// each time it is called. The returned object is assumed to be time stamped in the config.ExchangeTimeZone. /// public override BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, bool isLiveMode) { return new LinkedData { Count = 10, Symbol = config.Symbol, EndTime = date }; } /// /// Indicates whether the data source is sparse. /// If false, it will disable missing file logging. /// /// true public override bool IsSparseData() { return true; } /// /// Indicates whether the data source can undergo /// rename events/is tied to equities. /// /// true public override bool RequiresMapping() { return true; } /// /// Set the data time zone to UTC /// /// Time zone as UTC public override DateTimeZone DataTimeZone() { return TimeZones.Utc; } /// /// Sets the default resolution to Second /// /// Resolution.Second public override Resolution DefaultResolution() { return Resolution.Daily; } /// /// Gets a list of all the supported Resolutions /// /// All resolutions public override List SupportedResolutions() { return DailyResolution; } } }