фиксация
parent
167c2ba119
commit
f4fb12407a
|
@ -1,16 +1,10 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace KLHZ.Trader.Core.Math.Declisions.Dtos
|
||||
namespace KLHZ.Trader.Core.Math.Declisions.Dtos
|
||||
{
|
||||
public class ConvolutionResult
|
||||
{
|
||||
public decimal Sum { get; set; }
|
||||
public decimal Value { get;set; }
|
||||
public decimal Value { get; set; }
|
||||
public int Shift { get; set; }
|
||||
public decimal Leverage { get; set; }
|
||||
public decimal Leverage { get; set; }
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,10 +1,4 @@
|
|||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace KLHZ.Trader.Core.Math.Declisions.Dtos
|
||||
namespace KLHZ.Trader.Core.Math.Declisions.Dtos
|
||||
{
|
||||
public class HistItem
|
||||
{
|
||||
|
|
|
@ -133,15 +133,15 @@ namespace KLHZ.Trader.Core.Math.Declisions.Utils
|
|||
public static HistItem[] CalcHistogram(ITradeDataItem[] values)
|
||||
{
|
||||
var result = new Dictionary<decimal, decimal>();
|
||||
foreach(var item in values)
|
||||
foreach (var item in values)
|
||||
{
|
||||
if (!result.TryGetValue(item.Price,out var val))
|
||||
if (!result.TryGetValue(item.Price, out var val))
|
||||
{
|
||||
result[item.Price] = 0;
|
||||
}
|
||||
result[item.Price] = val + 1;
|
||||
}
|
||||
return result.Select(r => new HistItem() { Value = r.Key, Count = r.Value }).OrderBy(i=>i.Value).ToArray();
|
||||
return result.Select(r => new HistItem() { Value = r.Key, Count = r.Value }).OrderBy(i => i.Value).ToArray();
|
||||
}
|
||||
|
||||
public static decimal[] GetParabolaCore(int leverageSize, decimal maxValue = 1)
|
||||
|
@ -163,7 +163,7 @@ namespace KLHZ.Trader.Core.Math.Declisions.Utils
|
|||
|
||||
public static ConvolutionResult[] CalcConvolution(HistItem[] hist, int leverageSize)
|
||||
{
|
||||
if (hist.Length>2* leverageSize+1)
|
||||
if (hist.Length > 2 * leverageSize + 1)
|
||||
{
|
||||
var results = new List<ConvolutionResult>();
|
||||
var coreSize = 2 * leverageSize + 1;
|
||||
|
@ -174,15 +174,15 @@ namespace KLHZ.Trader.Core.Math.Declisions.Utils
|
|||
for (int i = 0; i < 2 * leverageSize + 1; i++)
|
||||
{
|
||||
var core = GetParabolaCore(leverageSize, hist[i + shift].Count);
|
||||
s += (hist[i + shift].Count - core[i])*(hist[i + shift].Count - core[i]);
|
||||
if (i== leverageSize)
|
||||
s += (hist[i + shift].Count - core[i]) * (hist[i + shift].Count - core[i]);
|
||||
if (i == leverageSize)
|
||||
{
|
||||
k = i + shift;
|
||||
}
|
||||
}
|
||||
s = s / coreSize;
|
||||
s = (decimal)System.Math.Pow((double)s, 0.5d);
|
||||
//s /= coreSum;
|
||||
//s /= coreSum;
|
||||
results.Add(new ConvolutionResult()
|
||||
{
|
||||
Leverage = leverageSize,
|
||||
|
@ -191,7 +191,7 @@ namespace KLHZ.Trader.Core.Math.Declisions.Utils
|
|||
Shift = k,
|
||||
});
|
||||
}
|
||||
return results.OrderByDescending(r=>r.Value).ToArray();
|
||||
return results.OrderByDescending(r => r.Value).ToArray();
|
||||
}
|
||||
return Array.Empty<ConvolutionResult>();
|
||||
}
|
||||
|
|
|
@ -33,12 +33,12 @@ namespace KLHZ.Trader.Core.Tests
|
|||
}
|
||||
|
||||
|
||||
var res = Statistics.CalcHistogram(data.Select(d=>new CachedValue()
|
||||
var res = Statistics.CalcHistogram(data.Select(d => new CachedValue()
|
||||
{
|
||||
Figi ="",
|
||||
Figi = "",
|
||||
Ticker = "",
|
||||
Direction =1,
|
||||
Price = d/2,
|
||||
Direction = 1,
|
||||
Price = d / 2,
|
||||
Time = DateTime.UtcNow,
|
||||
}).ToArray());
|
||||
|
||||
|
|
|
@ -165,7 +165,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
|
|||
|
||||
if (DPricesValues.TryGetValue(message.Figi, out var olddPrice))
|
||||
{
|
||||
if (olddPrice < 0m && pricesDiff >0)
|
||||
if (olddPrice < 0m && pricesDiff > 0)
|
||||
{
|
||||
//await _tradeDataProvider.LogPrice(message, "diffs_pirson_diff_point_long_in", message.Price);
|
||||
}
|
||||
|
@ -189,7 +189,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
|
|||
});
|
||||
if (DPirsonValues.TryGetValue(message.Figi, out var olddpirs))
|
||||
{
|
||||
if (olddpirs < -0.3m && res > -0.3m && pricesDiff>0 && (tradesDiff > 0))
|
||||
if (olddpirs < -0.3m && res > -0.3m && pricesDiff > 0 && (tradesDiff > 0))
|
||||
{
|
||||
await _tradeDataProvider.LogPrice(message, "diffs_pirson_diff_point_long_in", message.Price);
|
||||
}
|
||||
|
|
|
@ -2,12 +2,10 @@ using KLHZ.Trader.Core.Contracts.Messaging.Dtos;
|
|||
using KLHZ.Trader.Core.Contracts.Messaging.Interfaces;
|
||||
using KLHZ.Trader.Core.DataLayer;
|
||||
using KLHZ.Trader.Core.DataLayer.Entities.Orders;
|
||||
using KLHZ.Trader.Core.Math.Declisions.Dtos;
|
||||
using KLHZ.Trader.Core.Math.Declisions.Utils;
|
||||
using KLHZ.Trader.Service.Models;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
using System.Linq;
|
||||
|
||||
namespace KLHZ.Trader.Service.Controllers
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue