121 lines
6.3 KiB
C#
121 lines
6.3 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace FinlyticSimulation.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class InitialSimulationMigration : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "DynamicSettings",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Key = table.Column<string>(type: "character varying(150)", maxLength: 150, nullable: false),
|
|
ValueJson = table.Column<string>(type: "text", nullable: false),
|
|
ServiceIdentifier = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
LastUpdatedUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_DynamicSettings", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "simulation_runs",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Isin = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
|
|
Symbol = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
|
|
StrategyKey = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
|
Timeframe = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: false),
|
|
StartDateUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
EndDateUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
StartingCapital = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
|
TotalTrades = table.Column<int>(type: "integer", nullable: false),
|
|
WinningTrades = table.Column<int>(type: "integer", nullable: false),
|
|
LosingTrades = table.Column<int>(type: "integer", nullable: false),
|
|
WinRatePercent = table.Column<decimal>(type: "numeric(6,2)", nullable: false),
|
|
ProfitFactor = table.Column<decimal>(type: "numeric(8,4)", nullable: false),
|
|
MaxDrawdownPercent = table.Column<decimal>(type: "numeric(6,2)", nullable: false),
|
|
TotalReturnPercent = table.Column<decimal>(type: "numeric(8,2)", nullable: false),
|
|
ExpectancyEur = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
|
SharpeRatio = table.Column<decimal>(type: "numeric(8,4)", nullable: false),
|
|
ReportJson = table.Column<string>(type: "jsonb", nullable: false),
|
|
CreatedAtUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_simulation_runs", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "simulation_strategy_matrix",
|
|
columns: table => new
|
|
{
|
|
Isin = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
|
|
StrategyKey = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
|
Timeframe = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: false),
|
|
SampleTradesCount = table.Column<int>(type: "integer", nullable: false),
|
|
WinRatePercent = table.Column<decimal>(type: "numeric(6,2)", nullable: false),
|
|
ProfitFactor = table.Column<decimal>(type: "numeric(8,4)", nullable: false),
|
|
MaxDrawdownPercent = table.Column<decimal>(type: "numeric(6,2)", nullable: false),
|
|
ReliabilityScore = table.Column<decimal>(type: "numeric(5,2)", nullable: false),
|
|
IsApproved = table.Column<bool>(type: "boolean", nullable: false),
|
|
RecommendedAction = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
|
|
LastBacktestRunId = table.Column<Guid>(type: "uuid", nullable: true),
|
|
UpdatedAtUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_simulation_strategy_matrix", x => new { x.Isin, x.StrategyKey, x.Timeframe });
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_DynamicSettings_Key",
|
|
table: "DynamicSettings",
|
|
column: "Key",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_simulation_runs_CreatedAtUtc",
|
|
table: "simulation_runs",
|
|
column: "CreatedAtUtc");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_simulation_runs_Isin_StrategyKey_Timeframe",
|
|
table: "simulation_runs",
|
|
columns: new[] { "Isin", "StrategyKey", "Timeframe" });
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_simulation_strategy_matrix_Isin_IsApproved",
|
|
table: "simulation_strategy_matrix",
|
|
columns: new[] { "Isin", "IsApproved" });
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_simulation_strategy_matrix_ReliabilityScore",
|
|
table: "simulation_strategy_matrix",
|
|
column: "ReliabilityScore");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "DynamicSettings");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "simulation_runs");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "simulation_strategy_matrix");
|
|
}
|
|
}
|
|
}
|