Lean
$LEAN_TAG$
Index.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
QuantConnect
.
Orders
.
Fees
;
18
using
QuantConnect
.
Orders
.
Fills
;
19
using
QuantConnect
.
Orders
.
Slippage
;
20
21
namespace
QuantConnect.Securities.Index
22
{
23
/// <summary>
24
/// INDEX Security Object Implementation for INDEX Assets
25
/// </summary>
26
/// <seealso cref="Security"/>
27
public
class
Index
:
Security
28
{
29
private
bool
_isTradable;
30
31
/// <summary>
32
/// Gets or sets whether or not this security should be considered tradable
33
/// </summary>
34
public
override
bool
IsTradable
{
35
get
=> _isTradable;
36
set
37
{
38
if
(value) ManualSetIsTradable =
true
;
39
_isTradable = value;
40
}
41
}
42
43
/// <summary>
44
/// Field to check if the user has manually set IsTradable field to true
45
/// </summary>
46
internal
bool
ManualSetIsTradable {
get
;
set
; }
47
48
/// <summary>
49
/// Constructor for the INDEX security
50
/// </summary>
51
/// <param name="exchangeHours">Defines the hours this exchange is open</param>
52
/// <param name="quoteCurrency">The cash object that represent the quote currency</param>
53
/// <param name="config">The subscription configuration for this security</param>
54
/// <param name="symbolProperties">The symbol properties for this security</param>
55
/// <param name="currencyConverter">Currency converter used to convert <see cref="CashAmount"/>
56
/// instances into units of the account currency</param>
57
/// <param name="registeredTypes">Provides all data types registered in the algorithm</param>
58
public
Index
(
SecurityExchangeHours
exchangeHours,
59
Cash
quoteCurrency,
60
SubscriptionDataConfig
config,
61
SymbolProperties
symbolProperties,
62
ICurrencyConverter
currencyConverter,
63
IRegisteredSecurityDataTypesProvider
registeredTypes)
64
: base(config,
65
quoteCurrency,
66
symbolProperties,
67
new
IndexExchange
(exchangeHours),
68
new
IndexCache
(),
69
new
SecurityPortfolioModel
(),
70
new
ImmediateFillModel
(),
71
new
ConstantFeeModel
(0),
72
NullSlippageModel
.Instance,
73
new
ImmediateSettlementModel
(),
74
Securities.
VolatilityModel
.Null,
75
new
SecurityMarginModel
(50m),
76
new
IndexDataFilter
(),
77
new
SecurityPriceVariationModel
(),
78
currencyConverter,
79
registeredTypes,
80
Securities.
MarginInterestRateModel
.Null
81
)
82
{
83
IsTradable
=
false
;
//Index are non tradable by default
84
Holdings
=
new
IndexHolding
(
this
, currencyConverter);
85
}
86
87
/// <summary>
88
/// Constructor for the INDEX security
89
/// </summary>
90
/// <param name="symbol">The security's symbol</param>
91
/// <param name="exchangeHours">Defines the hours this exchange is open</param>
92
/// <param name="quoteCurrency">The cash object that represent the quote currency</param>
93
/// <param name="symbolProperties">The symbol properties for this security</param>
94
/// <param name="currencyConverter">Currency converter used to convert <see cref="CashAmount"/>
95
/// instances into units of the account currency</param>
96
/// <param name="registeredTypes">Provides all data types registered in the algorithm</param>
97
/// <param name="securityCache">Cache to store security information</param>
98
public
Index
(
Symbol
symbol,
99
SecurityExchangeHours
exchangeHours,
100
Cash
quoteCurrency,
101
SymbolProperties
symbolProperties,
102
ICurrencyConverter
currencyConverter,
103
IRegisteredSecurityDataTypesProvider
registeredTypes,
104
SecurityCache
securityCache)
105
: base(symbol,
106
quoteCurrency,
107
symbolProperties,
108
new
IndexExchange
(exchangeHours),
109
securityCache,
110
new
SecurityPortfolioModel
(),
111
new
ImmediateFillModel
(),
112
new
ConstantFeeModel
(0),
113
NullSlippageModel
.Instance,
114
new
ImmediateSettlementModel
(),
115
Securities.
VolatilityModel
.Null,
116
new
SecurityMarginModel
(50m),
117
new
IndexDataFilter
(),
118
new
SecurityPriceVariationModel
(),
119
currencyConverter,
120
registeredTypes,
121
Securities.
MarginInterestRateModel
.Null
122
)
123
{
124
IsTradable
=
false
;
//Index are non tradable by default
125
Holdings
=
new
IndexHolding
(
this
, currencyConverter);
126
}
127
}
128
}
Common
Securities
Index
Index.cs
Generated by
1.8.17