154 lines
7.5 KiB
C#
154 lines
7.5 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace FinlyticTrades.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class Init : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "Settings",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
AtrStopLossMultiplier = table.Column<double>(type: "double precision", nullable: false),
|
|
RiskPerTradePercentage = table.Column<double>(type: "double precision", nullable: false),
|
|
MaxOpenPositions = table.Column<int>(type: "integer", nullable: false),
|
|
UpdatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_Settings", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "trades",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
TradeId = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
AnalysisId = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
EventId = table.Column<string>(type: "character varying(100)", maxLength: 100, nullable: false),
|
|
Sector = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: false),
|
|
Symbol = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
|
|
Isin = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
|
|
CompanyName = table.Column<string>(type: "character varying(150)", maxLength: 150, nullable: false),
|
|
Status = table.Column<int>(type: "integer", nullable: false),
|
|
EntryPrice = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
|
StopLoss = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
|
TakeProfit = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
|
SignalType = table.Column<string>(type: "character varying(10)", maxLength: 10, nullable: false),
|
|
RiskTolerance = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
|
|
Timeframe = table.Column<string>(type: "character varying(20)", maxLength: 20, nullable: false),
|
|
InstrumentType = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
|
|
WinRate = table.Column<double>(type: "double precision", nullable: false),
|
|
VixRegime = table.Column<int>(type: "integer", nullable: false),
|
|
VixValue = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
|
TtlMinutes = table.Column<int>(type: "integer", nullable: false),
|
|
Reasoning = table.Column<string>(type: "text", nullable: false),
|
|
UserExitPrice = table.Column<decimal>(type: "numeric(18,4)", nullable: true),
|
|
UserExitTimestamp = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
|
CloseReason = table.Column<string>(type: "character varying(50)", maxLength: 50, nullable: true),
|
|
PnlAbsolute = table.Column<decimal>(type: "numeric(18,4)", nullable: true),
|
|
PnlPercent = table.Column<decimal>(type: "numeric(18,4)", nullable: true),
|
|
IsWin = table.Column<bool>(type: "boolean", nullable: true),
|
|
CreatedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
|
ClosedAt = table.Column<DateTime>(type: "timestamp with time zone", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_trades", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "trade_hourly_updates",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
|
TradeId = table.Column<Guid>(type: "uuid", nullable: false),
|
|
Recommendation = table.Column<string>(type: "character varying(30)", maxLength: 30, nullable: false),
|
|
CurrentPrice = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
|
SuggestedStopLoss = table.Column<decimal>(type: "numeric(18,4)", nullable: true),
|
|
SuggestedTakeProfit = table.Column<decimal>(type: "numeric(18,4)", nullable: true),
|
|
VixValue = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
|
Reasoning = table.Column<string>(type: "text", nullable: false),
|
|
Timestamp = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_trade_hourly_updates", x => x.Id);
|
|
table.ForeignKey(
|
|
name: "FK_trade_hourly_updates_trades_TradeId",
|
|
column: x => x.TradeId,
|
|
principalTable: "trades",
|
|
principalColumn: "Id",
|
|
onDelete: ReferentialAction.Cascade);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_trade_hourly_updates_Timestamp",
|
|
table: "trade_hourly_updates",
|
|
column: "Timestamp");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_trade_hourly_updates_TradeId",
|
|
table: "trade_hourly_updates",
|
|
column: "TradeId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_trades_AnalysisId",
|
|
table: "trades",
|
|
column: "AnalysisId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_trades_CreatedAt",
|
|
table: "trades",
|
|
column: "CreatedAt");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_trades_EventId",
|
|
table: "trades",
|
|
column: "EventId");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_trades_Isin",
|
|
table: "trades",
|
|
column: "Isin");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_trades_Sector",
|
|
table: "trades",
|
|
column: "Sector");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_trades_Status",
|
|
table: "trades",
|
|
column: "Status");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_trades_TradeId",
|
|
table: "trades",
|
|
column: "TradeId",
|
|
unique: true);
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "Settings");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "trade_hourly_updates");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "trades");
|
|
}
|
|
}
|
|
}
|