Lean
$LEAN_TAG$
FundamentalService.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
QuantConnect
.
Util
;
18
using
QuantConnect
.
Interfaces
;
19
using
QuantConnect
.
Configuration
;
20
using
QuantConnect
.
Data
.
Fundamental
;
21
22
namespace
QuantConnect.Data.UniverseSelection
23
{
24
/// <summary>
25
/// Fundamental data provider service
26
/// </summary>
27
public
static
class
FundamentalService
28
{
29
private
static
IFundamentalDataProvider
_fundamentalDataProvider;
30
31
/// <summary>
32
/// Initializes the service
33
/// </summary>
34
/// <param name="dataProvider">The data provider instance to use</param>
35
/// <param name="liveMode">True if running in live mode</param>
36
public
static
void
Initialize
(
IDataProvider
dataProvider,
bool
liveMode)
37
{
38
Initialize
(dataProvider,
Config
.
Get
(
"fundamental-data-provider"
, nameof(
CoarseFundamentalDataProvider
)), liveMode);
39
}
40
41
/// <summary>
42
/// Initializes the service
43
/// </summary>
44
/// <param name="dataProvider">The data provider instance to use</param>
45
/// <param name="fundamentalDataProvider">The fundamental data provider</param>
46
/// <param name="liveMode">True if running in live mode</param>
47
public
static
void
Initialize
(
IDataProvider
dataProvider,
string
fundamentalDataProvider,
bool
liveMode)
48
{
49
Initialize
(dataProvider,
Composer
.
Instance
.GetExportedValueByTypeName<
IFundamentalDataProvider
>(fundamentalDataProvider), liveMode);
50
}
51
52
/// <summary>
53
/// Initializes the service
54
/// </summary>
55
/// <param name="dataProvider">The data provider instance to use</param>
56
/// <param name="fundamentalDataProvider">The fundamental data provider</param>
57
/// <param name="liveMode">True if running in live mode</param>
58
public
static
void
Initialize
(
IDataProvider
dataProvider,
IFundamentalDataProvider
fundamentalDataProvider,
bool
liveMode)
59
{
60
_fundamentalDataProvider = fundamentalDataProvider;
61
_fundamentalDataProvider.
Initialize
(dataProvider, liveMode);
62
}
63
64
/// <summary>
65
/// Will fetch the requested fundamental information for the requested time and symbol
66
/// </summary>
67
/// <typeparam name="T">The expected data type</typeparam>
68
/// <param name="time">The time to request this data for</param>
69
/// <param name="symbol">The symbol instance</param>
70
/// <param name="name">The name of the fundamental property</param>
71
/// <returns>The fundamental information</returns>
72
public
static
T
Get<T>
(DateTime time,
Symbol
symbol,
FundamentalProperty
name) =>
Get<T>
(time, symbol.ID, name);
73
74
/// <summary>
75
/// Will fetch the requested fundamental information for the requested time and symbol
76
/// </summary>
77
/// <typeparam name="T">The expected data type</typeparam>
78
/// <param name="time">The time to request this data for</param>
79
/// <param name="securityIdentifier">The security identifier</param>
80
/// <param name="name">The name of the fundamental property</param>
81
/// <returns>The fundamental information</returns>
82
public
static
T
Get<T>
(DateTime time,
SecurityIdentifier
securityIdentifier,
FundamentalProperty
name)
83
{
84
return
_fundamentalDataProvider.Get<T>(time.Date, securityIdentifier, name);
85
}
86
}
87
}
Common
Data
UniverseSelection
FundamentalService.cs
Generated by
1.8.17