f622dadf95
Adds a background forward-test engine that records flat-stake "paper" bets for directional anomalies as they fire and settles them when results arrive, measuring the detector's live, out-of-sample edge — the antidote to backtest overfitting. The results UI is a follow-up. - Domain: PaperBet entity (Rate>1 / Stake>0 invariants, Open factory, SettleAgainst — Won pays stake x rate, else Lost) + AnomalyEvidenceSide.RateFor. - Application: OpenPaperBetsUseCase (directional + score gate, dedups by AnomalyId, picks the post-flip favourite and its locked-in rate) and SettlePaperBetsUseCase (Won when pick == winner else Lost; ungraded events stay open; batched result lookup). - Infrastructure: PaperBetEntity + config (TEXT decimals, unique AnomalyId index, Outcome index), repository, mapping, additive AddPaperBets migration, and PaperTradingWorker (config-gated, baseline since-marker, open+settle per cycle). - Config: PaperTradingOptions / appsettings PaperTrading (Enabled:false default). - 25 tests: domain settlement, both use cases, and a real-SQLite round-trip incl. the unique-AnomalyId double-open backstop.
53 lines
1.9 KiB
C#
53 lines
1.9 KiB
C#
using Microsoft.EntityFrameworkCore.Migrations;
|
|
|
|
#nullable disable
|
|
|
|
namespace Marathon.Infrastructure.Migrations
|
|
{
|
|
/// <inheritdoc />
|
|
public partial class AddPaperBets : Migration
|
|
{
|
|
/// <inheritdoc />
|
|
protected override void Up(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.CreateTable(
|
|
name: "PaperBets",
|
|
columns: table => new
|
|
{
|
|
Id = table.Column<string>(type: "TEXT", nullable: false),
|
|
AnomalyId = table.Column<string>(type: "TEXT", nullable: false),
|
|
EventCode = table.Column<string>(type: "TEXT", nullable: false),
|
|
PickedSide = table.Column<int>(type: "INTEGER", nullable: false),
|
|
Rate = table.Column<decimal>(type: "TEXT", nullable: false),
|
|
Stake = table.Column<decimal>(type: "TEXT", nullable: false),
|
|
OpenedAt = table.Column<string>(type: "TEXT", nullable: false),
|
|
Outcome = table.Column<int>(type: "INTEGER", nullable: false),
|
|
SettledAt = table.Column<string>(type: "TEXT", nullable: true),
|
|
Payout = table.Column<decimal>(type: "TEXT", nullable: true)
|
|
},
|
|
constraints: table =>
|
|
{
|
|
table.PrimaryKey("PK_PaperBets", x => x.Id);
|
|
});
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_PaperBets_AnomalyId",
|
|
table: "PaperBets",
|
|
column: "AnomalyId",
|
|
unique: true);
|
|
|
|
migrationBuilder.CreateIndex(
|
|
name: "IX_PaperBets_Outcome",
|
|
table: "PaperBets",
|
|
column: "Outcome");
|
|
}
|
|
|
|
/// <inheritdoc />
|
|
protected override void Down(MigrationBuilder migrationBuilder)
|
|
{
|
|
migrationBuilder.DropTable(
|
|
name: "PaperBets");
|
|
}
|
|
}
|
|
}
|