Trading bot grain (#33)

* Trading bot Grain

* Fix a bit more of the trading bot

* Advance on the tradingbot grain

* Fix build

* Fix db script

* Fix user login

* Fix a bit backtest

* Fix cooldown and backtest

* start fixing bot start

* Fix startup

* Setup local db

* Fix build and update candles and scenario

* Add bot registry

* Add reminder

* Updateing the grains

* fix bootstraping

* Save stats on tick

* Save bot data every tick

* Fix serialization

* fix save bot stats

* Fix get candles

* use dict instead of list for position

* Switch hashset to dict

* Fix a bit

* Fix bot launch and bot view

* add migrations

* Remove the tolist

* Add agent grain

* Save agent summary

* clean

* Add save bot

* Update get bots

* Add get bots

* Fix stop/restart

* fix Update config

* Update scanner table on new backtest saved

* Fix backtestRowDetails.tsx

* Fix agentIndex

* Update agentIndex

* Fix more things

* Update user cache

* Fix

* Fix account load/start/restart/run
This commit is contained in:
Oda
2025-08-04 23:07:06 +02:00
committed by GitHub
parent cd378587aa
commit 082ae8714b
215 changed files with 9562 additions and 14028 deletions

View File

@@ -1,34 +0,0 @@
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");
}
}
}

View File

@@ -1,47 +0,0 @@
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");
}
}
}

View File

@@ -1,85 +0,0 @@
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

@@ -1,49 +0,0 @@
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

@@ -1,49 +0,0 @@
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");
}
}
}

View File

@@ -1,49 +0,0 @@
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");
}
}
}

View File

@@ -1,51 +0,0 @@
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");
}
}
}

View File

