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:
Oda
2025-07-27 15:42:17 +02:00
committed by GitHub
parent 361bfbf6e8
commit 422fecea7b
294 changed files with 23953 additions and 7272 deletions

View File

@@ -3,8 +3,6 @@ using System.ComponentModel.DataAnnotations;
using Exilion.TradingAtomics;
using Managing.Domain.Bots;
using Managing.Domain.Candles;
using Managing.Domain.MoneyManagements;
using Managing.Domain.Strategies;
using Managing.Domain.Strategies.Base;
using Managing.Domain.Trades;
using Managing.Domain.Users;
@@ -17,7 +15,7 @@ public class Backtest
public Backtest(
TradingBotConfig config,
List<Position> positions,
List<Signal> signals,
List<LightSignal> signals,
List<Candle> candles = null)
{
Config = config;
@@ -47,14 +45,13 @@ public class Backtest
[Required] public decimal HodlPercentage { get; set; }
[Required] public TradingBotConfig Config { get; }
[Required] public List<Position> Positions { get; }
[Required] public List<Signal> Signals { get; }
[Required] public List<LightSignal> Signals { get; }
[Required] public List<Candle> Candles { get; set; }
[Required] public DateTime StartDate { get; set; }
[Required] public DateTime EndDate { get; set; }
[Required] public PerformanceMetrics Statistics { get; set; }
[Required] public decimal Fees { get; set; }
[Required] public List<KeyValuePair<DateTime, decimal>> WalletBalances { get; set; }
[Required] public MoneyManagement OptimizedMoneyManagement { get; set; }
[Required] public User User { get; set; }
[Required] public Dictionary<IndicatorType, IndicatorsResultBase> IndicatorsValues { get; set; }
[Required] public double Score { get; set; }
@@ -75,7 +72,7 @@ public class Backtest
string accountName,
string botName,
decimal initialTradingBalance,
MoneyManagement moneyManagement = null)
LightMoneyManagement moneyManagement = null)
{
return new TradingBotConfig
{
@@ -100,16 +97,16 @@ public class Backtest
/// Creates a copy of the backtest's configuration for a new backtest.
/// Useful for running similar backtests with modified parameters.
/// </summary>
/// <param name="startDate">New start date for the backtest</param>
/// <param name="endDate">New end date for the backtest</param>
/// <param name="balance">New initial balance for the backtest</param>
/// <param name="startDate">Start date for the new backtest</param>
/// <param name="endDate">End date for the new backtest</param>
/// <param name="balance">Initial balance for the new backtest</param>
/// <param name="moneyManagement">Optional money management override</param>
/// <returns>A new TradingBotConfig for backtesting</returns>
public TradingBotConfig CreateBacktestConfig(
DateTime startDate,
DateTime endDate,
decimal balance,
MoneyManagement moneyManagement = null)
LightMoneyManagement moneyManagement = null)
{
return new TradingBotConfig
{
@@ -123,10 +120,10 @@ public class Backtest
IsForBacktest = true,
CooldownPeriod = Config.CooldownPeriod,
MaxLossStreak = Config.MaxLossStreak,
MaxPositionTimeHours = Config.MaxPositionTimeHours, // Properly copy nullable value
MaxPositionTimeHours = Config.MaxPositionTimeHours,
FlipOnlyWhenInProfit = Config.FlipOnlyWhenInProfit,
FlipPosition = Config.FlipPosition,
Name = $"Backtest-{Config.ScenarioName}-{DateTime.UtcNow:yyyyMMdd-HHmmss}"
Name = Config.Name
};
}