实现策略引擎核心功能,包括三种策略计算器和相关DTO定义: 1. 添加双均线策略(ma_trend)计算器 2. 添加吊灯止损策略(chandelier_exit)计算器 3. 添加风险平价策略(risk_parity)计算器 4. 定义策略类型常量类和策略配置DTO 5. 实现策略引擎服务接口和扩展方法 6. 更新项目引用和README文档
26 lines
799 B
C#
26 lines
799 B
C#
using AssetManager.Infrastructure.StrategyEngine.Calculators;
|
|
using Microsoft.Extensions.DependencyInjection;
|
|
|
|
namespace AssetManager.Infrastructure.StrategyEngine;
|
|
|
|
/// <summary>
|
|
/// 策略引擎服务注册扩展
|
|
/// </summary>
|
|
public static class StrategyEngineExtensions
|
|
{
|
|
/// <summary>
|
|
/// 注册策略引擎及所有计算器
|
|
/// </summary>
|
|
public static IServiceCollection AddStrategyEngine(this IServiceCollection services)
|
|
{
|
|
// 注册策略计算器
|
|
services.AddScoped<IStrategyCalculator, MaTrendCalculator>();
|
|
services.AddScoped<IStrategyCalculator, ChandelierExitCalculator>();
|
|
services.AddScoped<IStrategyCalculator, RiskParityCalculator>();
|
|
|
|
// 注册策略引擎
|
|
services.AddScoped<IStrategyEngine, StrategyEngine>();
|
|
|
|
return services;
|
|
}
|
|
} |