Enhance user settings management by adding new properties and updating related functionality

This commit introduces additional user settings properties, including TrendStrongAgreementThreshold, SignalAgreementThreshold, AllowSignalTrendOverride, and DefaultExchange, to the User entity and associated DTOs. The UserController and UserService are updated to handle these new settings, allowing users to customize their trading configurations more effectively. Database migrations are also included to ensure proper schema updates for the new fields.
This commit is contained in:
2025-12-30 06:48:08 +07:00
parent 79d8a381d9
commit aa3b06bbe4
26 changed files with 5909 additions and 57 deletions

View File

@@ -19,14 +19,20 @@ public class UserEntity
public DateTimeOffset? LastConnectionDate { get; set; }
public bool IsAdmin { get; set; }
// User Settings
[Column(TypeName = "decimal(18,8)")] public decimal? LowEthAmountAlert { get; set; }
// User Settings - Trading Configuration
[Column(TypeName = "decimal(18,8)")] public decimal? LowEthAmountAlert { get; set; } = 1.5m; // Default: MinimumTradeEthBalanceUsd
public bool EnableAutoswap { get; set; } = false;
[Column(TypeName = "decimal(18,8)")] public decimal? AutoswapAmount { get; set; }
public int? MaxWaitingTimeForPositionToGetFilledSeconds { get; set; }
[Column(TypeName = "decimal(18,8)")] public decimal? MaxTxnGasFeePerPosition { get; set; }
[Column(TypeName = "decimal(18,8)")] public decimal? AutoswapAmount { get; set; } = 3m; // Default: AutoSwapAmount
public int? MaxWaitingTimeForPositionToGetFilledSeconds { get; set; } = 600; // Default: 10 minutes (600 seconds)
[Column(TypeName = "decimal(18,8)")] public decimal? MaxTxnGasFeePerPosition { get; set; } = 1.5m; // Default: MaximumGasFeeUsd
public bool IsGmxEnabled { get; set; } = false;
public Confidence? MinimumConfidence { get; set; }
// User Settings - Indicator Combo Configuration
public Confidence? MinimumConfidence { get; set; } = Confidence.Medium; // Default: Medium confidence for context indicators
[Column(TypeName = "decimal(5,4)")] public decimal? TrendStrongAgreementThreshold { get; set; } = 0.66m; // Default: 66% agreement required
[Column(TypeName = "decimal(5,4)")] public decimal? SignalAgreementThreshold { get; set; } = 0.5m; // Default: 50% agreement required
public bool? AllowSignalTrendOverride { get; set; } = true; // Default: Allow signal strategies to override trends
public TradingExchanges? DefaultExchange { get; set; } = TradingExchanges.GmxV2; // Default exchange
// Navigation properties
public virtual ICollection<AccountEntity> Accounts { get; set; } = new List<AccountEntity>();

View File

@@ -103,6 +103,8 @@ public class ManagingDbContext : DbContext
entity.Property(e => e.TelegramChannel).HasMaxLength(255);
entity.Property(e => e.MinimumConfidence)
.HasConversion<string>(); // Store enum as string
entity.Property(e => e.DefaultExchange)
.HasConversion<string>(); // Store enum as string
// Create indexes for performance
entity.HasIndex(e => e.Name).IsUnique();

View File

@@ -141,6 +141,10 @@ public static class PostgreSqlMappers
MaxTxnGasFeePerPosition = entity.MaxTxnGasFeePerPosition,
IsGmxEnabled = entity.IsGmxEnabled,
MinimumConfidence = entity.MinimumConfidence,
TrendStrongAgreementThreshold = entity.TrendStrongAgreementThreshold,
SignalAgreementThreshold = entity.SignalAgreementThreshold,
AllowSignalTrendOverride = entity.AllowSignalTrendOverride,
DefaultExchange = entity.DefaultExchange,
Accounts = entity.Accounts?.Select(MapAccountWithoutUser).ToList() ?? new List<Account>()
};
}
@@ -183,7 +187,11 @@ public static class PostgreSqlMappers
MaxWaitingTimeForPositionToGetFilledSeconds = user.MaxWaitingTimeForPositionToGetFilledSeconds,
MaxTxnGasFeePerPosition = user.MaxTxnGasFeePerPosition,
IsGmxEnabled = user.IsGmxEnabled,
MinimumConfidence = user.MinimumConfidence
MinimumConfidence = user.MinimumConfidence,
TrendStrongAgreementThreshold = user.TrendStrongAgreementThreshold,
SignalAgreementThreshold = user.SignalAgreementThreshold,
AllowSignalTrendOverride = user.AllowSignalTrendOverride,
DefaultExchange = user.DefaultExchange
};
}

View File

@@ -264,6 +264,10 @@ public class PostgreSqlUserRepository : BaseRepositoryWithLogging, IUserReposito
existingUser.MaxTxnGasFeePerPosition = user.MaxTxnGasFeePerPosition;
existingUser.IsGmxEnabled = user.IsGmxEnabled;
existingUser.MinimumConfidence = user.MinimumConfidence;
existingUser.TrendStrongAgreementThreshold = user.TrendStrongAgreementThreshold;
existingUser.SignalAgreementThreshold = user.SignalAgreementThreshold;
existingUser.AllowSignalTrendOverride = user.AllowSignalTrendOverride;
existingUser.DefaultExchange = user.DefaultExchange;
_context.Users.Update(existingUser);