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)