/* * 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 type that is indexed, i.e. a file that points to another file containing the contents /// we're looking for in a Symbol. /// [ProtoContract(SkipConstructor = true)] public class IndexedLinkedData2 : IndexedBaseData { /// /// Example data property /// [ProtoMember(55)] public int Count { get; set; } /// /// Determines the actual source from an index contained within a ticker folder /// /// Subscription configuration /// Date /// File to load data from /// Is live mode /// SubscriptionDataSource pointing to the article public override SubscriptionDataSource GetSourceForAnIndex(SubscriptionDataConfig config, DateTime date, string index, bool isLiveMode) { return new SubscriptionDataSource( Path.Combine("TestData", "indexlinked2", "content", $"{date.ToStringInvariant(DateFormat.EightCharacter)}.zip#{index}" ), SubscriptionTransportMedium.LocalFile, FileFormat.Csv ); } /// /// Gets the source of the index file /// /// Configuration object /// Date of this source file /// Is live mode /// SubscriptionDataSource indicating where data is located and how it's stored public override SubscriptionDataSource GetSource(SubscriptionDataConfig config, DateTime date, bool isLiveMode) { if (isLiveMode) { throw new NotImplementedException("Live mode not supported"); } return new SubscriptionDataSource( Path.Combine( "TestData", "indexlinked2", config.Symbol.Value.ToLowerInvariant(), $"{date.ToStringInvariant(DateFormat.EightCharacter)}.csv" ), SubscriptionTransportMedium.LocalFile, FileFormat.Index ); } /// /// Creates an instance from a line of JSON containing article information read from the `content` directory /// /// Subscription configuration /// Line of data /// Date /// Is live mode public override BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, bool isLiveMode) { return new IndexedLinkedData2 { 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; } } }