@@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace Managing.Infrastructure.Databases.Migrations
{
[DbContext(typeof(ManagingDbContext))]
[Migration("20250725202808_RemoveFeeEntity")]
partial class RemoveFeeEntity
[Migration("20250801100607_Init")]
partial class Init
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -177,55 +177,68 @@ namespace Managing.Infrastructure.Databases.Migrations
b.ToTable("Backtests");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BotBackupEntity", b =>
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BotEntity", b =>
{
b.Property<int>("Id")
b.Property<Guid>("Identifier")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
.HasMaxLength(255)
.HasColumnType("uuid");
b.Property<DateTime>("CreateDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("text");
b.Property<decimal>("Fees")
.HasPrecision(18, 8)
.HasColumnType("numeric(18,8)");
b.Property<string>("Identifier")
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("LastStatus")
b.Property<decimal>("Pnl")
.HasPrecision(18, 8)
.HasColumnType("numeric(18,8)");
b.Property<decimal>("Roi")
.HasPrecision(18, 8)
.HasColumnType("numeric(18,8)");
b.Property<DateTime>("StartupTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<int>("TradeLosses")
.HasColumnType("integer");
b.Property<int>("TradeWins")
.HasColumnType("integer");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<int?>("UserId")
b.Property<int>("UserId")
.HasColumnType("integer");
b.Property<string>("UserName")
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<decimal>("Volume")
.HasPrecision(18, 8)
.HasColumnType("numeric(18,8)");
b.HasKey("Id");
b.HasKey("Identifier");
b.HasIndex("CreateDate");
b.HasIndex("Identifier")
.IsUnique();
b.HasIndex("LastStatus");
b.HasIndex("Status");
b.HasIndex("UserId");
b.HasIndex("UserName");
b.HasIndex("UserName", "CreateDate");
b.ToTable("BotBackups");
b.ToTable("Bots");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BundleBacktestRequestEntity", b =>
@@ -619,11 +632,9 @@ namespace Managing.Infrastructure.Databases.Migrations
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.PositionEntity", b =>
{
b.Property<int>("Id")
b.Property<Guid>("Identifier")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
.HasColumnType("uuid");
b.Property<string>("AccountName")
.IsRequired()
@@ -636,11 +647,6 @@ namespace Managing.Infrastructure.Databases.Migrations
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Identifier")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<string>("Initiator")
.IsRequired()
.HasColumnType("text");
@@ -687,7 +693,7 @@ namespace Managing.Infrastructure.Databases.Migrations
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.HasKey("Id");
b.HasKey("Identifier");
b.HasIndex("CreatedAt");
@@ -1185,6 +1191,7 @@ namespace Managing.Infrastructure.Databases.Migrations
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<string>("AgentName")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
@@ -1251,12 +1258,13 @@ namespace Managing.Infrastructure.Databases.Migrations
b.Navigation("User");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BotBackupEntity", b =>
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BotEntity", b =>
{
b.HasOne("Managing.Infrastructure.Databases.PostgreSql.Entities.UserEntity", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.SetNull);
.OnDelete(DeleteBehavior.SetNull)
.IsRequired();
b.Navigation("User");
});

View File

@@ -7,7 +7,7 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace Managing.Infrastructure.Databases.Migrations
{
/// <inheritdoc />
public partial class InitialCreate : Migration
public partial class Init : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
@@ -34,7 +34,7 @@ namespace Managing.Infrastructure.Databases.Migrations
StatisticsJson = table.Column<string>(type: "jsonb", nullable: true),
Fees = table.Column<decimal>(type: "numeric(18,8)", nullable: false),
Score = table.Column<double>(type: "double precision", nullable: false),
ScoreMessage = table.Column<string>(type: "character varying(1000)", maxLength: 1000, nullable: false),
ScoreMessage = table.Column<string>(type: "text", maxLength: 1000, nullable: false),
Metadata = table.Column<string>(type: "text", nullable: true),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
@@ -44,69 +44,6 @@ namespace Managing.Infrastructure.Databases.Migrations
table.PrimaryKey("PK_Backtests", x => x.Id);
});
migrationBuilder.CreateTable(
name: "BotBackups",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Identifier = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
UserName = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
Data = table.Column<string>(type: "jsonb", nullable: false),
LastStatus = table.Column<int>(type: "integer", nullable: false),
CreateDate = 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_BotBackups", x => x.Id);
});
migrationBuilder.CreateTable(
name: "BundleBacktestRequests",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
RequestId = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
UserName = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
CompletedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
Status = table.Column<string>(type: "text", nullable: false),
BacktestRequestsJson = table.Column<string>(type: "text", nullable: false),
TotalBacktests = table.Column<int>(type: "integer", nullable: false),
CompletedBacktests = table.Column<int>(type: "integer", nullable: false),
FailedBacktests = table.Column<int>(type: "integer", nullable: false),
ErrorMessage = table.Column<string>(type: "text", nullable: true),
ProgressInfo = table.Column<string>(type: "text", nullable: true),
CurrentBacktest = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
EstimatedTimeRemainingSeconds = table.Column<int>(type: "integer", nullable: true),
Name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
ResultsJson = table.Column<string>(type: "jsonb", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BundleBacktestRequests", x => x.Id);
});
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),
Exchange = table.Column<string>(type: "text", nullable: false),
LastUpdate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
CreatedAt = 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.CreateTable(
name: "FundingRates",
columns: table => new
@@ -155,26 +92,6 @@ namespace Managing.Infrastructure.Databases.Migrations
table.PrimaryKey("PK_Indicators", x => x.Id);
});
migrationBuilder.CreateTable(
name: "MoneyManagements",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
Timeframe = table.Column<string>(type: "text", nullable: false),
StopLoss = table.Column<decimal>(type: "numeric(18,8)", nullable: false),
TakeProfit = table.Column<decimal>(type: "numeric(18,8)", nullable: false),
Leverage = table.Column<decimal>(type: "numeric(18,8)", nullable: false),
UserName = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
CreatedAt = 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_MoneyManagements", x => x.Id);
});
migrationBuilder.CreateTable(
name: "Scenarios",
columns: table => new
@@ -236,6 +153,44 @@ namespace Managing.Infrastructure.Databases.Migrations
table.PrimaryKey("PK_SpotlightOverviews", x => x.Id);
});
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.CreateTable(
name: "TopVolumeTickers",
columns: table => new
@@ -309,7 +264,7 @@ namespace Managing.Infrastructure.Databases.Migrations
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
AgentName = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
AgentName = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
AvatarUrl = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
TelegramChannel = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true)
},
@@ -318,6 +273,24 @@ namespace Managing.Infrastructure.Databases.Migrations
table.PrimaryKey("PK_Users", x => x.Id);
});
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.CreateTable(
name: "ScenarioIndicators",
columns: table => new
@@ -349,9 +322,7 @@ namespace Managing.Infrastructure.Databases.Migrations
name: "Positions",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Identifier = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
Identifier = table.Column<Guid>(type: "uuid", nullable: false),
Date = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
ProfitAndLoss = table.Column<decimal>(type: "numeric(18,8)", nullable: false),
OriginDirection = table.Column<string>(type: "text", nullable: false),
@@ -371,7 +342,7 @@ namespace Managing.Infrastructure.Databases.Migrations
},
constraints: table =>
{
table.PrimaryKey("PK_Positions", x => x.Id);
table.PrimaryKey("PK_Positions", x => x.Identifier);
table.ForeignKey(
name: "FK_Positions_Trades_OpenTradeId",
column: x => x.OpenTradeId,
@@ -422,6 +393,70 @@ namespace Managing.Infrastructure.Databases.Migrations
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "Bots",
columns: table => new
{
Identifier = table.Column<Guid>(type: "uuid", maxLength: 255, nullable: false),
Name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
UserId = table.Column<int>(type: "integer", nullable: false),
Status = table.Column<string>(type: "text", nullable: false),
CreateDate = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
StartupTime = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
TradeWins = table.Column<int>(type: "integer", nullable: false),
TradeLosses = table.Column<int>(type: "integer", nullable: false),
Pnl = table.Column<decimal>(type: "numeric(18,8)", precision: 18, scale: 8, nullable: false),
Roi = table.Column<decimal>(type: "numeric(18,8)", precision: 18, scale: 8, nullable: false),
Volume = table.Column<decimal>(type: "numeric(18,8)", precision: 18, scale: 8, nullable: false),
Fees = table.Column<decimal>(type: "numeric(18,8)", precision: 18, scale: 8, nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_Bots", x => x.Identifier);
table.ForeignKey(
name: "FK_Bots_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "BundleBacktestRequests",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
RequestId = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
UserName = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
UserId = table.Column<int>(type: "integer", nullable: true),
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
CompletedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
Status = table.Column<string>(type: "text", nullable: false),
BacktestRequestsJson = table.Column<string>(type: "text", nullable: false),
TotalBacktests = table.Column<int>(type: "integer", nullable: false),
CompletedBacktests = table.Column<int>(type: "integer", nullable: false),
FailedBacktests = table.Column<int>(type: "integer", nullable: false),
ErrorMessage = table.Column<string>(type: "text", nullable: true),
ProgressInfo = table.Column<string>(type: "text", nullable: true),
CurrentBacktest = table.Column<string>(type: "character varying(500)", maxLength: 500, nullable: true),
EstimatedTimeRemainingSeconds = table.Column<int>(type: "integer", nullable: true),
Name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
ResultsJson = table.Column<string>(type: "jsonb", nullable: false),
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
},
constraints: table =>
{
table.PrimaryKey("PK_BundleBacktestRequests", x => x.Id);
table.ForeignKey(
name: "FK_BundleBacktestRequests_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "GeneticRequests",
columns: table => new
@@ -467,6 +502,33 @@ namespace Managing.Infrastructure.Databases.Migrations
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateTable(
name: "MoneyManagements",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
Name = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
Timeframe = table.Column<string>(type: "text", nullable: false),
StopLoss = table.Column<decimal>(type: "numeric(18,8)", nullable: false),
TakeProfit = table.Column<decimal>(type: "numeric(18,8)", nullable: false),
Leverage = table.Column<decimal>(type: "numeric(18,8)", nullable: false),
UserName = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: true),
UserId = table.Column<int>(type: "integer", nullable: true),
CreatedAt = 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_MoneyManagements", x => x.Id);
table.ForeignKey(
name: "FK_MoneyManagements_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.SetNull);
});
migrationBuilder.CreateIndex(
name: "IX_Accounts_Key",
table: "Accounts",
@@ -540,30 +602,25 @@ namespace Managing.Infrastructure.Databases.Migrations
column: "WinRate");
migrationBuilder.CreateIndex(
name: "IX_BotBackups_CreateDate",
table: "BotBackups",
name: "IX_Bots_CreateDate",
table: "Bots",
column: "CreateDate");
migrationBuilder.CreateIndex(
name: "IX_BotBackups_Identifier",
table: "BotBackups",
name: "IX_Bots_Identifier",
table: "Bots",
column: "Identifier",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_BotBackups_LastStatus",
table: "BotBackups",
column: "LastStatus");
name: "IX_Bots_Status",
table: "Bots",
column: "Status");
migrationBuilder.CreateIndex(
name: "IX_BotBackups_UserName",
table: "BotBackups",
column: "UserName");
migrationBuilder.CreateIndex(
name: "IX_BotBackups_UserName_CreateDate",
table: "BotBackups",
columns: new[] { "UserName", "CreateDate" });
name: "IX_Bots_UserId",
table: "Bots",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_BundleBacktestRequests_CompletedAt",
@@ -586,6 +643,11 @@ namespace Managing.Infrastructure.Databases.Migrations
table: "BundleBacktestRequests",
column: "Status");
migrationBuilder.CreateIndex(
name: "IX_BundleBacktestRequests_UserId",
table: "BundleBacktestRequests",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_BundleBacktestRequests_UserName",
table: "BundleBacktestRequests",
@@ -596,17 +658,6 @@ namespace Managing.Infrastructure.Databases.Migrations
table: "BundleBacktestRequests",
columns: new[] { "UserName", "CreatedAt" });
migrationBuilder.CreateIndex(
name: "IX_Fees_Exchange",
table: "Fees",
column: "Exchange",
unique: true);
migrationBuilder.CreateIndex(
name: "IX_Fees_LastUpdate",
table: "Fees",
column: "LastUpdate");
migrationBuilder.CreateIndex(
name: "IX_FundingRates_Date",
table: "FundingRates",
@@ -694,6 +745,11 @@ namespace Managing.Infrastructure.Databases.Migrations
table: "MoneyManagements",
column: "Name");
migrationBuilder.CreateIndex(
name: "IX_MoneyManagements_UserId",
table: "MoneyManagements",
column: "UserId");
migrationBuilder.CreateIndex(
name: "IX_MoneyManagements_UserName",
table: "MoneyManagements",
@@ -858,6 +914,28 @@ namespace Managing.Infrastructure.Databases.Migrations
table: "SpotlightOverviews",
column: "ScenarioCount");
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");
migrationBuilder.CreateIndex(
name: "IX_TopVolumeTickers_Date",
table: "TopVolumeTickers",
@@ -948,6 +1026,12 @@ namespace Managing.Infrastructure.Databases.Migrations
name: "IX_Trades_Status",
table: "Trades",
column: "Status");
migrationBuilder.CreateIndex(
name: "IX_Workers_WorkerType",
table: "Workers",
column: "WorkerType",
unique: true);
}
/// <inheritdoc />
@@ -960,14 +1044,11 @@ namespace Managing.Infrastructure.Databases.Migrations
name: "Backtests");
migrationBuilder.DropTable(
name: "BotBackups");
name: "Bots");
migrationBuilder.DropTable(
name: "BundleBacktestRequests");
migrationBuilder.DropTable(
name: "Fees");
migrationBuilder.DropTable(
name: "FundingRates");
@@ -989,12 +1070,21 @@ namespace Managing.Infrastructure.Databases.Migrations
migrationBuilder.DropTable(
name: "SpotlightOverviews");
migrationBuilder.DropTable(
name: "SynthMinersLeaderboards");
migrationBuilder.DropTable(
name: "SynthPredictions");
migrationBuilder.DropTable(
name: "TopVolumeTickers");
migrationBuilder.DropTable(
name: "Traders");
migrationBuilder.DropTable(
name: "Workers");
migrationBuilder.DropTable(
name: "Users");

