/* * 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.Collections.Generic; namespace QuantConnect.Algorithm.Framework.Alphas.Analysis { /// /// Provides a simple abstraction that returns a security's current price and volatility. /// This facilitates testing by removing the dependency of IAlgorithm on the analysis components /// public interface ISecurityValuesProvider { /// /// Gets the current values for the specified symbol (price/volatility) /// /// The symbol to get price/volatility for /// The insight target values for the specified symbol SecurityValues GetValues(Symbol symbol); /// /// Gets the current values for all the algorithm securities (price/volatility) /// /// The insight target values for all the algorithm securities ReadOnlySecurityValuesCollection GetAllValues(); } /// /// Provides extension methods for /// public static class SecurityValuesProviderExtensions { /// /// Creates a new instance of to hold all for /// the specified symbol at the current instant in time /// /// Security values provider fetches security values for each symbol /// The symbols to get values for /// A collection of public static ReadOnlySecurityValuesCollection GetValues(this ISecurityValuesProvider securityValuesProvider, ICollection symbols) { var values = new Dictionary(symbols.Count); foreach (var symbol in symbols) { values[symbol] = securityValuesProvider.GetValues(symbol); } return new ReadOnlySecurityValuesCollection(values); } } }