фикс торговли
test / deploy_trader_prod (push) Successful in 4m59s Details

dev
vlad zverzhkhovskiy 2025-09-24 10:53:18 +03:00
parent ce58c7a22c
commit 39b509c0cf
3 changed files with 17 additions and 11 deletions

View File

@ -182,7 +182,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[crossings[0]] - pricesForFinalComparison[crossings[1]] >= uptrendEndingDetectionMeanfullStep)
//if (pricesForFinalComparison[crossings[0]] - pricesForFinalComparison[crossings[1]] >= uptrendEndingDetectionMeanfullStep)
{
res |= TradingEvent.UptrendEnd;
}
@ -191,7 +191,7 @@ namespace KLHZ.Trader.Core.Math.Declisions.Utils
// если фильтрация окном 120 наползает на окно 15 сверху, потенциальное время открытия лонга и закрытия шорта
if (twavss[size - 1] >= twavbs[size - 1] && twavss[size - 2] < twavbs[size - 2])
{
if (pricesForFinalComparison[crossings[0]] - pricesForFinalComparison[crossings[1]] <= uptrendStartingDetectionMeanfullStep)
//if (pricesForFinalComparison[crossings[0]] - pricesForFinalComparison[crossings[1]] <= uptrendStartingDetectionMeanfullStep)
{
res |= TradingEvent.UptrendStart;
}

View File

@ -444,6 +444,7 @@ INewPrice message, int windowMaxSize, decimal uptrendStartingDetectionMeanfullSt
{
price = await _tradeDataProvider.GetLastPrice(message.Figi);
}
price = System.Math.Round(price, 2);
var messages = new List<string>();
foreach (var asset in assets)
{
@ -458,6 +459,7 @@ INewPrice message, int windowMaxSize, decimal uptrendStartingDetectionMeanfullSt
}
if (profit > 0)
{
profit= System.Math.Round(profit, 2);
assetsForClose.Add(asset);
messages.Add($"Закрываю позицию {asset.Figi} ({(asset.Count > 0 ? "лонг" : "шорт")}) на счёте {_portfolioWrapper.Accounts[asset.AccountId].AccountName}. Количество {(long)asset.Count}, цена ~{price}, профит {profit}");
if (loggedDeclisions == 0)
@ -495,7 +497,7 @@ INewPrice message, int windowMaxSize, decimal uptrendStartingDetectionMeanfullSt
{
Text = $"Открываю позицию {message.Figi} ({(positionType == PositionType.Long ? "лонг" : "шорт")}) " +
$"на счёте {acc.AccountName}. Количество {(positionType == PositionType.Long ? "" : "-")}{count}, " +
$"цена ~{message.Value}. Стоп лосс: {(positionType == PositionType.Long ? "-" : "+")}{stopLossShift}. " +
$"цена ~{System.Math.Round(message.Value,2)}. Стоп лосс: {(positionType == PositionType.Long ? "-" : "+")}{stopLossShift}. " +
$"Тейк профит: {(positionType == PositionType.Long ? "+" : "-")}{takeProfitShift}"
});
}
@ -538,13 +540,13 @@ INewPrice message, int windowMaxSize, decimal uptrendStartingDetectionMeanfullSt
//result = MergeResults(result, resTask3.Result.ToImmutableDictionary());
result = MergeResultsMax(result, changeModeData);
result = MergeResultsMult(result, getFFTModsTask.Result);
//result = MergeResults(result, getAreasModsTask.Result);
////result = MergeResults(result, getAreasModsTask.Result);
result = MergeResultsMult(result, getSellsDiffsModsTask.Result);
result = MergeResultsMult(result, getTradingModeModsTask.Result);
if (result[TradingEvent.UptrendStart] > Constants.UppingCoefficient
&& !LongOpeningStops.ContainsKey(message.Figi)
&& state == ExchangeState.Open
// && !LongOpeningStops.ContainsKey(message.Figi)
// && state == ExchangeState.Open
)
{
var stops = GetStops(message, PositionType.Long);
@ -564,8 +566,8 @@ INewPrice message, int windowMaxSize, decimal uptrendStartingDetectionMeanfullSt
await LogDeclision(DeclisionTradeAction.ResetStopsLong, message.Value - stops.stopLoss, message.Time.AddMilliseconds(RandomNumberGenerator.GetInt32(300, 1000)), message);
}
if (result[TradingEvent.DowntrendStart] > Constants.PowerUppingCoefficient
&& !ShortOpeningStops.ContainsKey(message.Figi)
&& state == ExchangeState.Open
//&& !ShortOpeningStops.ContainsKey(message.Figi)
// && state == ExchangeState.Open
)
{
var stops = GetStops(message, PositionType.Short);
@ -806,7 +808,7 @@ INewPrice message, int windowMaxSize, decimal uptrendStartingDetectionMeanfullSt
//res[TradingEvent.UptrendStart] = Constants.UppingCoefficient;
res[TradingEvent.DowntrendEnd] = Constants.PowerUppingCoefficient;
//res[TradingEvent.UptrendEnd] = Constants.LowingCoefficient;
//res[TradingEvent.DowntrendStart] = Constants.LowingCoefficient;
res[TradingEvent.DowntrendStart] = Constants.BlockingCoefficient;
}
if (position == ValueAmplitudePosition.UpperThen30Decil)
{
@ -873,11 +875,15 @@ INewPrice message, int windowMaxSize, decimal uptrendStartingDetectionMeanfullSt
{
uptrendStartMode *= Constants.PowerUppingCoefficient;
downstartMode *= Constants.PowerUppingCoefficient;
uptrendEndMode *= Constants.BlockingCoefficient;
downtrendEndMode *= Constants.BlockingCoefficient;
}
else if (System.Math.Abs(bys_rel) > 0.3m || System.Math.Abs(sells_rel) > 0.3m)
{
uptrendStartMode *= Constants.UppingCoefficient;
downstartMode *= Constants.UppingCoefficient;
uptrendEndMode *=Constants.BlockingCoefficient;
downtrendEndMode *= Constants.BlockingCoefficient;
}
//else if (System.Math.Abs(bys_rel) <= 0.2m && System.Math.Abs(sells_rel) <= 0.2m)
//{

View File

@ -34,8 +34,8 @@ namespace KLHZ.Trader.Service.Controllers
//var figi1 = "BBG004730N88";
var figi2 = "BBG004730N88";
//var figi2 = "FUTIMOEXF000";
//var time1 = DateTime.UtcNow.AddDays(-shift ?? -7).Date;
var time1 = new DateTime(2025, 9, 23, 17, 0, 0, DateTimeKind.Utc);
var time1 = DateTime.UtcNow.AddDays(-shift ?? -7).Date;
//var time1 = new DateTime(2025, 9, 24, 7, 15, 0, DateTimeKind.Utc);
//var time2 = DateTime.UtcNow.AddMinutes(18);
using var context1 = await _dbContextFactory.CreateDbContextAsync();
context1.ChangeTracker.QueryTrackingBehavior = QueryTrackingBehavior.NoTracking;