Lean
$LEAN_TAG$
AlgorithmSettings.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
.
Interfaces
;
18
using
QuantConnect
.
Securities
;
19
using
QuantConnect
.
Orders
.
Fills
;
20
21
namespace
QuantConnect
22
{
23
/// <summary>
24
/// This class includes user settings for the algorithm which can be changed in the <see cref="IAlgorithm.Initialize"/> method
25
/// </summary>
26
public
class
AlgorithmSettings
:
IAlgorithmSettings
27
{
28
/// <summary>
29
/// True if should rebalance portfolio on security changes. True by default
30
/// </summary>
31
public
bool
?
RebalancePortfolioOnSecurityChanges
{
get
;
set
; }
32
33
/// <summary>
34
/// True if should rebalance portfolio on new insights or expiration of insights. True by default
35
/// </summary>
36
public
bool
?
RebalancePortfolioOnInsightChanges
{
get
;
set
; }
37
38
/// <summary>
39
/// The absolute maximum valid total portfolio value target percentage
40
/// </summary>
41
/// <remarks>This setting is currently being used to filter out undesired target percent values,
42
/// caused by the IPortfolioConstructionModel implementation being used.
43
/// For example rounding errors, math operations</remarks>
44
public
decimal
MaxAbsolutePortfolioTargetPercentage
{
get
;
set
; }
45
46
/// <summary>
47
/// The absolute minimum valid total portfolio value target percentage
48
/// </summary>
49
/// <remarks>This setting is currently being used to filter out undesired target percent values,
50
/// caused by the IPortfolioConstructionModel implementation being used.
51
/// For example rounding errors, math operations</remarks>
52
public
decimal
MinAbsolutePortfolioTargetPercentage
{
get
;
set
; }
53
54
/// <summary>
55
/// Configurable minimum order margin portfolio percentage to ignore bad orders, orders with unrealistic small sizes
56
/// </summary>
57
/// <remarks>Default value is 0.1% of the portfolio value. This setting is useful to avoid small trading noise when using SetHoldings</remarks>
58
public
decimal
MinimumOrderMarginPortfolioPercentage
{
get
;
set
; }
59
60
/// <summary>
61
/// Gets/sets the maximum number of concurrent market data subscriptions available
62
/// </summary>
63
/// <remarks>
64
/// All securities added with <see cref="IAlgorithm.AddSecurity"/> are counted as one,
65
/// with the exception of options and futures where every single contract in a chain counts as one.
66
/// </remarks>
67
[Obsolete(
"This property is deprecated. Please observe data subscription limits set by your brokerage to avoid runtime errors."
)]
68
public
int
DataSubscriptionLimit
{
get
;
set
; } =
int
.MaxValue;
69
70
/// <summary>
71
/// Gets/sets the SetHoldings buffers value.
72
/// The buffer is used for orders not to be rejected due to volatility when using SetHoldings and CalculateOrderQuantity
73
/// </summary>
74
public
decimal?
FreePortfolioValue
{
get
;
set
; }
75
76
/// <summary>
77
/// Gets/sets the SetHoldings buffers value percentage.
78
/// This percentage will be used to set the <see cref="FreePortfolioValue"/>
79
/// based on the <see cref="SecurityPortfolioManager.TotalPortfolioValue"/>
80
/// </summary>
81
public
decimal
FreePortfolioValuePercentage
{
get
;
set
; }
82
83
/// <summary>
84
/// Gets/sets if Liquidate() is enabled
85
/// </summary>
86
public
bool
LiquidateEnabled
{
get
;
set
; }
87
88
/// <summary>
89
/// Gets/sets the minimum time span elapsed to consider a market fill price as stale (defaults to one hour)
90
/// </summary>
91
/// <remarks>
92
/// In the default fill models, a warning message will be added to market order fills
93
/// if this time span (or more) has elapsed since the price was last updated.
94
/// </remarks>
95
/// <seealso cref="FillModel"/>
96
/// <seealso cref="ImmediateFillModel"/>
97
public
TimeSpan
StalePriceTimeSpan
{
get
;
set
; }
98
99
/// <summary>
100
/// The warmup resolution to use if any
101
/// </summary>
102
/// <remarks>This allows improving the warmup speed by setting it to a lower resolution than the one added in the algorithm</remarks>
103
public
Resolution
?
WarmupResolution
{
get
;
set
; }
104
105
/// <summary>
106
/// The warmup resolution to use if any
107
/// </summary>
108
/// <remarks>This allows improving the warmup speed by setting it to a lower resolution than the one added in the algorithm.
109
/// Pass through version to be user friendly</remarks>
110
public
Resolution
?
WarmUpResolution
111
{
112
get
113
{
114
return
WarmupResolution
;
115
}
116
set
117
{
118
WarmupResolution
= value;
119
}
120
}
121
122
/// <summary>
123
/// Number of trading days per year for this Algorithm's portfolio statistics.
124
/// </summary>
125
/// <remarks>Effect on
126
/// <see cref="Statistics.PortfolioStatistics.AnnualVariance"/>,
127
/// <seealso cref="Statistics.PortfolioStatistics.AnnualStandardDeviation"/>,
128
/// <seealso cref="Statistics.PortfolioStatistics.SharpeRatio"/>,
129
/// <seealso cref="Statistics.PortfolioStatistics.SortinoRatio"/>,
130
/// <seealso cref="Statistics.PortfolioStatistics.TrackingError"/>,
131
/// <seealso cref="Statistics.PortfolioStatistics.InformationRatio"/>.
132
/// </remarks>
133
public
int
?
TradingDaysPerYear
{
get
;
set
; }
134
135
/// <summary>
136
/// Initializes a new instance of the <see cref="AlgorithmSettings"/> class
137
/// </summary>
138
public
AlgorithmSettings
()
139
{
140
LiquidateEnabled
=
true
;
141
FreePortfolioValuePercentage
= 0.0025m;
142
// Because the free portfolio value has a trailing behavior by default, let's add a default minimum order margin portfolio percentage
143
// to avoid tiny trades when rebalancing, defaulting to 0.1% of the TPV
144
MinimumOrderMarginPortfolioPercentage
= 0.001m;
145
StalePriceTimeSpan
=
Time
.
OneHour
;
146
MaxAbsolutePortfolioTargetPercentage
= 1000000000;
147
MinAbsolutePortfolioTargetPercentage
= 0.0000000001m;
148
}
149
}
150
}
Common
AlgorithmSettings.cs
Generated by
1.8.17