添加价格范围限制,确保不超过decimal(20,8)最大范围
This commit is contained in:
parent
f9d24203c6
commit
a62d892b4b
@ -342,14 +342,14 @@ public class MarketDataService : IMarketDataService
|
|||||||
source = "Tiingo";
|
source = "Tiingo";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 写入缓存,保留8位小数,避免字段超出范围
|
// 写入缓存,保留8位小数,强制转换为12位整数+8位小数,避免MySql字段溢出
|
||||||
var cacheEntity = new MarketPriceCache
|
var cacheEntity = new MarketPriceCache
|
||||||
{
|
{
|
||||||
Id = cacheKey,
|
Id = cacheKey,
|
||||||
Symbol = symbol.ToUpper(),
|
Symbol = symbol.ToUpper(),
|
||||||
AssetType = assetType.ToUpper(),
|
AssetType = assetType.ToUpper(),
|
||||||
Price = Math.Round(response.Price, 8),
|
Price = Math.Round(Math.Clamp(response.Price, 0, 999999999999.99999999m), 8),
|
||||||
PreviousClose = response.PreviousClose > 0 ? Math.Round(response.PreviousClose, 8) : null,
|
PreviousClose = response.PreviousClose > 0 ? Math.Round(Math.Clamp(response.PreviousClose.Value, 0, 999999999999.99999999m), 8) : null,
|
||||||
Source = source,
|
Source = source,
|
||||||
FetchedAt = DateTime.Now,
|
FetchedAt = DateTime.Now,
|
||||||
ExpiredAt = GetCacheExpirationTime(assetType)
|
ExpiredAt = GetCacheExpirationTime(assetType)
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user