fix: 添加缺失的 StrategySignalResponse DTO
- 新增 StrategySignalResponse 类(策略信号响应) - 新增 SignalAction 类(信号行动建议) - 修正 PortfolioFacade 属性名为 PascalCase
This commit is contained in:
parent
625bfa1624
commit
61e3023837
@ -130,3 +130,45 @@ public class StrategyListItemDto
|
||||
public DateTime CreatedAt { get; set; }
|
||||
public DateTime UpdatedAt { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 策略信号响应
|
||||
/// </summary>
|
||||
public class StrategySignalResponse
|
||||
{
|
||||
/// <summary>
|
||||
/// 信号类型:buy / sell / hold / rebalance
|
||||
/// </summary>
|
||||
public string? Signal { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 信号原因说明
|
||||
/// </summary>
|
||||
public string? Reason { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 建议操作(可选)
|
||||
/// </summary>
|
||||
public List<SignalAction>? Actions { get; set; }
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// 信号行动建议
|
||||
/// </summary>
|
||||
public class SignalAction
|
||||
{
|
||||
/// <summary>
|
||||
/// 股票代码
|
||||
/// </summary>
|
||||
public string? Symbol { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 行动类型:buy / sell
|
||||
/// </summary>
|
||||
public string? Action { get; set; }
|
||||
|
||||
/// <summary>
|
||||
/// 目标权重或数量
|
||||
/// </summary>
|
||||
public double? Target { get; set; }
|
||||
}
|
||||
|
||||
@ -98,14 +98,14 @@ public class PortfolioFacade : IPortfolioFacade
|
||||
var portfolio = _databaseService.GetPortfolioById(portfolioId, userId);
|
||||
if (portfolio == null || string.IsNullOrEmpty(portfolio.StrategyId))
|
||||
{
|
||||
return new StrategySignalResponse { signal = "hold", reason = "未绑定策略" };
|
||||
return new StrategySignalResponse { Signal = "hold", Reason = "未绑定策略" };
|
||||
}
|
||||
|
||||
// 获取策略
|
||||
var strategy = await _strategyService.GetStrategyByIdAsync(portfolio.StrategyId, userId);
|
||||
if (strategy == null)
|
||||
{
|
||||
return new StrategySignalResponse { signal = "hold", reason = "策略不存在" };
|
||||
return new StrategySignalResponse { Signal = "hold", Reason = "策略不存在" };
|
||||
}
|
||||
|
||||
// 计算信号
|
||||
|
||||
Loading…
Reference in New Issue
Block a user