Postgres (#30)
* 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
This commit is contained in:
@@ -1,19 +1,15 @@
|
||||
using Microsoft.AspNetCore.Authorization;
|
||||
using Microsoft.AspNetCore.Mvc;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using System;
|
||||
using System.Threading.Tasks;
|
||||
using System.Collections.Generic;
|
||||
using Managing.Application.Abstractions;
|
||||
using Managing.Application.Abstractions;
|
||||
using Managing.Application.Abstractions.Services;
|
||||
using Managing.Domain.MoneyManagements;
|
||||
using Managing.Domain.Strategies;
|
||||
using Managing.Domain.Scenarios;
|
||||
using Managing.Domain.Users;
|
||||
using static Managing.Common.Enums;
|
||||
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]")]
|
||||
@@ -22,28 +18,58 @@ 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 ActionResult SetupSettings()
|
||||
public async Task<ActionResult<bool>> SetupSettings()
|
||||
{
|
||||
return Ok(_settingsService.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()
|
||||
{
|
||||
return Ok(await _settingsService.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>
|
||||
/// <returns>A result indicating if the default configuration was created successfully.</returns>
|
||||
[HttpPost]
|
||||
[Route("create-default-config")]
|
||||
public async Task<ActionResult<bool>> CreateDefaultConfiguration()
|
||||
@@ -52,9 +78,12 @@ public class SettingsController : BaseController
|
||||
{
|
||||
var user = await GetUser();
|
||||
if (user == null)
|
||||
return Unauthorized("User not found");
|
||||
{
|
||||
return Unauthorized("User not found or authentication failed");
|
||||
}
|
||||
|
||||
return Ok(await _settingsService.CreateDefaultConfiguration(user));
|
||||
var result = await _settingsService.CreateDefaultConfiguration(user);
|
||||
return Ok(result);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
||||
Reference in New Issue
Block a user