27 lines
1.0 KiB
C#
27 lines
1.0 KiB
C#
using KLHZ.Trader.Core.DataLayer.Entities.Prices;
|
|
using KLHZ.Trader.Core.Math.Common;
|
|
using KLHZ.Trader.Core.Math.Declisions.Services.Cache;
|
|
using KLHZ.Trader.Core.Math.Declisions.Utils;
|
|
|
|
namespace KLHZ.Trader.Core.Tests
|
|
{
|
|
public class MovingAverageTests
|
|
{
|
|
[Test]
|
|
public void Test1()
|
|
{
|
|
var cacheUnit = new PriceHistoryCacheUnit2("");
|
|
for (int i = 0; i < 5 * PriceHistoryCacheUnit2.CacheMaxLength; i++)
|
|
{
|
|
cacheUnit.AddData(new PriceChange() { Figi = "", Ticker = "", Value = i, Time = DateTime.UtcNow });
|
|
if (i >= 500)
|
|
{
|
|
var data = cacheUnit.GetData().Result;
|
|
Assert.IsTrue(data.prices.Length == PriceHistoryCacheUnit2.CacheMaxLength);
|
|
Assert.IsTrue(data.prices.Last() == i);
|
|
var res = MovingAverage.CheckByWindowAverageMean(data.timestamps, data.prices, 100);
|
|
}
|
|
}
|
|
}
|
|
}
|
|
} |