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>
40 lines
1.2 KiB
C#
40 lines
1.2 KiB
C#
using FluentAssertions;
|
|
using IBKRTrader.Modules.Accounting.Logic;
|
|
using IBKRTrader.Modules.Accounting.Models;
|
|
|
|
namespace IBKRTrader.Tests.Modules.Accounting;
|
|
|
|
[Trait("cat", "unit")]
|
|
public class FxConverterTests
|
|
{
|
|
private static FxRate R(int day, decimal rate) =>
|
|
new() { Date = new DateTime(2026, 5, day), UsdToEur = rate, Source = "ECB" };
|
|
|
|
[Fact]
|
|
public void UsesNearestRateOnOrBefore()
|
|
{
|
|
var conv = new FxConverter(new[] { R(1, 0.90m), R(10, 0.92m) });
|
|
|
|
conv.UsdToEurOn(new DateTime(2026, 5, 5)).Should().Be(0.90m); // zwischen 1. und 10. → 0.90
|
|
conv.UsdToEurOn(new DateTime(2026, 5, 10)).Should().Be(0.92m); // exakt
|
|
conv.UsdToEurOn(new DateTime(2026, 5, 20)).Should().Be(0.92m); // nach letztem → letzter
|
|
}
|
|
|
|
[Fact]
|
|
public void ReturnsNull_WhenNoRateBeforeDate()
|
|
{
|
|
var conv = new FxConverter(new[] { R(10, 0.92m) });
|
|
|
|
conv.UsdToEurOn(new DateTime(2026, 5, 1)).Should().BeNull();
|
|
conv.UsdToEur(100m, new DateTime(2026, 5, 1)).Should().BeNull();
|
|
}
|
|
|
|
[Fact]
|
|
public void ConvertsAndRounds()
|
|
{
|
|
var conv = new FxConverter(new[] { R(1, 0.9123m) });
|
|
|
|
conv.UsdToEur(100m, new DateTime(2026, 5, 2)).Should().Be(91.23m);
|
|
}
|
|
}
|