feat: 添加列表接口价格获取详细日志
定位组合收益率显示为 0 的问题: - 记录每个股票的价格获取结果 - 记录价格字典查找情况 - 区分价格获取失败 vs 价格为 0 的情况
This commit is contained in:
parent
c0accdc903
commit
7bf687323d
@ -213,6 +213,11 @@ public class PortfolioService : IPortfolioService
|
|||||||
if (price != null)
|
if (price != null)
|
||||||
{
|
{
|
||||||
priceDict[code] = price;
|
priceDict[code] = price;
|
||||||
|
_logger.LogInformation("批量获取价格成功: {Code} -> Price={Price}, PreviousClose={PreviousClose}", code, price.Price, price.PreviousClose);
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.LogWarning("批量获取价格返回 null: {Code}", code);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -246,7 +251,16 @@ public class PortfolioService : IPortfolioService
|
|||||||
{
|
{
|
||||||
currentPrice = priceResponse.Price;
|
currentPrice = priceResponse.Price;
|
||||||
previousClose = priceResponse.PreviousClose > 0 ? priceResponse.PreviousClose : currentPrice;
|
previousClose = priceResponse.PreviousClose > 0 ? priceResponse.PreviousClose : currentPrice;
|
||||||
|
_logger.LogInformation("组合 {PortfolioId} 持仓 {StockCode} 使用实时价格: {Price}", p.Id, pos.StockCode, currentPrice);
|
||||||
}
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.LogWarning("组合 {PortfolioId} 持仓 {StockCode} 价格为 0,使用成本价", p.Id, pos.StockCode);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
_logger.LogWarning("组合 {PortfolioId} 持仓 {StockCode} 未在价格字典中,使用成本价", p.Id, pos.StockCode);
|
||||||
}
|
}
|
||||||
|
|
||||||
decimal positionValue = pos.Shares * currentPrice;
|
decimal positionValue = pos.Shares * currentPrice;
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user