Files
managing-apps/src/Managing.Domain/Strategies/Indicator.cs
Oda a547c4a040 Add synthApi (#27)
* Add synthApi

* Put confidence for Synth proba

* Update the code

* Update readme

* Fix bootstraping

* fix github build

* Update the endpoints for scenario

* Add scenario and update backtest modal

* Update bot modal

* Update interfaces for synth

* add synth to backtest

* Add Kelly criterion and better signal

* Update signal confidence

* update doc

* save leaderboard and prediction

* Update nswag to generate ApiClient in the correct path

* Unify the trading modal

* Save miner and prediction

* Update messaging and block new signal until position not close when flipping off

* Rename strategies to indicators

* Update doc

* Update chart + add signal name

* Fix signal direction

* Update docker webui

* remove crypto npm

* Clean
2025-07-03 00:13:42 +07:00

71 lines
2.1 KiB
C#

using System.Runtime.Serialization;
using System.Text.Json.Serialization;
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; }
[JsonIgnore] [IgnoreDataMember] 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<Signal> Run()
{
return new List<Signal>();
}
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;
}
}
}