фиксация
test / deploy_trader_prod (push) Successful in 2m41s Details

dev
vlad zverzhkhovskiy 2025-09-24 14:45:16 +03:00
parent 3afd839265
commit ac7c985019
3 changed files with 47 additions and 1 deletions

View File

@ -9,6 +9,7 @@
public decimal Mediana { get; init; }
public decimal Upper30Decil { get; init; }
public decimal Lower20Decil { get; init; }
public int Length { get; init; }
public DateTime LastTime { get; init; }
public DateTime StartTime { get; init; }
public bool IsEmpty => this == Empty;

View File

@ -2,6 +2,7 @@
using KLHZ.Trader.Core.Math.Declisions.Dtos.FFT.Enums;
using MathNet.Numerics;
using MathNet.Numerics.IntegralTransforms;
using static System.Runtime.InteropServices.JavaScript.JSType;
namespace KLHZ.Trader.Core.Math.Declisions.Utils
{
@ -51,6 +52,48 @@ namespace KLHZ.Trader.Core.Math.Declisions.Utils
Lower20Decil = newValues[(int)(newValues.Length * 0.2)],
Max = newValues.Max(),
Min = newValues.Min(),
Length = values.Length,
};
}
public static FFTAnalyzeResult ReAnalyze(FFTAnalyzeResult result, string key, TimeSpan minPeriod, TimeSpan maxPeriod)
{
var tmp = new List<Harmonic>();
for (int i = 0; i < result.Harmonics.Length; i++)
{
var per = CaclHarmonycPeriod(result.LastTime - result.StartTime, result.Length, i);
if (per >= minPeriod && per <= maxPeriod)
{
tmp.Add(result.Harmonics[i]);
}
}
var harms = tmp.ToArray();
var newValues = new decimal[result.Length];
var newValues2 = new decimal[result.Length];
var time = result.StartTime;
var dt = (result.LastTime - result.StartTime).TotalSeconds / result.Length;
for (int i = 0; i < result.Length; i++)
{
var currentTime = time.AddSeconds(i* dt);
newValues[i] = (decimal)CalcAmplitude(harms, result.StartTime, currentTime);
newValues2[i] = (decimal)CalcExtremum(harms, result.StartTime, currentTime);
}
newValues = newValues.Order().ToArray();
var ma = newValues2.Max();
var mi = newValues2.Min();
return new FFTAnalyzeResult()
{
Key = key,
Harmonics = harms,
LastTime = result.LastTime,
StartTime = result.StartTime,
Mediana = newValues[newValues.Length / 2],
Upper30Decil = newValues[(int)(newValues.Length * 0.7)],
Lower20Decil = newValues[(int)(newValues.Length * 0.2)],
Max = newValues.Max(),
Min = newValues.Min(),
};
}

View File

@ -117,8 +117,10 @@ namespace KLHZ.Trader.Core.Exchange.Services
if (data.isFullIntervalExists)
{
var interpolatedData = SignalProcessing.InterpolateData(data.timestamps, data.prices, TimeSpan.FromSeconds(5));
fft = FFT.Analyze(interpolatedData.timestamps, interpolatedData.values, message.Figi, TimeSpan.FromMinutes(3), TimeSpan.FromMinutes(40));
var fftFull = FFT.Analyze(interpolatedData.timestamps, interpolatedData.values, message.Figi+"_full", TimeSpan.FromSeconds(15), TimeSpan.FromHours(24));
fft = FFT.ReAnalyze(fftFull, message.Figi, TimeSpan.FromMinutes(3), TimeSpan.FromMinutes(40));
await _tradeDataProvider.SetFFtResult(fft);
await _tradeDataProvider.SetFFtResult(fftFull);
}
}
else