Portierung der beiden fehlenden Grundbausteine aus PolytraderSharp (voller Ausbau). Core S-0 (Datenfundament fuer Analyse/Forensik): - core_decision_journal + core_order_events (+ ReasonCode/Decision/OrderEvent-Enums), IDecisionJournal/IOrderEventLog mit fehlertoleranten EF-Impls (Handel bricht nie). - SignalId-Durchreichung TradeSignal -> ExecutionService -> core_trade_history; ExecutionService schreibt an jeder Verzweigung Journal/Order-Events. - JSONL-Log-Sink (LogJson + Dual-Sink), pure Analytik: RealizedPnlEngine (FIFO), TradeAnalytics, DossierBuilder. Migration AddAnalysisFoundation. Accounting-Modul (acc_): unabhaengiger IBKR-Kontoauszug (Activity Flex Query) hinter Interfaces mit Offline-Null-Stubs -> append-only Ledger + Periodenabrechnung/BWA + FX (USD/EUR) + CSV/PDF (PDFsharp/MigraDoc). Steuerschicht bewusst offen (Platzhalter-Tab). Kein Handel. Migration InitialAccounting. Supervisor-Modul (sup_): read-only OpenRouter-Agent (Function-Calling-Loop) + read-only Tool-Registry (8 Tools) + Profile + Dossier-Browser + Counterfactual-Job (Stub) + Tagesbericht/MCP-Light (opt-in). Migration InitialSupervisor. Verdrahtung: Program.cs (beide Module + Icons), slnx/App/Tests-Referenzen, provision-db.ps1, AppSettings-Sektionen, docs/konzepte, README. Tests: 79 -> 117 gruen (FIFO/KPIs/Dossier/JSONL, Classifier/Engine/FX/Idempotenz, OpenRouter/Registry/Agent/MCP, STA-Konstruktion beider neuen Fenster). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
164 lines
8.5 KiB
C#
164 lines
8.5 KiB
C#
using System;
|
|
using Microsoft.EntityFrameworkCore.Metadata;
|
|
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace IBKRTrader.Modules.Accounting.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class InitialAccounting : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.AlterDatabase()
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "acc_fx_rates",
|
|
columns: table => new
|
|
{
|
|
Date = table.Column<DateTime>(type: "date", nullable: false),
|
|
UsdToEur = table.Column<decimal>(type: "decimal(18,8)", precision: 18, scale: 8, nullable: false),
|
|
Source = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_acc_fx_rates", x => x.Date);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "acc_ingest_runs",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
AccountId = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Backfill = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
StartedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
FinishedAt = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
|
FromTimestamp = table.Column<DateTime>(type: "datetime(6)", nullable: true),
|
|
NewEntries = table.Column<int>(type: "int", nullable: false),
|
|
DuplicateEntries = table.Column<int>(type: "int", nullable: false),
|
|
Success = table.Column<bool>(type: "tinyint(1)", nullable: false),
|
|
Message = table.Column<string>(type: "varchar(1000)", maxLength: 1000, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
BalanceAnchorBase = table.Column<decimal>(type: "decimal(28,8)", precision: 28, scale: 8, nullable: true),
|
|
LedgerNetBase = table.Column<decimal>(type: "decimal(28,8)", precision: 28, scale: 8, nullable: true),
|
|
BalanceDeltaBase = table.Column<decimal>(type: "decimal(28,8)", precision: 28, scale: 8, nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_acc_ingest_runs", x => x.Id);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "acc_ledger",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
AccountId = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
EventType = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Timestamp = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
Symbol = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
AssetClass = table.Column<string>(type: "varchar(10)", maxLength: 10, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Currency = table.Column<string>(type: "varchar(5)", maxLength: 5, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Side = table.Column<string>(type: "varchar(10)", maxLength: 10, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Quantity = table.Column<decimal>(type: "decimal(28,8)", precision: 28, scale: 8, nullable: false),
|
|
PriceNative = table.Column<decimal>(type: "decimal(18,6)", precision: 18, scale: 6, nullable: false),
|
|
GrossBase = table.Column<decimal>(type: "decimal(28,8)", precision: 28, scale: 8, nullable: false),
|
|
FeeBase = table.Column<decimal>(type: "decimal(28,8)", precision: 28, scale: 8, nullable: false),
|
|
NetBase = table.Column<decimal>(type: "decimal(28,8)", precision: 28, scale: 8, nullable: false),
|
|
TransactionId = table.Column<string>(type: "varchar(60)", maxLength: 60, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Source = table.Column<string>(type: "varchar(40)", maxLength: 40, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
IngestBatchId = table.Column<long>(type: "bigint", nullable: false),
|
|
IngestedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false),
|
|
IdempotencyKey = table.Column<string>(type: "varchar(120)", maxLength: 120, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4")
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_acc_ledger", x => x.Id);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateTable(
|
|
name: "acc_raw",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<long>(type: "bigint", nullable: false)
|
|
.Annotation("MySql:ValueGenerationStrategy", MySqlValueGenerationStrategy.IdentityColumn),
|
|
IngestRunId = table.Column<long>(type: "bigint", nullable: false),
|
|
AccountId = table.Column<string>(type: "varchar(30)", maxLength: 30, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
SourceKind = table.Column<string>(type: "varchar(20)", maxLength: 20, nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
Json = table.Column<string>(type: "longtext", nullable: false)
|
|
.Annotation("MySql:CharSet", "utf8mb4"),
|
|
CapturedAt = table.Column<DateTime>(type: "datetime(6)", nullable: false)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_acc_raw", x => x.Id);
|
|
})
|
|
.Annotation("MySql:CharSet", "utf8mb4");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_acc_ingest_runs_AccountId_StartedAt",
|
|
table: "acc_ingest_runs",
|
|
columns: new[] { "AccountId", "StartedAt" });
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_acc_ledger_AccountId_Timestamp",
|
|
table: "acc_ledger",
|
|
columns: new[] { "AccountId", "Timestamp" });
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_acc_ledger_EventType",
|
|
table: "acc_ledger",
|
|
column: "EventType");
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_acc_ledger_IdempotencyKey",
|
|
table: "acc_ledger",
|
|
column: "IdempotencyKey",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_acc_raw_IngestRunId",
|
|
table: "acc_raw",
|
|
column: "IngestRunId");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "acc_fx_rates");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "acc_ingest_runs");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "acc_ledger");
|
|
|
|
migrationBuilder.DropTable(
|
|
name: "acc_raw");
|
|
}
|
|
}
|
|
}
|