From e7a551ea8bda6202154d3ebade3664dc796023bf Mon Sep 17 00:00:00 2001 From: claw_bot Date: Thu, 12 Mar 2026 06:22:52 +0000 Subject: [PATCH 1/2] =?UTF-8?q?=E4=BF=AE=E5=A4=8Ddecimal=E5=AD=97=E6=AE=B5?= =?UTF-8?q?=E5=AE=9A=E4=B9=89=E9=94=99=E8=AF=AF=EF=BC=9A=E7=BB=9F=E4=B8=80?= =?UTF-8?q?=E4=BB=B7=E6=A0=BC=E5=AD=97=E6=AE=B5=E4=B8=BAdecimal(18,8)?= =?UTF-8?q?=EF=BC=8C=E6=88=90=E4=BA=A4=E9=87=8F=E4=B8=BAdecimal(24,8)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AssetManager.Data/MarketKlineCache.cs | 10 +++++----- AssetManager.Data/MarketPriceCache.cs | 4 ++-- 2 files changed, 7 insertions(+), 7 deletions(-) diff --git a/AssetManager.Data/MarketKlineCache.cs b/AssetManager.Data/MarketKlineCache.cs index cd75e72..dc7de21 100644 --- a/AssetManager.Data/MarketKlineCache.cs +++ b/AssetManager.Data/MarketKlineCache.cs @@ -41,31 +41,31 @@ public class MarketKlineCache /// /// 开盘价 /// - [SugarColumn(DecimalDigits = 8, IsNullable = false)] + [SugarColumn(DecimalDigits = 8, Length = 18, IsNullable = false)] public decimal Open { get; set; } /// /// 最高价 /// - [SugarColumn(DecimalDigits = 8, IsNullable = false)] + [SugarColumn(DecimalDigits = 8, Length = 18, IsNullable = false)] public decimal High { get; set; } /// /// 最低价 /// - [SugarColumn(DecimalDigits = 8, IsNullable = false)] + [SugarColumn(DecimalDigits = 8, Length = 18, IsNullable = false)] public decimal Low { get; set; } /// /// 收盘价 /// - [SugarColumn(DecimalDigits = 8, IsNullable = false)] + [SugarColumn(DecimalDigits = 8, Length = 18, IsNullable = false)] public decimal Close { get; set; } /// /// 成交量 /// - [SugarColumn(DecimalDigits = 8, IsNullable = true)] + [SugarColumn(DecimalDigits = 8, Length = 24, IsNullable = true)] public decimal? Volume { get; set; } /// diff --git a/AssetManager.Data/MarketPriceCache.cs b/AssetManager.Data/MarketPriceCache.cs index 4fd676d..f61ba11 100644 --- a/AssetManager.Data/MarketPriceCache.cs +++ b/AssetManager.Data/MarketPriceCache.cs @@ -29,13 +29,13 @@ public class MarketPriceCache /// /// 最新价格 /// - [SugarColumn(Length = 20, DecimalDigits = 8, IsNullable = false)] + [SugarColumn(DecimalDigits = 8, Length = 18, IsNullable = false)] public decimal Price { get; set; } /// /// 前收盘价(计算当日涨跌幅用) /// - [SugarColumn(Length = 20, DecimalDigits = 8, IsNullable = true)] + [SugarColumn(DecimalDigits = 8, Length = 18, IsNullable = true)] public decimal? PreviousClose { get; set; } /// From 447eb9ef4fa5e2ac9250bc19762f814629d156f8 Mon Sep 17 00:00:00 2001 From: claw_bot Date: Thu, 12 Mar 2026 06:26:57 +0000 Subject: [PATCH 2/2] =?UTF-8?q?=E7=A7=BB=E9=99=A4=E6=97=A0=E7=94=A8?= =?UTF-8?q?=E7=9A=84=E4=BB=B7=E6=A0=BCClamp=E6=A3=80=E6=B5=8B=EF=BC=8C?= =?UTF-8?q?=E4=BB=85=E4=BF=9D=E7=95=998=E4=BD=8D=E5=B0=8F=E6=95=B0?= =?UTF-8?q?=E6=88=AA=E6=96=AD?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AssetManager.Infrastructure/Services/MarketDataService.cs | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/AssetManager.Infrastructure/Services/MarketDataService.cs b/AssetManager.Infrastructure/Services/MarketDataService.cs index 87102ac..b440fa4 100644 --- a/AssetManager.Infrastructure/Services/MarketDataService.cs +++ b/AssetManager.Infrastructure/Services/MarketDataService.cs @@ -342,14 +342,14 @@ public class MarketDataService : IMarketDataService source = "Tiingo"; } - // 写入缓存,保留8位小数,强制转换为12位整数+8位小数,避免MySql字段溢出 + // 写入缓存,保留8位小数 var cacheEntity = new MarketPriceCache { Id = cacheKey, Symbol = symbol.ToUpper(), AssetType = assetType.ToUpper(), - Price = Math.Round(Math.Clamp(response.Price, 0, 999999999999.99999999m), 8), - PreviousClose = response.PreviousClose > 0 ? Math.Round(Math.Clamp(response.PreviousClose.Value, 0, 999999999999.99999999m), 8) : null, + Price = Math.Round(response.Price, 8), + PreviousClose = response.PreviousClose > 0 ? Math.Round(response.PreviousClose.Value, 8) : null, Source = source, FetchedAt = DateTime.Now, ExpiredAt = GetCacheExpirationTime(assetType)