обновление алгоритма принятия решений
test / deploy_trader_prod (push) Successful in 41s
Details
test / deploy_trader_prod (push) Successful in 41s
Details
parent
59c777172e
commit
6efea45378
|
@ -32,8 +32,8 @@ namespace KLHZ.Trader.Core.Math.Declisions.Utils
|
|||
var twavss = new decimal[size];
|
||||
var twavbs = new decimal[size];
|
||||
var times = new DateTime[size];
|
||||
|
||||
for (int shift = 0; shift < size-1 && shift < prices.Length -1; shift++)
|
||||
|
||||
for (int shift = 0; shift < size - 1 && shift < prices.Length - 1; shift++)
|
||||
{
|
||||
s = shift;
|
||||
var i2 = size - 1 - shift;
|
||||
|
@ -75,7 +75,7 @@ namespace KLHZ.Trader.Core.Math.Declisions.Utils
|
|||
// если фильтрация окном 120 наползает на окно 15 сверху, потенциальное время открытия лонга и закрытия шорта
|
||||
if (twavbs[size - 1] <= twavss[size - 1] && twavbs[size - 2] > twavss[size - 2])
|
||||
{
|
||||
if (pricesForFinalComparison[i2+1] - pricesForFinalComparison[size - 1] >= meanfullStep)
|
||||
if (pricesForFinalComparison[i2 + 1] - pricesForFinalComparison[size - 1] >= meanfullStep)
|
||||
{
|
||||
res |= TradingEvent.LongOpen;
|
||||
res |= TradingEvent.ShortClose;
|
||||
|
@ -86,7 +86,7 @@ namespace KLHZ.Trader.Core.Math.Declisions.Utils
|
|||
// если фильтрация окном 15 наползает на окно 120 сверху, потенциальное время закрытия лонга и возможно открытия шорта
|
||||
if (twavss[size - 1] <= twavbs[size - 1] && twavss[size - 2] > twavbs[size - 2])
|
||||
{
|
||||
if (pricesForFinalComparison[i2+1] - pricesForFinalComparison[size - 1] <= -meanfullStep)
|
||||
if (pricesForFinalComparison[i2 + 1] - pricesForFinalComparison[size - 1] <= -meanfullStep)
|
||||
{
|
||||
res |= TradingEvent.LongClose;
|
||||
res |= TradingEvent.ShortOpen;
|
||||
|
|
|
@ -31,7 +31,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
|
|||
private readonly IDataBus _dataBus;
|
||||
private readonly BotModeSwitcher _botModeSwitcher;
|
||||
private readonly IDbContextFactory<TraderDbContext> _dbContextFactory;
|
||||
private readonly ConcurrentDictionary<string, DateTime> BuyStops = new();
|
||||
private readonly ConcurrentDictionary<string, DateTime> OpeningStops = new();
|
||||
private readonly ConcurrentDictionary<string, ManagedAccount> Accounts = new();
|
||||
private readonly ConcurrentDictionary<string, IPriceHistoryCacheUnit> _historyCash = new();
|
||||
private readonly ILogger<Trader> _logger;
|
||||
|
@ -110,7 +110,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
|
|||
foreach (var stop in stops)
|
||||
{
|
||||
var time = stop.Time.AddMinutes(_buyStopLength);
|
||||
BuyStops.TryAdd(stop.Figi, time);
|
||||
OpeningStops.TryAdd(stop.Figi, time);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -137,22 +137,18 @@ namespace KLHZ.Trader.Core.Exchange.Services
|
|||
if (message.Figi == "FUTIMOEXF000")
|
||||
{
|
||||
var data = await unit.GetData();
|
||||
if (BuyStops.TryGetValue(message.Figi, out var dt))
|
||||
if (OpeningStops.TryGetValue(message.Figi, out var dt))
|
||||
{
|
||||
if (dt > (message.IsHistoricalData ? message.Time : DateTime.UtcNow))
|
||||
if (dt < (message.IsHistoricalData ? message.Time : DateTime.UtcNow))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
else
|
||||
{
|
||||
BuyStops.TryRemove(message.Figi, out _);
|
||||
OpeningStops.TryRemove(message.Figi, out _);
|
||||
}
|
||||
}
|
||||
|
||||
if ((unit.BidsCount / unit.AsksCount) < 0.5m || (unit.BidsCount / unit.AsksCount) > 2m)
|
||||
{
|
||||
var stopTo = (message.IsHistoricalData ? message.Time : DateTime.UtcNow).AddMinutes(3);
|
||||
BuyStops.AddOrUpdate(message.Figi, stopTo, (k, v) => stopTo);
|
||||
OpeningStops.AddOrUpdate(message.Figi, stopTo, (k, v) => stopTo);
|
||||
declisionsForSave.Add(new Declision()
|
||||
{
|
||||
AccountId = string.Empty,
|
||||
|
@ -191,7 +187,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
|
|||
if ((result.events & TradingEvent.StopBuy) == TradingEvent.StopBuy)
|
||||
{
|
||||
var stopTo = (message.IsHistoricalData ? message.Time : DateTime.UtcNow).AddMinutes(_buyStopLength);
|
||||
BuyStops.AddOrUpdate(message.Figi, stopTo, (k, v) => stopTo);
|
||||
OpeningStops.AddOrUpdate(message.Figi, stopTo, (k, v) => stopTo);
|
||||
declisionsForSave.Add(new Declision()
|
||||
{
|
||||
AccountId = string.Empty,
|
||||
|
@ -205,6 +201,7 @@ namespace KLHZ.Trader.Core.Exchange.Services
|
|||
}
|
||||
|
||||
if ((result.events & TradingEvent.LongOpen) == TradingEvent.LongOpen
|
||||
&& !OpeningStops.TryGetValue(message.Figi, out _)
|
||||
&& ((unit.BidsCount / unit.AsksCount) > 0.5m))
|
||||
{
|
||||
declisionsForSave.Add(new Declision()
|
||||
|
@ -231,7 +228,9 @@ namespace KLHZ.Trader.Core.Exchange.Services
|
|||
});
|
||||
}
|
||||
|
||||
if ((result.events & TradingEvent.ShortOpen) == TradingEvent.ShortOpen && (unit.BidsCount / unit.AsksCount < 2))
|
||||
if ((result.events & TradingEvent.ShortOpen) == TradingEvent.ShortOpen
|
||||
&& !OpeningStops.TryGetValue(message.Figi, out _)
|
||||
&& (unit.BidsCount / unit.AsksCount < 2))
|
||||
{
|
||||
declisionsForSave.Add(new Declision()
|
||||
{
|
||||
|
|
Loading…
Reference in New Issue