Lean  $LEAN_TAG$
FineFundamentalUniverse.cs
1 /*
2  * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
3  * Lean Algorithmic Trading Engine v2.0. Copyright 2014 QuantConnect Corporation.
4  *
5  * Licensed under the Apache License, Version 2.0 (the "License");
6  * you may not use this file except in compliance with the License.
7  * You may obtain a copy of the License at http://www.apache.org/licenses/LICENSE-2.0
8  *
9  * Unless required by applicable law or agreed to in writing, software
10  * distributed under the License is distributed on an "AS IS" BASIS,
11  * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
12  * See the License for the specific language governing permissions and
13  * limitations under the License.
14 */
15 
16 using System;
17 using System.Linq;
18 using System.Collections.Generic;
20 
22 {
23  /// <summary>
24  /// Defines a universe that reads fine us equity data
25  /// </summary>
27  {
28  private readonly Func<IEnumerable<FineFundamental>, IEnumerable<Symbol>> _selector;
29 
30  /// <summary>
31  /// Initializes a new instance of the <see cref="FineFundamentalUniverse"/> class
32  /// </summary>
33  /// <param name="universeSettings">The settings used for new subscriptions generated by this universe</param>
34  /// <param name="selector">Returns the symbols that should be included in the universe</param>
35  public FineFundamentalUniverse(UniverseSettings universeSettings, Func<IEnumerable<FineFundamental>, IEnumerable<Symbol>> selector)
36  : base(CreateConfiguration(FundamentalUniverseFactory.SymbolFactory.UniverseSymbol()))
37  {
38  UniverseSettings = universeSettings;
39  _selector = selector;
40  }
41 
42  /// <summary>
43  /// Initializes a new instance of the <see cref="FineFundamentalUniverse"/> class
44  /// </summary>
45  /// <param name="symbol">Defines the symbol to use for this universe</param>
46  /// <param name="universeSettings">The settings used for new subscriptions generated by this universe</param>
47  /// <param name="selector">Returns the symbols that should be included in the universe</param>
48  public FineFundamentalUniverse(Symbol symbol, UniverseSettings universeSettings, Func<IEnumerable<FineFundamental>, IEnumerable<Symbol>> selector)
49  : base(CreateConfiguration(symbol))
50  {
51  UniverseSettings = universeSettings;
52  _selector = selector;
53  }
54 
55  /// <summary>
56  /// Performs universe selection using the data specified
57  /// </summary>
58  /// <param name="utcTime">The current utc time</param>
59  /// <param name="data">The symbols to remain in the universe</param>
60  /// <returns>The data that passes the filter</returns>
61  public override IEnumerable<Symbol> SelectSymbols(DateTime utcTime, BaseDataCollection data)
62  {
63  return _selector(data.Data.OfType<FineFundamental>());
64  }
65 
66  /// <summary>
67  /// Creates a <see cref="FineFundamental"/> subscription configuration for the US-equity market
68  /// </summary>
69  /// <param name="symbol">The symbol used in the returned configuration</param>
70  /// <returns>A fine fundamental subscription configuration with the specified symbol</returns>
72  {
74  }
75  }
76 }