Orlean (#32)
* 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
This commit is contained in:
@@ -1,6 +1,4 @@
|
||||
using System.Runtime.Serialization;
|
||||
using System.Text.Json.Serialization;
|
||||
using Managing.Core.FixedSizedQueue;
|
||||
using Managing.Core.FixedSizedQueue;
|
||||
using Managing.Domain.Candles;
|
||||
using Managing.Domain.Scenarios;
|
||||
using Managing.Domain.Strategies.Base;
|
||||
@@ -20,18 +18,31 @@ namespace Managing.Domain.Strategies
|
||||
}
|
||||
|
||||
public string Name { get; set; }
|
||||
[JsonIgnore] [IgnoreDataMember] public FixedSizeQueue<Candle> Candles { 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()
|
||||
|
||||
84
src/Managing.Domain/Strategies/LightIndicator.cs
Normal file
84
src/Managing.Domain/Strategies/LightIndicator.cs
Normal file
@@ -0,0 +1,84 @@
|
||||
using Managing.Domain.Scenarios;
|
||||
using Orleans;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
namespace Managing.Domain.Strategies;
|
||||
|
||||
/// <summary>
|
||||
/// Lightweight indicator class for Orleans serialization
|
||||
/// Contains only the essential properties needed for backtesting
|
||||
/// </summary>
|
||||
[GenerateSerializer]
|
||||
public class LightIndicator
|
||||
{
|
||||
public LightIndicator(string name, IndicatorType type)
|
||||
{
|
||||
Name = name;
|
||||
Type = type;
|
||||
SignalType = ScenarioHelpers.GetSignalType(type);
|
||||
}
|
||||
|
||||
[Id(0)] public string Name { get; set; }
|
||||
|
||||
[Id(1)] public IndicatorType Type { get; set; }
|
||||
|
||||
[Id(2)] public SignalType SignalType { get; set; }
|
||||
|
||||
[Id(3)] public int MinimumHistory { get; set; }
|
||||
|
||||
[Id(4)] public int? Period { get; set; }
|
||||
|
||||
[Id(5)] public int? FastPeriods { get; set; }
|
||||
|
||||
[Id(6)] public int? SlowPeriods { get; set; }
|
||||
|
||||
[Id(7)] public int? SignalPeriods { get; set; }
|
||||
|
||||
[Id(8)] public double? Multiplier { get; set; }
|
||||
|
||||
[Id(9)] public int? SmoothPeriods { get; set; }
|
||||
|
||||
[Id(10)] public int? StochPeriods { get; set; }
|
||||
|
||||
[Id(11)] public int? CyclePeriods { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// Converts a full Indicator to a LightIndicator
|
||||
/// </summary>
|
||||
public static LightIndicator FromIndicator(Indicator indicator)
|
||||
{
|
||||
return new LightIndicator(indicator.Name, indicator.Type)
|
||||
{
|
||||
SignalType = indicator.SignalType,
|
||||
MinimumHistory = indicator.MinimumHistory,
|
||||
Period = indicator.Period,
|
||||
FastPeriods = indicator.FastPeriods,
|
||||
SlowPeriods = indicator.SlowPeriods,
|
||||
SignalPeriods = indicator.SignalPeriods,
|
||||
Multiplier = indicator.Multiplier,
|
||||
SmoothPeriods = indicator.SmoothPeriods,
|
||||
StochPeriods = indicator.StochPeriods,
|
||||
CyclePeriods = indicator.CyclePeriods
|
||||
};
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Converts a LightIndicator back to a full Indicator
|
||||
/// </summary>
|
||||
public Indicator ToIndicator()
|
||||
{
|
||||
return new Indicator(Name, Type)
|
||||
{
|
||||
SignalType = SignalType,
|
||||
MinimumHistory = MinimumHistory,
|
||||
Period = Period,
|
||||
FastPeriods = FastPeriods,
|
||||
SlowPeriods = SlowPeriods,
|
||||
SignalPeriods = SignalPeriods,
|
||||
Multiplier = Multiplier,
|
||||
SmoothPeriods = SmoothPeriods,
|
||||
StochPeriods = StochPeriods,
|
||||
CyclePeriods = CyclePeriods
|
||||
};
|
||||
}
|
||||
}
|
||||
@@ -2,8 +2,10 @@ using System.ComponentModel.DataAnnotations;
|
||||
using System.Globalization;
|
||||
using Managing.Core;
|
||||
using Managing.Domain.Candles;
|
||||
using Orleans;
|
||||
using static Managing.Common.Enums;
|
||||
|
||||
[GenerateSerializer]
|
||||
public class LightSignal : ValueObject
|
||||
{
|
||||
public LightSignal(Ticker ticker, TradeDirection direction, Confidence confidence, Candle candle, DateTime date,
|
||||
@@ -24,17 +26,40 @@ public class LightSignal : ValueObject
|
||||
$"{indicatorName}-{indicatorType}-{direction}-{ticker}-{candle?.Close.ToString(CultureInfo.InvariantCulture)}-{date:yyyyMMdd-HHmmss}";
|
||||
}
|
||||
|
||||
[Id(0)]
|
||||
[Required] public SignalStatus Status { get; set; }
|
||||
|
||||
[Id(1)]
|
||||
[Required] public TradeDirection Direction { get; }
|
||||
|
||||
[Id(2)]
|
||||
[Required] public Confidence Confidence { get; set; }
|
||||
|
||||
[Id(3)]
|
||||
[Required] public Timeframe Timeframe { get; }
|
||||
|
||||
[Id(4)]
|
||||
[Required] public DateTime Date { get; private set; }
|
||||
|
||||
[Id(5)]
|
||||
[Required] public Candle Candle { get; }
|
||||
|
||||
[Id(6)]
|
||||
[Required] public string Identifier { get; }
|
||||
|
||||
[Id(7)]
|
||||
[Required] public Ticker Ticker { get; }
|
||||
|
||||
[Id(8)]
|
||||
[Required] public TradingExchanges Exchange { get; set; }
|
||||
|
||||
[Id(9)]
|
||||
[Required] public IndicatorType IndicatorType { get; set; }
|
||||
|
||||
[Id(10)]
|
||||
[Required] public SignalType SignalType { get; set; }
|
||||
|
||||
[Id(11)]
|
||||
[Required] public string IndicatorName { get; set; }
|
||||
|
||||
protected override IEnumerable<object> GetEqualityComponents()
|
||||
|
||||
Reference in New Issue
Block a user