mirror of
https://github.com/mihakralj/QuanTAlib.git
synced 2026-08-07 05:27:43 +00:00
dev up-to-speed
This commit is contained in:
@@ -81,7 +81,7 @@ public class EQUITY_Series : Single_TSeries_Indicator {
|
||||
if (_inmarket == 0 && TValue.v == 1) { _longbuy = true; } //out of market, enter long
|
||||
if (_inmarket == 1 && TValue.v == -1) { _longsell = true; } //long market, exit long
|
||||
|
||||
//Console.WriteLine($"{TValue.v,3}\t {(_inmarket)} : {_cash,10:f2} + {_units*_price[this.Count-1].v,7:f2} = {_equity-_capital:f2}");
|
||||
//Console.WriteLine($"{TValue.v,3}\t {(_inmarket)} : {_cash,10:f2} + {_units*_price[^1].v,7:f2} = {_equity-_capital:f2}");
|
||||
}
|
||||
inmarket.Add((TValue.t, (double)_inmarket));
|
||||
base.Add((TValue.t, _equity), update, _NaN);
|
||||
|
||||
@@ -20,9 +20,11 @@ public class TSeriesEventArgs : EventArgs {
|
||||
}
|
||||
|
||||
public class TSeries : List<(DateTime t, double v)> {
|
||||
public List<DateTime> t => this.Select(item => item.t).ToList();
|
||||
public List<double> v => this.Select(item => item.v).ToList();
|
||||
public (DateTime t, double v) Last => this[^1];
|
||||
private readonly (DateTime t, double v) Default = (DateTime.MinValue, double.NaN);
|
||||
public IEnumerable<DateTime> t => this.Select(item => item.t);
|
||||
public IEnumerable<double> v => this.Select(item => item.v);
|
||||
public (DateTime t, double v) Last => Count > 0 ? this[^1] : Default;
|
||||
|
||||
public int Length => Count;
|
||||
public string Name { get; set; }
|
||||
|
||||
@@ -35,13 +37,12 @@ public class TSeries : List<(DateTime t, double v)> {
|
||||
}
|
||||
|
||||
public virtual (DateTime t, double v) Add(double v, bool update = false) {
|
||||
var Value = (t: Count == 0 ? DateTime.Today : this[this.Count-1].t.AddDays(1), v);
|
||||
return Add(Value, update);
|
||||
return Add((t: Count == 0 ? DateTime.Today : this[^1].t.AddDays(1), v), update);
|
||||
}
|
||||
|
||||
public virtual (DateTime t, double v) Add((DateTime t, double v) TValue, bool update = false) {
|
||||
if (update) {
|
||||
this[this.Count-1] = TValue;
|
||||
this[^1] = TValue;
|
||||
}
|
||||
else {
|
||||
base.Add(TValue);
|
||||
|
||||
Reference in New Issue
Block a user