style: format code with dotnet-format

This commit fixes the style issues introduced in 1e77eb8 according to the output
from dotnet-format.

Details: None
This commit is contained in:
deepsource-autofix[bot]
2024-10-06 06:59:26 +00:00
committed by GitHub
parent 1e77eb80a4
commit 5fe968754f
116 changed files with 1773 additions and 2748 deletions
+22 -11
View File
@@ -8,7 +8,8 @@ namespace QuanTAlib;
/// of the true range. The true range is the greatest of: current high - current low,
/// absolute value of current high - previous close, or absolute value of current low - previous close.
/// </remarks>
public class Atr : AbstractBarBase {
public class Atr : AbstractBarBase
{
private readonly Ema _ma;
private double _prevClose, _p_prevClose;
@@ -19,11 +20,13 @@ public class Atr : AbstractBarBase {
/// <exception cref="ArgumentOutOfRangeException">
/// Thrown when period is less than 1.
/// </exception>
public Atr(int period) {
if (period < 1) {
public Atr(int period)
{
if (period < 1)
{
throw new ArgumentOutOfRangeException(nameof(period), "Period must be greater than or equal to 1.");
}
_ma = new(1.0/period);
_ma = new(1.0 / period);
WarmupPeriod = _ma.WarmupPeriod;
Name = $"ATR({period})";
}
@@ -33,7 +36,8 @@ public class Atr : AbstractBarBase {
/// </summary>
/// <param name="source">The source object to subscribe to for bar updates.</param>
/// <param name="period">The period over which to calculate the ATR.</param>
public Atr(object source, int period) : this(period) {
public Atr(object source, int period) : this(period)
{
var pubEvent = source.GetType().GetEvent("Pub");
pubEvent?.AddEventHandler(source, new BarSignal(Sub));
}
@@ -41,7 +45,8 @@ public class Atr : AbstractBarBase {
/// <summary>
/// Initializes the Atr instance by setting up the initial state.
/// </summary>
public override void Init() {
public override void Init()
{
base.Init();
_ma.Init();
_prevClose = double.NaN;
@@ -51,11 +56,15 @@ public class Atr : AbstractBarBase {
/// Manages the state of the Atr instance based on whether a new bar is being processed.
/// </summary>
/// <param name="isNew">Indicates whether the current input is a new bar.</param>
protected override void ManageState(bool isNew) {
if (isNew) {
protected override void ManageState(bool isNew)
{
if (isNew)
{
_index++;
_p_prevClose = _prevClose;
} else {
}
else
{
_prevClose = _p_prevClose;
}
}
@@ -71,7 +80,8 @@ public class Atr : AbstractBarBase {
/// to smooth the true range values. For the first bar, it uses the high-low range
/// as the true range.
/// </remarks>
protected override double Calculation() {
protected override double Calculation()
{
ManageState(Input.IsNew);
double trueRange = Math.Max(
@@ -81,7 +91,8 @@ public class Atr : AbstractBarBase {
),
Math.Abs(Input.Low - _prevClose)
);
if (_index < 2) {
if (_index < 2)
{
trueRange = Input.High - Input.Low;
}