Lean  $LEAN_TAG$
StockholdersEquityGrowth.cs
1 /*
2  * QUANTCONNECT.COM - Democratizing Finance, Empowering Individuals.
3  * Lean Algorithmic Trading Engine v2.0. Copyright 2023 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 
17 using System;
18 using System.Linq;
19 using Python.Runtime;
20 using Newtonsoft.Json;
21 using System.Collections.Generic;
23 
25 {
26  /// <summary>
27  /// The growth in the stockholder's equity on a percentage basis. Morningstar calculates the growth percentage based on the residual interest in the assets of the enterprise that remains after deducting its liabilities reported in the Balance Sheet within the company filings or reports.
28  /// </summary>
30  {
31  /// <summary>
32  /// The default period
33  /// </summary>
34  protected override string DefaultPeriod => "OneYear";
35 
36  /// <summary>
37  /// Gets/sets the OneYear period value for the field
38  /// </summary>
39  [JsonProperty("1Y")]
40  public double OneYear => FundamentalService.Get<double>(TimeProvider.GetUtcNow(), SecurityIdentifier, FundamentalProperty.OperationRatios_StockholdersEquityGrowth_OneYear);
41 
42  /// <summary>
43  /// Gets/sets the ThreeYears period value for the field
44  /// </summary>
45  [JsonProperty("3Y")]
46  public double ThreeYears => FundamentalService.Get<double>(TimeProvider.GetUtcNow(), SecurityIdentifier, FundamentalProperty.OperationRatios_StockholdersEquityGrowth_ThreeYears);
47 
48  /// <summary>
49  /// Gets/sets the FiveYears period value for the field
50  /// </summary>
51  [JsonProperty("5Y")]
52  public double FiveYears => FundamentalService.Get<double>(TimeProvider.GetUtcNow(), SecurityIdentifier, FundamentalProperty.OperationRatios_StockholdersEquityGrowth_FiveYears);
53 
54  /// <summary>
55  /// Returns true if the field contains a value for the default period
56  /// </summary>
57  public override bool HasValue => !BaseFundamentalDataProvider.IsNone(typeof(double), FundamentalService.Get<double>(TimeProvider.GetUtcNow(), SecurityIdentifier, FundamentalProperty.OperationRatios_StockholdersEquityGrowth_OneYear));
58 
59  /// <summary>
60  /// Returns the default value for the field
61  /// </summary>
62  public override double Value
63  {
64  get
65  {
66  var defaultValue = FundamentalService.Get<double>(TimeProvider.GetUtcNow(), SecurityIdentifier, FundamentalProperty.OperationRatios_StockholdersEquityGrowth_OneYear);
67  if (!BaseFundamentalDataProvider.IsNone(typeof(double), defaultValue))
68  {
69  return defaultValue;
70  }
71  return base.Value;
72  }
73  }
74 
75  /// <summary>
76  /// Gets a dictionary of period names and values for the field
77  /// </summary>
78  /// <returns>The dictionary of period names and values</returns>
79  public override IReadOnlyDictionary<string, double> GetPeriodValues()
80  {
81  var result = new Dictionary<string, double>();
82  foreach (var kvp in new[] { new Tuple<string, double>("1Y",OneYear), new Tuple<string, double>("3Y",ThreeYears), new Tuple<string, double>("5Y",FiveYears) })
83  {
84  if(!BaseFundamentalDataProvider.IsNone(typeof(double), kvp.Item2))
85  {
86  result[kvp.Item1] = kvp.Item2;
87  }
88  }
89  return result;
90  }
91 
92  /// <summary>
93  /// Gets the value of the field for the requested period
94  /// </summary>
95  /// <param name="period">The requested period</param>
96  /// <returns>The value for the period</returns>
97  public override double GetPeriodValue(string period) => FundamentalService.Get<double>(TimeProvider.GetUtcNow(), SecurityIdentifier, Enum.Parse<FundamentalProperty>($"OperationRatios_StockholdersEquityGrowth_{ConvertPeriod(period)}"));
98 
99  /// <summary>
100  /// Creates a new empty instance
101  /// </summary>
103  {
104  }
105 
106  /// <summary>
107  /// Creates a new instance for the given time and security
108  /// </summary>
109  public StockholdersEquityGrowth(ITimeProvider timeProvider, SecurityIdentifier securityIdentifier) : base(timeProvider, securityIdentifier)
110  {
111  }
112  }
113 }