Lean
$LEAN_TAG$
PrecalculatedSubscriptionData.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
QuantConnect
.
Data
;
17
using
System;
18
19
namespace
QuantConnect.Lean.Engine.DataFeeds
20
{
21
/// <summary>
22
/// Store data both raw and adjusted and the time at which it should be synchronized
23
/// </summary>
24
public
class
PrecalculatedSubscriptionData
:
SubscriptionData
25
{
26
private
BaseData
_normalizedData;
27
private
SubscriptionDataConfig
_config;
28
private
readonly
DataNormalizationMode
_mode;
29
30
/// <summary>
31
/// Gets the data
32
/// </summary>
33
public
override
BaseData
Data
34
{
35
get
36
{
37
if
(_config.
DataNormalizationMode
==
DataNormalizationMode
.Raw)
38
{
39
return
_data
;
40
}
41
else
if
(_config.
DataNormalizationMode
== _mode)
42
{
43
return
_normalizedData;
44
}
45
else
46
{
47
throw
new
ArgumentException($
"DataNormalizationMode.{_config.DataNormalizationMode} was requested for "
48
+ $
"symbol {_data.Symbol} but only {_mode} and Raw DataNormalizationMode are available. "
49
+
"Please configure the desired DataNormalizationMode initially when adding the Symbol"
);
50
}
51
}
52
}
53
54
/// <summary>
55
/// Initializes a new instance of the <see cref="PrecalculatedSubscriptionData"/> class
56
/// </summary>
57
/// <param name="configuration">The subscription's configuration</param>
58
/// <param name="rawData">The base data</param>
59
/// <param name="normalizedData">The normalized calculated based on raw data</param>
60
/// <param name="normalizationMode">Specifies how data is normalized</param>
61
/// <param name="emitTimeUtc">The emit time for the data</param>
62
public
PrecalculatedSubscriptionData
(
SubscriptionDataConfig
configuration,
BaseData
rawData,
BaseData
normalizedData,
DataNormalizationMode
normalizationMode, DateTime emitTimeUtc)
63
: base(rawData, emitTimeUtc)
64
{
65
_config = configuration;
66
_normalizedData = normalizedData;
67
_mode = normalizationMode;
68
}
69
}
70
}
Engine
DataFeeds
PrecalculatedSubscriptionData.cs
Generated by
1.8.17