修复行情缓存字段溢出问题:价格保留8位小数,字段长度扩展为20位
This commit is contained in:
parent
4ce5e1b7f9
commit
f9d24203c6
@ -29,13 +29,13 @@ public class MarketPriceCache
|
|||||||
/// <summary>
|
/// <summary>
|
||||||
/// 最新价格
|
/// 最新价格
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(DecimalDigits = 8, IsNullable = false)]
|
[SugarColumn(Length = 20, DecimalDigits = 8, IsNullable = false)]
|
||||||
public decimal Price { get; set; }
|
public decimal Price { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// 前收盘价(计算当日涨跌幅用)
|
/// 前收盘价(计算当日涨跌幅用)
|
||||||
/// </summary>
|
/// </summary>
|
||||||
[SugarColumn(DecimalDigits = 8, IsNullable = true)]
|
[SugarColumn(Length = 20, DecimalDigits = 8, IsNullable = true)]
|
||||||
public decimal? PreviousClose { get; set; }
|
public decimal? PreviousClose { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|||||||
@ -342,14 +342,14 @@ public class MarketDataService : IMarketDataService
|
|||||||
source = "Tiingo";
|
source = "Tiingo";
|
||||||
}
|
}
|
||||||
|
|
||||||
// 写入缓存
|
// 写入缓存,保留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 = response.Price,
|
Price = Math.Round(response.Price, 8),
|
||||||
PreviousClose = response.PreviousClose,
|
PreviousClose = response.PreviousClose > 0 ? Math.Round(response.PreviousClose, 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