Merge branch 'main' of https://git.jb18cm.plus/fanfpy/AssetManager.API
This commit is contained in:
commit
e4bc793452
@ -29,13 +29,13 @@ public class MarketPriceCache
|
||||
/// <summary>
|
||||
/// 最新价格
|
||||
/// </summary>
|
||||
[SugarColumn(DecimalDigits = 8, IsNullable = false)]
|
||||
[SugarColumn(Length = 20, DecimalDigits = 8, IsNullable = false)]
|
||||
public decimal Price { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 前收盘价(计算当日涨跌幅用)
|
||||
/// </summary>
|
||||
[SugarColumn(DecimalDigits = 8, IsNullable = true)]
|
||||
[SugarColumn(Length = 20, DecimalDigits = 8, IsNullable = true)]
|
||||
public decimal? PreviousClose { get; set; }
|
||||
|
||||
/// <summary>
|
||||
|
||||
@ -342,14 +342,14 @@ public class MarketDataService : IMarketDataService
|
||||
source = "Tiingo";
|
||||
}
|
||||
|
||||
// 写入缓存
|
||||
// 写入缓存,保留8位小数,强制转换为12位整数+8位小数,避免MySql字段溢出
|
||||
var cacheEntity = new MarketPriceCache
|
||||
{
|
||||
Id = cacheKey,
|
||||
Symbol = symbol.ToUpper(),
|
||||
AssetType = assetType.ToUpper(),
|
||||
Price = response.Price,
|
||||
PreviousClose = response.PreviousClose,
|
||||
Price = Math.Round(Math.Clamp(response.Price, 0, 999999999999.99999999m), 8),
|
||||
PreviousClose = response.PreviousClose > 0 ? Math.Round(Math.Clamp(response.PreviousClose.Value, 0, 999999999999.99999999m), 8) : null,
|
||||
Source = source,
|
||||
FetchedAt = DateTime.Now,
|
||||
ExpiredAt = GetCacheExpirationTime(assetType)
|
||||
|
||||
Loading…
Reference in New Issue
Block a user