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

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,34 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Managing.Infrastructure.Databases.Migrations
{
/// <inheritdoc />
public partial class UpdateBotBackupDataToText : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Data",
table: "BotBackups",
type: "text",
nullable: false,
oldClrType: typeof(string),
oldType: "jsonb");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "Data",
table: "BotBackups",
type: "jsonb",
nullable: false,
oldClrType: typeof(string),
oldType: "text");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,47 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Managing.Infrastructure.Databases.Migrations
{
/// <inheritdoc />
public partial class AddWorkerEntity : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Workers",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
WorkerType = table.Column<string>(type: "text", nullable: false),
StartTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
LastRunTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
ExecutionCount = table.Column<int>(type: "integer", nullable: false),
DelayTicks = table.Column<long>(type: "bigint", nullable: false),
IsActive = table.Column<bool>(type: "boolean", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Workers", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Workers_WorkerType",
table: "Workers",
column: "WorkerType",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Workers");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,85 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Managing.Infrastructure.Databases.Migrations
{
/// <inheritdoc />
public partial class AddSynthEntities : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "SynthMinersLeaderboards",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Asset = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false),
TimeIncrement = table.Column<int>(type: "integer", nullable: false),
SignalDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
IsBacktest = table.Column<bool>(type: "boolean", nullable: false),
MinersData = table.Column<string>(type: "jsonb", nullable: false),
CacheKey = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SynthMinersLeaderboards", x => x.Id);
});
migrationBuilder.CreateTable(
name: "SynthPredictions",
columns: table => new
{
Id = table.Column<Guid>(type: "uuid", nullable: false),
Asset = table.Column<string>(type: "character varying(32)", maxLength: 32, nullable: false),
MinerUid = table.Column<int>(type: "integer", nullable: false),
TimeIncrement = table.Column<int>(type: "integer", nullable: false),
TimeLength = table.Column<int>(type: "integer", nullable: false),
SignalDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
IsBacktest = table.Column<bool>(type: "boolean", nullable: false),
PredictionData = table.Column<string>(type: "jsonb", nullable: false),
CacheKey = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_SynthPredictions", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_SynthMinersLeaderboards_CacheKey",
table: "SynthMinersLeaderboards",
column: "CacheKey",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_SynthMinersLeaderboards_CreatedAt",
table: "SynthMinersLeaderboards",
column: "CreatedAt");
migrationBuilder.CreateIndex(
name: "IX_SynthPredictions_CacheKey",
table: "SynthPredictions",
column: "CacheKey",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_SynthPredictions_CreatedAt",
table: "SynthPredictions",
column: "CreatedAt");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "SynthMinersLeaderboards");
migrationBuilder.DropTable(
name: "SynthPredictions");
}
}
}

View File

@@ -0,0 +1,38 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Managing.Infrastructure.Databases.Migrations
{
/// <inheritdoc />
public partial class UpdateScoreMessageToText : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "ScoreMessage",
table: "Backtests",
type: "text",
maxLength: 1000,
nullable: false,
oldClrType: typeof(string),
oldType: "character varying(1000)",
oldMaxLength: 1000);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "ScoreMessage",
table: "Backtests",
type: "character varying(1000)",
maxLength: 1000,
nullable: false,
oldClrType: typeof(string),
oldType: "text",
oldMaxLength: 1000);
}
}
}

View File

@@ -0,0 +1,49 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Managing.Infrastructure.Databases.Migrations
{
/// <inheritdoc />
public partial class AddUserIdToBundleBacktestRequest : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "UserId",
table: "BundleBacktestRequests",
type: "integer",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_BundleBacktestRequests_UserId",
table: "BundleBacktestRequests",
column: "UserId");
migrationBuilder.AddForeignKey(
name: "FK_BundleBacktestRequests_Users_UserId",
table: "BundleBacktestRequests",
column: "UserId",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_BundleBacktestRequests_Users_UserId",
table: "BundleBacktestRequests");
migrationBuilder.DropIndex(
name: "IX_BundleBacktestRequests_UserId",
table: "BundleBacktestRequests");
migrationBuilder.DropColumn(
name: "UserId",
table: "BundleBacktestRequests");
}
}
}

View File

@@ -0,0 +1,29 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Managing.Infrastructure.Databases.Migrations
{
/// <inheritdoc />
public partial class RemoveOptimizedMoneyManagementJsonFromBacktestEntity : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "OptimizedMoneyManagementJson",
table: "Backtests");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "OptimizedMoneyManagementJson",
table: "Backtests",
type: "jsonb",
nullable: false,
defaultValue: "");
}
}
}

View File

@@ -0,0 +1,49 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Managing.Infrastructure.Databases.Migrations
{
/// <inheritdoc />
public partial class AddUserIdToMoneyManagement : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "UserId",
table: "MoneyManagements",
type: "integer",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_MoneyManagements_UserId",
table: "MoneyManagements",
column: "UserId");
migrationBuilder.AddForeignKey(
name: "FK_MoneyManagements_Users_UserId",
table: "MoneyManagements",
column: "UserId",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_MoneyManagements_Users_UserId",
table: "MoneyManagements");
migrationBuilder.DropIndex(
name: "IX_MoneyManagements_UserId",
table: "MoneyManagements");
migrationBuilder.DropColumn(
name: "UserId",
table: "MoneyManagements");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,49 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Managing.Infrastructure.Databases.Migrations
{
/// <inheritdoc />
public partial class AddUserIdToBotBackup : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "UserId",
table: "BotBackups",
type: "integer",
nullable: true);
migrationBuilder.CreateIndex(
name: "IX_BotBackups_UserId",
table: "BotBackups",
column: "UserId");
migrationBuilder.AddForeignKey(
name: "FK_BotBackups_Users_UserId",
table: "BotBackups",
column: "UserId",
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropForeignKey(
name: "FK_BotBackups_Users_UserId",
table: "BotBackups");
migrationBuilder.DropIndex(
name: "IX_BotBackups_UserId",
table: "BotBackups");
migrationBuilder.DropColumn(
name: "UserId",
table: "BotBackups");
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,51 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Managing.Infrastructure.Databases.Migrations
{
/// <inheritdoc />
public partial class RemoveFeeEntity : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "Fees");
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "Fees",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Cost = table.Column<decimal>(type: "numeric(18,8)", nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
Exchange = table.Column<string>(type: "text", nullable: false),
LastUpdate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Fees", x => x.Id);
});
migrationBuilder.CreateIndex(
name: "IX_Fees_Exchange",
table: "Fees",
column: "Exchange",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Fees_LastUpdate",
table: "Fees",
column: "LastUpdate");
}
}
}

File diff suppressed because it is too large Load Diff