mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-19 19:18:05 +00:00
Afirma + documentation +semver: patch
This commit is contained in:
@@ -7,8 +7,8 @@ namespace QuanTAlib;
|
||||
public class CircularBuffer : IEnumerable<double>
|
||||
{
|
||||
private readonly double[] _buffer;
|
||||
private int _start;
|
||||
private int _size;
|
||||
private int _start = 0;
|
||||
private int _size = 0;
|
||||
|
||||
public int Capacity { get; }
|
||||
public int Count => _size;
|
||||
@@ -69,9 +69,7 @@ public class CircularBuffer : IEnumerable<double>
|
||||
public double Newest()
|
||||
{
|
||||
if (_size == 0)
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
return _buffer[(_start + _size - 1) % Capacity];
|
||||
}
|
||||
|
||||
@@ -79,9 +77,7 @@ public class CircularBuffer : IEnumerable<double>
|
||||
public double Oldest()
|
||||
{
|
||||
if (_size == 0)
|
||||
{
|
||||
ThrowInvalidOperationException();
|
||||
}
|
||||
return _buffer[_start];
|
||||
}
|
||||
|
||||
@@ -113,9 +109,7 @@ public class CircularBuffer : IEnumerable<double>
|
||||
public bool MoveNext()
|
||||
{
|
||||
if (_index + 1 >= _buffer._size)
|
||||
{
|
||||
return false;
|
||||
}
|
||||
|
||||
_index++;
|
||||
_current = _buffer[_index];
|
||||
@@ -131,9 +125,7 @@ public class CircularBuffer : IEnumerable<double>
|
||||
_current = default;
|
||||
}
|
||||
|
||||
public void Dispose() {
|
||||
// not implemented
|
||||
}
|
||||
public void Dispose() { }
|
||||
}
|
||||
|
||||
[MethodImpl(MethodImplOptions.AggressiveInlining)]
|
||||
|
||||
+5
-5
@@ -54,11 +54,11 @@ public class TBarSeries : List<TBar>
|
||||
{
|
||||
private readonly TBar Default = new(DateTime.MinValue, double.NaN, double.NaN, double.NaN, double.NaN, double.NaN);
|
||||
|
||||
public TSeries Open { get; set; }
|
||||
public TSeries High { get; set; }
|
||||
public TSeries Low { get; set; }
|
||||
public TSeries Close { get; set; }
|
||||
public TSeries Volume { get; set; }
|
||||
public TSeries Open;
|
||||
public TSeries High;
|
||||
public TSeries Low;
|
||||
public TSeries Close;
|
||||
public TSeries Volume;
|
||||
|
||||
|
||||
public TBar Last => Count > 0 ? this[^1] : Default;
|
||||
|
||||
@@ -52,6 +52,12 @@ public class TSeries : List<TValue>
|
||||
var pubEvent = source.GetType().GetEvent("Pub");
|
||||
if (pubEvent != null)
|
||||
{
|
||||
/*
|
||||
var nameProperty = source.GetType().GetProperty("Name");
|
||||
if (nameProperty != null) {
|
||||
Name = nameProperty.GetValue(nameProperty)?.ToString()!;
|
||||
}
|
||||
*/
|
||||
pubEvent.AddEventHandler(source, new ValueSignal(Sub));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user