This commit is contained in:
niannian zheng 2026-03-12 14:43:01 +08:00
commit 116216560f
3 changed files with 10 additions and 10 deletions

View File

@ -41,31 +41,31 @@ public class MarketKlineCache
/// <summary> /// <summary>
/// 开盘价 /// 开盘价
/// </summary> /// </summary>
[SugarColumn(DecimalDigits = 8, IsNullable = false)] [SugarColumn(DecimalDigits = 8, Length = 18, IsNullable = false)]
public decimal Open { get; set; } public decimal Open { get; set; }
/// <summary> /// <summary>
/// 最高价 /// 最高价
/// </summary> /// </summary>
[SugarColumn(DecimalDigits = 8, IsNullable = false)] [SugarColumn(DecimalDigits = 8, Length = 18, IsNullable = false)]
public decimal High { get; set; } public decimal High { get; set; }
/// <summary> /// <summary>
/// 最低价 /// 最低价
/// </summary> /// </summary>
[SugarColumn(DecimalDigits = 8, IsNullable = false)] [SugarColumn(DecimalDigits = 8, Length = 18, IsNullable = false)]
public decimal Low { get; set; } public decimal Low { get; set; }
/// <summary> /// <summary>
/// 收盘价 /// 收盘价
/// </summary> /// </summary>
[SugarColumn(DecimalDigits = 8, IsNullable = false)] [SugarColumn(DecimalDigits = 8, Length = 18, IsNullable = false)]
public decimal Close { get; set; } public decimal Close { get; set; }
/// <summary> /// <summary>
/// 成交量 /// 成交量
/// </summary> /// </summary>
[SugarColumn(DecimalDigits = 8, IsNullable = true)] [SugarColumn(DecimalDigits = 8, Length = 24, IsNullable = true)]
public decimal? Volume { get; set; } public decimal? Volume { get; set; }
/// <summary> /// <summary>

View File

@ -29,13 +29,13 @@ public class MarketPriceCache
/// <summary> /// <summary>
/// 最新价格 /// 最新价格
/// </summary> /// </summary>
[SugarColumn(Length = 20, DecimalDigits = 8, IsNullable = false)] [SugarColumn(DecimalDigits = 8, Length = 18, IsNullable = false)]
public decimal Price { get; set; } public decimal Price { get; set; }
/// <summary> /// <summary>
/// 前收盘价(计算当日涨跌幅用) /// 前收盘价(计算当日涨跌幅用)
/// </summary> /// </summary>
[SugarColumn(Length = 20, DecimalDigits = 8, IsNullable = true)] [SugarColumn(DecimalDigits = 8, Length = 18, IsNullable = true)]
public decimal? PreviousClose { get; set; } public decimal? PreviousClose { get; set; }
/// <summary> /// <summary>

View File

@ -342,14 +342,14 @@ public class MarketDataService : IMarketDataService
source = "Tiingo"; source = "Tiingo";
} }
// 写入缓存保留8位小数强制转换为12位整数+8位小数避免MySql字段溢出 // 写入缓存保留8位小数
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(Math.Clamp(response.Price, 0, 999999999999.99999999m), 8), Price = Math.Round(response.Price, 8),
PreviousClose = response.PreviousClose > 0 ? Math.Round(Math.Clamp(response.PreviousClose.Value, 0, 999999999999.99999999m), 8) : null, PreviousClose = response.PreviousClose > 0 ? Math.Round(response.PreviousClose.Value, 8) : null,
Source = source, Source = source,
FetchedAt = DateTime.Now, FetchedAt = DateTime.Now,
ExpiredAt = GetCacheExpirationTime(assetType) ExpiredAt = GetCacheExpirationTime(assetType)