refactor(bot): update paper trading models, broker integration, background services, and test project
This commit is contained in:
@@ -0,0 +1,121 @@
|
||||
using System;
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace FinlyticBot.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class InitialBotMigration : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.CreateTable(
|
||||
name: "bot_portfolio_snapshots",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
SnapshotDateUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
TotalEquityEur = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
||||
CashEur = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
||||
OpenPositionsCount = table.Column<int>(type: "integer", nullable: false),
|
||||
DailyRealizedPnlEur = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
||||
TotalUnrealizedPnlEur = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
||||
WinRatePercent = table.Column<decimal>(type: "numeric(6,2)", nullable: true),
|
||||
CreatedAtUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_bot_portfolio_snapshots", x => x.Id);
|
||||
});
|
||||
|
||||
migrationBuilder.CreateTable(
|
||||
name: "bot_positions",
|
||||
columns: table => new
|
||||
{
|
||||
Id = table.Column<Guid>(type: "uuid", nullable: false),
|
||||
ProposalId = 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),
|
||||
Venue = table.Column<int>(type: "integer", nullable: false),
|
||||
AlpacaOrderId = table.Column<string>(type: "character varying(60)", maxLength: 60, nullable: true),
|
||||
ClientOrderId = table.Column<string>(type: "character varying(60)", maxLength: 60, nullable: true),
|
||||
Direction = table.Column<int>(type: "integer", nullable: false),
|
||||
Quantity = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
||||
EntryPrice = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
||||
AverageBuyIn = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
||||
InitialStopLoss = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
||||
CurrentStopLoss = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
||||
CurrentPrice = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
||||
TakeProfit1 = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
||||
TakeProfit2 = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
||||
RealizedPnlEur = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
||||
TotalFeesEur = table.Column<decimal>(type: "numeric(18,4)", nullable: false),
|
||||
Status = table.Column<int>(type: "integer", nullable: false),
|
||||
ExitPlan = table.Column<string>(type: "jsonb", nullable: false),
|
||||
OpenedAtUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false),
|
||||
ClosedAtUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: true),
|
||||
LastSyncAtUtc = table.Column<DateTime>(type: "timestamp with time zone", nullable: false)
|
||||
},
|
||||
constraints: table =>
|
||||
{
|
||||
table.PrimaryKey("PK_bot_positions", x => x.Id);
|
||||
});
|
||||
|
||||
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.CreateIndex(
|
||||
name: "IX_bot_portfolio_snapshots_SnapshotDateUtc",
|
||||
table: "bot_portfolio_snapshots",
|
||||
column: "SnapshotDateUtc");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_bot_positions_OpenedAtUtc",
|
||||
table: "bot_positions",
|
||||
column: "OpenedAtUtc");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_bot_positions_ProposalId",
|
||||
table: "bot_positions",
|
||||
column: "ProposalId");
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_bot_positions_Status_Venue",
|
||||
table: "bot_positions",
|
||||
columns: new[] { "Status", "Venue" });
|
||||
|
||||
migrationBuilder.CreateIndex(
|
||||
name: "IX_DynamicSettings_Key",
|
||||
table: "DynamicSettings",
|
||||
column: "Key",
|
||||
unique: true);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropTable(
|
||||
name: "bot_portfolio_snapshots");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "bot_positions");
|
||||
|
||||
migrationBuilder.DropTable(
|
||||
name: "DynamicSettings");
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user