84 lines
2.1 KiB
C#
84 lines
2.1 KiB
C#
using Managing.Application.Abstractions;
|
|
using Managing.Domain.Scenarios;
|
|
using Managing.Domain.Strategies;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using static Managing.Common.Enums;
|
|
|
|
namespace Managing.Api.Controllers;
|
|
|
|
[ApiController]
|
|
[Authorize]
|
|
[Route("[controller]")]
|
|
[Produces("application/json")]
|
|
public class ScenarioController : ControllerBase
|
|
{
|
|
private readonly IScenarioService _scenarioService;
|
|
public ScenarioController(IScenarioService scenarioService)
|
|
{
|
|
_scenarioService = scenarioService;
|
|
}
|
|
|
|
[HttpGet]
|
|
public ActionResult<IEnumerable<Scenario>> GetScenarios()
|
|
{
|
|
return Ok(_scenarioService.GetScenarios());
|
|
}
|
|
|
|
[HttpPost]
|
|
public ActionResult<Scenario> CreateScenario(string name, List<string> strategies)
|
|
{
|
|
return Ok(_scenarioService.CreateScenario(name, strategies));
|
|
}
|
|
|
|
|
|
[HttpDelete]
|
|
public ActionResult DeleteScenario(string name)
|
|
{
|
|
return Ok(_scenarioService.DeleteScenario(name));
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("strategy")]
|
|
public ActionResult<IEnumerable<Strategy>> GetStrategies()
|
|
{
|
|
return Ok(_scenarioService.GetStrategies());
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("strategy")]
|
|
public ActionResult<Strategy> CreateStrategy(
|
|
StrategyType strategyType,
|
|
Timeframe timeframe,
|
|
string name,
|
|
int? period = null,
|
|
int? fastPeriods = null,
|
|
int? slowPeriods = null,
|
|
int? signalPeriods = null,
|
|
double? multiplier = null,
|
|
int? stochPeriods = null,
|
|
int? smoothPeriods = null,
|
|
int? cyclePeriods = null)
|
|
{
|
|
return Ok(_scenarioService.CreateStrategy(
|
|
strategyType,
|
|
timeframe,
|
|
name,
|
|
period,
|
|
fastPeriods,
|
|
slowPeriods,
|
|
signalPeriods,
|
|
multiplier,
|
|
stochPeriods,
|
|
smoothPeriods,
|
|
cyclePeriods));
|
|
}
|
|
|
|
[HttpDelete]
|
|
[Route("strategy")]
|
|
public ActionResult DeleteStrategy(string name)
|
|
{
|
|
return Ok(_scenarioService.DeleteStrategy(name));
|
|
}
|
|
}
|