* Add postgres * Migrate users * Migrate geneticRequest * Try to fix Concurrent call * Fix asyncawait * Fix async and concurrent * Migrate backtests * Add cache for user by address * Fix backtest migration * Fix not open connection * Fix backtest command error * Fix concurrent * Fix all concurrency * Migrate TradingRepo * Fix scenarios * Migrate statistic repo * Save botbackup * Add settings et moneymanagement * Add bot postgres * fix a bit more backups * Fix bot model * Fix loading backup * Remove cache market for read positions * Add workers to postgre * Fix workers api * Reduce get Accounts for workers * Migrate synth to postgre * Fix backtest saved * Remove mongodb * botservice decorrelation * Fix tradingbot scope call * fix tradingbot * fix concurrent * Fix scope for genetics * Fix account over requesting * Fix bundle backtest worker * fix a lot of things * fix tab backtest * Remove optimized moneymanagement * Add light signal to not use User and too much property * Make money management lighter * insert indicators to awaitable * Migrate add strategies to await * Refactor scenario and indicator retrieval to use asynchronous methods throughout the application * add more async await * Add services * Fix and clean * Fix bot a bit * Fix bot and add message for cooldown * Remove fees * Add script to deploy db * Update dfeeploy script * fix script * Add idempotent script and backup * finish script migration * Fix did user and agent name on start bot
94 lines
3.0 KiB
C#
94 lines
3.0 KiB
C#
using Managing.Application.Abstractions;
|
|
using Managing.Application.Abstractions.Services;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
|
|
namespace Managing.Api.Controllers;
|
|
|
|
/// <summary>
|
|
/// Controller for managing application settings and configurations.
|
|
/// Provides endpoints for setting up default configurations and resetting settings.
|
|
/// Requires authorization for access and produces JSON responses.
|
|
/// </summary>
|
|
[ApiController]
|
|
[Authorize]
|
|
[Route("[controller]")]
|
|
[Produces("application/json")]
|
|
public class SettingsController : BaseController
|
|
{
|
|
private readonly ISettingsService _settingsService;
|
|
|
|
/// <summary>
|
|
/// Initializes a new instance of the <see cref="SettingsController"/> class.
|
|
/// </summary>
|
|
/// <param name="settingsService">The service for managing application settings.</param>
|
|
/// <param name="userService">The service for user-related operations.</param>
|
|
public SettingsController(ISettingsService settingsService, IUserService userService)
|
|
: base(userService)
|
|
{
|
|
_settingsService = settingsService;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Sets up initial application settings.
|
|
/// </summary>
|
|
/// <returns>A result indicating if the setup was successful.</returns>
|
|
[HttpPost]
|
|
public async Task<ActionResult<bool>> SetupSettings()
|
|
{
|
|
try
|
|
{
|
|
var result = await _settingsService.SetupSettings();
|
|
return Ok(result);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(500, $"Error setting up settings: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Resets all application settings to their default values.
|
|
/// </summary>
|
|
/// <returns>A result indicating if the reset was successful.</returns>
|
|
[HttpDelete]
|
|
public async Task<ActionResult<bool>> ResetSettings()
|
|
{
|
|
try
|
|
{
|
|
var result = await _settingsService.ResetSettings();
|
|
return Ok(result);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(500, $"Error resetting settings: {ex.Message}");
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Creates default configuration for backtesting including Money Management, Strategy, and Scenario
|
|
/// for the authenticated user.
|
|
/// </summary>
|
|
/// <returns>A result indicating if the default configuration was created successfully.</returns>
|
|
[HttpPost]
|
|
[Route("create-default-config")]
|
|
public async Task<ActionResult<bool>> CreateDefaultConfiguration()
|
|
{
|
|
try
|
|
{
|
|
var user = await GetUser();
|
|
if (user == null)
|
|
{
|
|
return Unauthorized("User not found or authentication failed");
|
|
}
|
|
|
|
var result = await _settingsService.CreateDefaultConfiguration(user);
|
|
return Ok(result);
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(500, $"Error creating default configuration: {ex.Message}");
|
|
}
|
|
}
|
|
}
|