From f9d24203c6afd455778be22c566729a82f009d98 Mon Sep 17 00:00:00 2001 From: claw_bot Date: Thu, 12 Mar 2026 06:08:57 +0000 Subject: [PATCH] =?UTF-8?q?=E4=BF=AE=E5=A4=8D=E8=A1=8C=E6=83=85=E7=BC=93?= =?UTF-8?q?=E5=AD=98=E5=AD=97=E6=AE=B5=E6=BA=A2=E5=87=BA=E9=97=AE=E9=A2=98?= =?UTF-8?q?=EF=BC=9A=E4=BB=B7=E6=A0=BC=E4=BF=9D=E7=95=998=E4=BD=8D?= =?UTF-8?q?=E5=B0=8F=E6=95=B0=EF=BC=8C=E5=AD=97=E6=AE=B5=E9=95=BF=E5=BA=A6?= =?UTF-8?q?=E6=89=A9=E5=B1=95=E4=B8=BA20=E4=BD=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- AssetManager.Data/MarketPriceCache.cs | 4 ++-- AssetManager.Infrastructure/Services/MarketDataService.cs | 6 +++--- 2 files changed, 5 insertions(+), 5 deletions(-) diff --git a/AssetManager.Data/MarketPriceCache.cs b/AssetManager.Data/MarketPriceCache.cs index a264d99..4fd676d 100644 --- a/AssetManager.Data/MarketPriceCache.cs +++ b/AssetManager.Data/MarketPriceCache.cs @@ -29,13 +29,13 @@ public class MarketPriceCache /// /// 最新价格 /// - [SugarColumn(DecimalDigits = 8, IsNullable = false)] + [SugarColumn(Length = 20, DecimalDigits = 8, IsNullable = false)] public decimal Price { get; set; } /// /// 前收盘价(计算当日涨跌幅用) /// - [SugarColumn(DecimalDigits = 8, IsNullable = true)] + [SugarColumn(Length = 20, DecimalDigits = 8, IsNullable = true)] public decimal? PreviousClose { get; set; } /// diff --git a/AssetManager.Infrastructure/Services/MarketDataService.cs b/AssetManager.Infrastructure/Services/MarketDataService.cs index 88c76f0..78d0c12 100644 --- a/AssetManager.Infrastructure/Services/MarketDataService.cs +++ b/AssetManager.Infrastructure/Services/MarketDataService.cs @@ -342,14 +342,14 @@ public class MarketDataService : IMarketDataService source = "Tiingo"; } - // 写入缓存 + // 写入缓存,保留8位小数,避免字段超出范围 var cacheEntity = new MarketPriceCache { Id = cacheKey, Symbol = symbol.ToUpper(), AssetType = assetType.ToUpper(), - Price = response.Price, - PreviousClose = response.PreviousClose, + Price = Math.Round(response.Price, 8), + PreviousClose = response.PreviousClose > 0 ? Math.Round(response.PreviousClose, 8) : null, Source = source, FetchedAt = DateTime.Now, ExpiredAt = GetCacheExpirationTime(assetType)