* Start building with orlean * Add missing file * Serialize grain state * Remove grain and proxies * update and add plan * Update a bit * Fix backtest grain * Fix backtest grain * Clean a bit
82 lines
2.1 KiB
C#
82 lines
2.1 KiB
C#
using Managing.Core.FixedSizedQueue;
|
|
using Managing.Domain.Candles;
|
|
using Managing.Domain.Scenarios;
|
|
using Managing.Domain.Strategies.Base;
|
|
using Managing.Domain.Users;
|
|
using static Managing.Common.Enums;
|
|
|
|
namespace Managing.Domain.Strategies
|
|
{
|
|
public class Indicator : IIndicator
|
|
{
|
|
public Indicator(string name, IndicatorType type)
|
|
{
|
|
Name = name;
|
|
Type = type;
|
|
SignalType = ScenarioHelpers.GetSignalType(type);
|
|
Candles = new FixedSizeQueue<Candle>(500);
|
|
}
|
|
|
|
public string Name { get; set; }
|
|
|
|
public FixedSizeQueue<Candle> Candles { get; set; }
|
|
|
|
public IndicatorType Type { get; set; }
|
|
|
|
public SignalType SignalType { get; set; }
|
|
|
|
public int MinimumHistory { get; set; }
|
|
|
|
public int? Period { get; set; }
|
|
|
|
public int? FastPeriods { get; set; }
|
|
|
|
public int? SlowPeriods { get; set; }
|
|
|
|
public int? SignalPeriods { get; set; }
|
|
|
|
public double? Multiplier { get; set; }
|
|
|
|
public int? SmoothPeriods { get; set; }
|
|
|
|
public int? StochPeriods { get; set; }
|
|
|
|
public int? CyclePeriods { get; set; }
|
|
|
|
public User User { get; set; }
|
|
|
|
public virtual List<LightSignal> Run()
|
|
{
|
|
return new List<LightSignal>();
|
|
}
|
|
|
|
public virtual IndicatorsResultBase GetIndicatorValues()
|
|
{
|
|
return new IndicatorsResultBase();
|
|
}
|
|
|
|
public void UpdateCandles(HashSet<Candle> newCandles)
|
|
{
|
|
if (newCandles == null || newCandles.Count == 0)
|
|
{
|
|
return;
|
|
}
|
|
|
|
lock (Candles)
|
|
{
|
|
foreach (var item in newCandles.ToList())
|
|
{
|
|
if (Candles.All(c => c.Date != item.Date))
|
|
{
|
|
Candles.Enqueue(item);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
|
|
public string GetName()
|
|
{
|
|
return Name;
|
|
}
|
|
}
|
|
} |