/* * 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 System; using System.Linq; using System.Globalization; namespace QuantConnect.Data.UniverseSelection { /// /// Defines summary information about a single symbol for a given date /// public class CoarseFundamental : BaseData { /// /// Gets the market for this symbol /// public string Market => Symbol.ID.Market; /// /// Gets the day's dollar volume for this symbol /// public virtual double DollarVolume { get; } /// /// Gets the day's total volume /// public virtual long Volume { get; } /// /// Returns whether the symbol has fundamental data for the given date /// public virtual bool HasFundamentalData { get; } /// /// Gets the price factor for the given date /// public virtual decimal PriceFactor { get; } = 1; /// /// Gets the split factor for the given date /// public virtual decimal SplitFactor { get; } = 1; /// /// Gets the combined factor used to create adjusted prices from raw prices /// public decimal PriceScaleFactor => PriceFactor * SplitFactor; /// /// Gets the split and dividend adjusted price /// public decimal AdjustedPrice => Price * PriceScaleFactor; /// /// The end time of this data. /// public override DateTime EndTime { get { return Time + QuantConnect.Time.OneDay; } set { Time = value - QuantConnect.Time.OneDay; } } /// /// Gets the raw price /// public override decimal Price => Value; /// /// Initializes a new instance of the class /// public CoarseFundamental() { } /// /// Return the URL string source of the file. This will be converted to a stream /// /// Configuration object /// Date of this source file /// true if we're in live mode, false for backtesting mode /// String URL of source file. public override SubscriptionDataSource GetSource(SubscriptionDataConfig config, DateTime date, bool isLiveMode) { throw new InvalidOperationException($"Coarse type is obsolete, please use {nameof(Fundamental)}"); } /// /// 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. /// /// Subscription data config setup object /// Line of the source document /// Date of the requested data /// true if we're in live mode, false for backtesting mode /// Instance of the T:BaseData object generated by this line of the CSV public override BaseData Reader(SubscriptionDataConfig config, string line, DateTime date, bool isLiveMode) { throw new InvalidOperationException($"Coarse type is obsolete, please use {nameof(Fundamental)}"); } /// /// Converts a given fundamental data point into row format /// public static string ToRow(CoarseFundamental coarse) { // sid,symbol,close,volume,dollar volume,has fundamental data,price factor,split factor var values = new object[] { coarse.Symbol.ID, coarse.Symbol.Value, coarse.Value, coarse.Volume, coarse.DollarVolume, coarse.HasFundamentalData, coarse.PriceFactor, coarse.SplitFactor }; return string.Join(",", values.Select(s => Convert.ToString(s, CultureInfo.InvariantCulture))); } } }