/*
* 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.Collections.Generic;
using QuantConnect.Data.Fundamental;
namespace QuantConnect.Data.UniverseSelection
{
///
/// Defines a universe that reads fine us equity data
///
public class FineFundamentalUniverse : Universe
{
private readonly Func, IEnumerable> _selector;
///
/// Initializes a new instance of the class
///
/// The settings used for new subscriptions generated by this universe
/// Returns the symbols that should be included in the universe
public FineFundamentalUniverse(UniverseSettings universeSettings, Func, IEnumerable> selector)
: base(CreateConfiguration(FundamentalUniverseFactory.SymbolFactory.UniverseSymbol()))
{
UniverseSettings = universeSettings;
_selector = selector;
}
///
/// Initializes a new instance of the class
///
/// Defines the symbol to use for this universe
/// The settings used for new subscriptions generated by this universe
/// Returns the symbols that should be included in the universe
public FineFundamentalUniverse(Symbol symbol, UniverseSettings universeSettings, Func, IEnumerable> selector)
: base(CreateConfiguration(symbol))
{
UniverseSettings = universeSettings;
_selector = selector;
}
///
/// Performs universe selection using the data specified
///
/// The current utc time
/// The symbols to remain in the universe
/// The data that passes the filter
public override IEnumerable SelectSymbols(DateTime utcTime, BaseDataCollection data)
{
return _selector(data.Data.OfType());
}
///
/// Creates a subscription configuration for the US-equity market
///
/// The symbol used in the returned configuration
/// A fine fundamental subscription configuration with the specified symbol
public static SubscriptionDataConfig CreateConfiguration(Symbol symbol)
{
return FundamentalUniverseFactory.CreateConfiguration(symbol);
}
}
}