View File

@@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace Managing.Infrastructure.Databases.Migrations
{
[DbContext(typeof(ManagingDbContext))]
[Migration("20250725014014_AddUserIdToBundleBacktestRequest")]
partial class AddUserIdToBundleBacktestRequest
[Migration("20250801111224_UpdateUserEntity")]
partial class UpdateUserEntity
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -111,10 +111,6 @@ namespace Managing.Infrastructure.Databases.Migrations
.IsRequired()
.HasColumnType("jsonb");
b.Property<string>("OptimizedMoneyManagementJson")
.IsRequired()
.HasColumnType("jsonb");
b.Property<string>("PositionsJson")
.IsRequired()
.HasColumnType("jsonb");
@@ -181,50 +177,68 @@ namespace Managing.Infrastructure.Databases.Migrations
b.ToTable("Backtests");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BotBackupEntity", b =>
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BotEntity", b =>
{
b.Property<int>("Id")
b.Property<Guid>("Identifier")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
.HasMaxLength(255)
.HasColumnType("uuid");
b.Property<DateTime>("CreateDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("text");
b.Property<decimal>("Fees")
.HasPrecision(18, 8)
.HasColumnType("numeric(18,8)");
b.Property<string>("Identifier")
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("LastStatus")
b.Property<decimal>("Pnl")
.HasPrecision(18, 8)
.HasColumnType("numeric(18,8)");
b.Property<decimal>("Roi")
.HasPrecision(18, 8)
.HasColumnType("numeric(18,8)");
b.Property<DateTime>("StartupTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<int>("TradeLosses")
.HasColumnType("integer");
b.Property<int>("TradeWins")
.HasColumnType("integer");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("UserName")
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.Property<decimal>("Volume")
.HasPrecision(18, 8)
.HasColumnType("numeric(18,8)");
b.HasKey("Identifier");
b.HasIndex("CreateDate");
b.HasIndex("Identifier")
.IsUnique();
b.HasIndex("LastStatus");
b.HasIndex("Status");
b.HasIndex("UserName");
b.HasIndex("UserId");
b.HasIndex("UserName", "CreateDate");
b.ToTable("BotBackups");
b.ToTable("Bots");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BundleBacktestRequestEntity", b =>
@@ -316,40 +330,6 @@ namespace Managing.Infrastructure.Databases.Migrations
b.ToTable("BundleBacktestRequests");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.FeeEntity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<decimal>("Cost")
.HasColumnType("decimal(18,8)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Exchange")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("LastUpdate")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("Exchange")
.IsUnique();
b.HasIndex("LastUpdate");
b.ToTable("Fees");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.FundingRateEntity", b =>
{
b.Property<int>("Id")
@@ -630,6 +610,9 @@ namespace Managing.Infrastructure.Databases.Migrations
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<int?>("UserId")
.HasColumnType("integer");
b.Property<string>("UserName")
.HasMaxLength(255)
.HasColumnType("character varying(255)");
@@ -638,6 +621,8 @@ namespace Managing.Infrastructure.Databases.Migrations
b.HasIndex("Name");
b.HasIndex("UserId");
b.HasIndex("UserName");
b.HasIndex("UserName", "Name");
@@ -647,11 +632,9 @@ namespace Managing.Infrastructure.Databases.Migrations
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.PositionEntity", b =>
{
b.Property<int>("Id")
b.Property<Guid>("Identifier")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
.HasColumnType("uuid");
b.Property<string>("AccountName")
.IsRequired()
@@ -664,11 +647,6 @@ namespace Managing.Infrastructure.Databases.Migrations
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Identifier")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<string>("Initiator")
.IsRequired()
.HasColumnType("text");
@@ -715,7 +693,7 @@ namespace Managing.Infrastructure.Databases.Migrations
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.HasKey("Id");
b.HasKey("Identifier");
b.HasIndex("CreatedAt");
@@ -1279,6 +1257,17 @@ namespace Managing.Infrastructure.Databases.Migrations
b.Navigation("User");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BotEntity", b =>
{
b.HasOne("Managing.Infrastructure.Databases.PostgreSql.Entities.UserEntity", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.SetNull)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BundleBacktestRequestEntity", b =>
{
b.HasOne("Managing.Infrastructure.Databases.PostgreSql.Entities.UserEntity", "User")
@@ -1299,6 +1288,16 @@ namespace Managing.Infrastructure.Databases.Migrations
b.Navigation("User");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.MoneyManagementEntity", b =>
{
b.HasOne("Managing.Infrastructure.Databases.PostgreSql.Entities.UserEntity", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.SetNull);
b.Navigation("User");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.PositionEntity", b =>
{
b.HasOne("Managing.Infrastructure.Databases.PostgreSql.Entities.TradeEntity", "OpenTrade")

View File

@@ -5,34 +5,36 @@
namespace Managing.Infrastructure.Databases.Migrations
{
/// <inheritdoc />
public partial class UpdateScoreMessageToText : Migration
public partial class UpdateUserEntity : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "ScoreMessage",
table: "Backtests",
type: "text",
maxLength: 1000,
nullable: false,
name: "AgentName",
table: "Users",
type: "character varying(255)",
maxLength: 255,
nullable: true,
oldClrType: typeof(string),
oldType: "character varying(1000)",
oldMaxLength: 1000);
oldType: "character varying(255)",
oldMaxLength: 255);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AlterColumn<string>(
name: "ScoreMessage",
table: "Backtests",
type: "character varying(1000)",
maxLength: 1000,
name: "AgentName",
table: "Users",
type: "character varying(255)",
maxLength: 255,
nullable: false,
defaultValue: "",
oldClrType: typeof(string),
oldType: "text",
oldMaxLength: 1000);
oldType: "character varying(255)",
oldMaxLength: 255,
oldNullable: true);
}
}
}

View File

@@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace Managing.Infrastructure.Databases.Migrations
{
[DbContext(typeof(ManagingDbContext))]
[Migration("20250725172635_AddUserIdToMoneyManagement")]
partial class AddUserIdToMoneyManagement
[Migration("20250803201734_AddTickerToBots")]
partial class AddTickerToBots
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -177,50 +177,71 @@ namespace Managing.Infrastructure.Databases.Migrations
b.ToTable("Backtests");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BotBackupEntity", b =>
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BotEntity", b =>
{
b.Property<int>("Id")
b.Property<Guid>("Identifier")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
.HasMaxLength(255)
.HasColumnType("uuid");
b.Property<DateTime>("CreateDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("text");
b.Property<decimal>("Fees")
.HasPrecision(18, 8)
.HasColumnType("numeric(18,8)");
b.Property<string>("Identifier")
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("LastStatus")
b.Property<decimal>("Pnl")
.HasPrecision(18, 8)
.HasColumnType("numeric(18,8)");
b.Property<decimal>("Roi")
.HasPrecision(18, 8)
.HasColumnType("numeric(18,8)");
b.Property<DateTime>("StartupTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Ticker")
.HasColumnType("integer");
b.Property<int>("TradeLosses")
.HasColumnType("integer");
b.Property<int>("TradeWins")
.HasColumnType("integer");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("UserName")
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("UserId")
.HasColumnType("integer");
b.HasKey("Id");
b.Property<decimal>("Volume")
.HasPrecision(18, 8)
.HasColumnType("numeric(18,8)");
b.HasKey("Identifier");
b.HasIndex("CreateDate");
b.HasIndex("Identifier")
.IsUnique();
b.HasIndex("LastStatus");
b.HasIndex("Status");
b.HasIndex("UserName");
b.HasIndex("UserId");
b.HasIndex("UserName", "CreateDate");
b.ToTable("BotBackups");
b.ToTable("Bots");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BundleBacktestRequestEntity", b =>
@@ -312,40 +333,6 @@ namespace Managing.Infrastructure.Databases.Migrations
b.ToTable("BundleBacktestRequests");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.FeeEntity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<decimal>("Cost")
.HasColumnType("decimal(18,8)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Exchange")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("LastUpdate")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("Exchange")
.IsUnique();
b.HasIndex("LastUpdate");
b.ToTable("Fees");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.FundingRateEntity", b =>
{
b.Property<int>("Id")
@@ -648,11 +635,9 @@ namespace Managing.Infrastructure.Databases.Migrations
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.PositionEntity", b =>
{
b.Property<int>("Id")
b.Property<Guid>("Identifier")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
.HasColumnType("uuid");
b.Property<string>("AccountName")
.IsRequired()
@@ -665,11 +650,6 @@ namespace Managing.Infrastructure.Databases.Migrations
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Identifier")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<string>("Initiator")
.IsRequired()
.HasColumnType("text");
@@ -716,7 +696,7 @@ namespace Managing.Infrastructure.Databases.Migrations
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.HasKey("Id");
b.HasKey("Identifier");
b.HasIndex("CreatedAt");
@@ -1280,6 +1260,17 @@ namespace Managing.Infrastructure.Databases.Migrations
b.Navigation("User");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BotEntity", b =>
{
b.HasOne("Managing.Infrastructure.Databases.PostgreSql.Entities.UserEntity", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.SetNull)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BundleBacktestRequestEntity", b =>
{
b.HasOne("Managing.Infrastructure.Databases.PostgreSql.Entities.UserEntity", "User")

View File

@@ -5,25 +5,25 @@
namespace Managing.Infrastructure.Databases.Migrations
{
/// <inheritdoc />
public partial class RemoveOptimizedMoneyManagementJsonFromBacktestEntity : Migration
public partial class AddTickerToBots : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "OptimizedMoneyManagementJson",
table: "Backtests");
migrationBuilder.AddColumn<int>(
name: "Ticker",
table: "Bots",
type: "integer",
nullable: false,
defaultValue: 0);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<string>(
name: "OptimizedMoneyManagementJson",
table: "Backtests",
type: "jsonb",
nullable: false,
defaultValue: "");
migrationBuilder.DropColumn(
name: "Ticker",
table: "Bots");
}
}
}

View File

@@ -12,8 +12,8 @@ using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
namespace Managing.Infrastructure.Databases.Migrations
{
[DbContext(typeof(ManagingDbContext))]
[Migration("20250725173315_AddUserIdToBotBackup")]
partial class AddUserIdToBotBackup
[Migration("20250803204725_UpdateBotTicker")]
partial class UpdateBotTicker
{
/// <inheritdoc />
protected override void BuildTargetModel(ModelBuilder modelBuilder)
@@ -177,55 +177,71 @@ namespace Managing.Infrastructure.Databases.Migrations
b.ToTable("Backtests");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BotBackupEntity", b =>
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BotEntity", b =>
{
b.Property<int>("Id")
b.Property<Guid>("Identifier")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
.HasMaxLength(255)
.HasColumnType("uuid");
b.Property<DateTime>("CreateDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("text");
b.Property<decimal>("Fees")
.HasPrecision(18, 8)
.HasColumnType("numeric(18,8)");
b.Property<string>("Identifier")
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("LastStatus")
b.Property<decimal>("Pnl")
.HasPrecision(18, 8)
.HasColumnType("numeric(18,8)");
b.Property<decimal>("Roi")
.HasPrecision(18, 8)
.HasColumnType("numeric(18,8)");
b.Property<DateTime>("StartupTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Ticker")
.HasColumnType("integer");
b.Property<int>("TradeLosses")
.HasColumnType("integer");
b.Property<int>("TradeWins")
.HasColumnType("integer");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<int?>("UserId")
b.Property<int>("UserId")
.HasColumnType("integer");
b.Property<string>("UserName")
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<decimal>("Volume")
.HasPrecision(18, 8)
.HasColumnType("numeric(18,8)");
b.HasKey("Id");
b.HasKey("Identifier");
b.HasIndex("CreateDate");
b.HasIndex("Identifier")
.IsUnique();
b.HasIndex("LastStatus");
b.HasIndex("Status");
b.HasIndex("UserId");
b.HasIndex("UserName");
b.HasIndex("UserName", "CreateDate");
b.ToTable("BotBackups");
b.ToTable("Bots");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BundleBacktestRequestEntity", b =>
@@ -317,40 +333,6 @@ namespace Managing.Infrastructure.Databases.Migrations
b.ToTable("BundleBacktestRequests");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.FeeEntity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<decimal>("Cost")
.HasColumnType("decimal(18,8)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<string>("Exchange")
.IsRequired()
.HasColumnType("text");
b.Property<DateTime>("LastUpdate")
.HasColumnType("timestamp with time zone");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.HasKey("Id");
b.HasIndex("Exchange")
.IsUnique();
b.HasIndex("LastUpdate");
b.ToTable("Fees");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.FundingRateEntity", b =>
{
b.Property<int>("Id")
@@ -653,11 +635,9 @@ namespace Managing.Infrastructure.Databases.Migrations
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.PositionEntity", b =>
{
b.Property<int>("Id")
b.Property<Guid>("Identifier")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
.HasColumnType("uuid");
b.Property<string>("AccountName")
.IsRequired()
@@ -670,11 +650,6 @@ namespace Managing.Infrastructure.Databases.Migrations
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Identifier")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<string>("Initiator")
.IsRequired()
.HasColumnType("text");
@@ -721,7 +696,7 @@ namespace Managing.Infrastructure.Databases.Migrations
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.HasKey("Id");
b.HasKey("Identifier");
b.HasIndex("CreatedAt");
@@ -1285,12 +1260,13 @@ namespace Managing.Infrastructure.Databases.Migrations
b.Navigation("User");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BotBackupEntity", b =>
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BotEntity", b =>
{
b.HasOne("Managing.Infrastructure.Databases.PostgreSql.Entities.UserEntity", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.SetNull);
.OnDelete(DeleteBehavior.SetNull)
.IsRequired();
b.Navigation("User");
});

View File

@@ -0,0 +1,22 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Managing.Infrastructure.Databases.Migrations
{
/// <inheritdoc />
public partial class UpdateBotTicker : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
}
}
}

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,71 @@
using System;
using Microsoft.EntityFrameworkCore.Migrations;
using Npgsql.EntityFrameworkCore.PostgreSQL.Metadata;
#nullable disable
namespace Managing.Infrastructure.Databases.Migrations
{
/// <inheritdoc />
public partial class AddAgentSummaryEntity : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.CreateTable(
name: "AgentSummaries",
columns: table => new
{
Id = table.Column<int>(type: "integer", nullable: false)
.Annotation("Npgsql:ValueGenerationStrategy", NpgsqlValueGenerationStrategy.IdentityByDefaultColumn),
UserId = table.Column<int>(type: "integer", nullable: false),
AgentName = table.Column<string>(type: "character varying(255)", maxLength: 255, nullable: false),
TotalPnL = table.Column<decimal>(type: "numeric(18,8)", nullable: false),
TotalROI = table.Column<decimal>(type: "numeric(18,8)", nullable: false),
Wins = table.Column<int>(type: "integer", nullable: false),
Losses = table.Column<int>(type: "integer", nullable: false),
Runtime = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
CreatedAt = 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_AgentSummaries", x => x.Id);
table.ForeignKey(
name: "FK_AgentSummaries_Users_UserId",
column: x => x.UserId,
principalTable: "Users",
principalColumn: "Id",
onDelete: ReferentialAction.Cascade);
});
migrationBuilder.CreateIndex(
name: "IX_AgentSummaries_AgentName",
table: "AgentSummaries",
column: "AgentName");
migrationBuilder.CreateIndex(
name: "IX_AgentSummaries_TotalPnL",
table: "AgentSummaries",
column: "TotalPnL");
migrationBuilder.CreateIndex(
name: "IX_AgentSummaries_UpdatedAt",
table: "AgentSummaries",
column: "UpdatedAt");
migrationBuilder.CreateIndex(
name: "IX_AgentSummaries_UserId",
table: "AgentSummaries",
column: "UserId",
unique: true);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropTable(
name: "AgentSummaries");
}
}
}

View File

@@ -0,0 +1,42 @@
using Microsoft.EntityFrameworkCore.Migrations;
#nullable disable
namespace Managing.Infrastructure.Databases.Migrations
{
/// <inheritdoc />
public partial class AddMissingAgentSummaryColumns : Migration
{
/// <inheritdoc />
protected override void Up(MigrationBuilder migrationBuilder)
{
migrationBuilder.AddColumn<int>(
name: "ActiveStrategiesCount",
table: "AgentSummaries",
type: "integer",
nullable: false,
defaultValue: 0);
migrationBuilder.AddColumn<decimal>(
name: "TotalVolume",
table: "AgentSummaries",
type: "numeric(18,8)",
precision: 18,
scale: 8,
nullable: false,
defaultValue: 0m);
}
/// <inheritdoc />
protected override void Down(MigrationBuilder migrationBuilder)
{
migrationBuilder.DropColumn(
name: "ActiveStrategiesCount",
table: "AgentSummaries");
migrationBuilder.DropColumn(
name: "TotalVolume",
table: "AgentSummaries");
}
}
}

View File

@@ -66,6 +66,64 @@ namespace Managing.Infrastructure.Databases.Migrations
b.ToTable("Accounts");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.AgentSummaryEntity", b =>
{
b.Property<int>("Id")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
b.Property<int>("ActiveStrategiesCount")
.HasColumnType("integer");
b.Property<string>("AgentName")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<DateTime>("CreatedAt")
.HasColumnType("timestamp with time zone");
b.Property<int>("Losses")
.HasColumnType("integer");
b.Property<DateTime?>("Runtime")
.HasColumnType("timestamp with time zone");
b.Property<decimal>("TotalPnL")
.HasColumnType("decimal(18,8)");
b.Property<decimal>("TotalROI")
.HasColumnType("decimal(18,8)");
b.Property<decimal>("TotalVolume")
.HasPrecision(18, 8)
.HasColumnType("numeric(18,8)");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<int>("UserId")
.HasColumnType("integer");
b.Property<int>("Wins")
.HasColumnType("integer");
b.HasKey("Id");
b.HasIndex("AgentName");
b.HasIndex("TotalPnL");
b.HasIndex("UpdatedAt");
b.HasIndex("UserId")
.IsUnique();
b.ToTable("AgentSummaries");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BacktestEntity", b =>
{
b.Property<int>("Id")
@@ -174,55 +232,71 @@ namespace Managing.Infrastructure.Databases.Migrations
b.ToTable("Backtests");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BotBackupEntity", b =>
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BotEntity", b =>
{
b.Property<int>("Id")
b.Property<Guid>("Identifier")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
.HasMaxLength(255)
.HasColumnType("uuid");
b.Property<DateTime>("CreateDate")
.HasColumnType("timestamp with time zone");
b.Property<string>("Data")
.IsRequired()
.HasColumnType("text");
b.Property<decimal>("Fees")
.HasPrecision(18, 8)
.HasColumnType("numeric(18,8)");
b.Property<string>("Identifier")
b.Property<string>("Name")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<int>("LastStatus")
b.Property<decimal>("Pnl")
.HasPrecision(18, 8)
.HasColumnType("numeric(18,8)");
b.Property<decimal>("Roi")
.HasPrecision(18, 8)
.HasColumnType("numeric(18,8)");
b.Property<DateTime>("StartupTime")
.HasColumnType("timestamp with time zone");
b.Property<string>("Status")
.IsRequired()
.HasColumnType("text");
b.Property<int>("Ticker")
.HasColumnType("integer");
b.Property<int>("TradeLosses")
.HasColumnType("integer");
b.Property<int>("TradeWins")
.HasColumnType("integer");
b.Property<DateTime>("UpdatedAt")
.HasColumnType("timestamp with time zone");
b.Property<int?>("UserId")
b.Property<int>("UserId")
.HasColumnType("integer");
b.Property<string>("UserName")
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<decimal>("Volume")
.HasPrecision(18, 8)
.HasColumnType("numeric(18,8)");
b.HasKey("Id");
b.HasKey("Identifier");
b.HasIndex("CreateDate");
b.HasIndex("Identifier")
.IsUnique();
b.HasIndex("LastStatus");
b.HasIndex("Status");
b.HasIndex("UserId");
b.HasIndex("UserName");
b.HasIndex("UserName", "CreateDate");
b.ToTable("BotBackups");
b.ToTable("Bots");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BundleBacktestRequestEntity", b =>
@@ -616,11 +690,9 @@ namespace Managing.Infrastructure.Databases.Migrations
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.PositionEntity", b =>
{
b.Property<int>("Id")
b.Property<Guid>("Identifier")
.ValueGeneratedOnAdd()
.HasColumnType("integer");
NpgsqlPropertyBuilderExtensions.UseIdentityByDefaultColumn(b.Property<int>("Id"));
.HasColumnType("uuid");
b.Property<string>("AccountName")
.IsRequired()
@@ -633,11 +705,6 @@ namespace Managing.Infrastructure.Databases.Migrations
b.Property<DateTime>("Date")
.HasColumnType("timestamp with time zone");
b.Property<string>("Identifier")
.IsRequired()
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.Property<string>("Initiator")
.IsRequired()
.HasColumnType("text");
@@ -684,7 +751,7 @@ namespace Managing.Infrastructure.Databases.Migrations
.HasMaxLength(255)
.HasColumnType("character varying(255)");
b.HasKey("Id");
b.HasKey("Identifier");
b.HasIndex("CreatedAt");
@@ -1248,12 +1315,24 @@ namespace Managing.Infrastructure.Databases.Migrations
b.Navigation("User");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BotBackupEntity", b =>
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.AgentSummaryEntity", b =>
{
b.HasOne("Managing.Infrastructure.Databases.PostgreSql.Entities.UserEntity", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.SetNull);
.OnDelete(DeleteBehavior.Cascade)
.IsRequired();
b.Navigation("User");
});
modelBuilder.Entity("Managing.Infrastructure.Databases.PostgreSql.Entities.BotEntity", b =>
{
b.HasOne("Managing.Infrastructure.Databases.PostgreSql.Entities.UserEntity", "User")
.WithMany()
.HasForeignKey("UserId")
.OnDelete(DeleteBehavior.SetNull)
.IsRequired();
b.Navigation("User");
});