Slice 0 (Fable-Fixes): IClobClient-Seam fuer testbare CLOB-Interaktionen

Verhaltensneutrale Testinfrastruktur als Grundlage fuer Slice 1/2:
- IClobClient-Interface (Core) ueber die von Leiter/Reconciliation genutzten
  CLOB-Methoden (Place/CancelConflicting/GetOpenOrders/CancelOrder).
- PolymarketClobClient implementiert IClobClient (Signaturen unveraendert).
- DI-Seam im Modul: IClobClient -> PolymarketClobClient-Singleton.
- SellLadderService haengt jetzt an IClobClient (statische CalculateExactOrderAmounts
  bleibt am konkreten Typ).
- InternalsVisibleTo(PolyTrader.Tests) + FakeClobClient-Test-Double.

Verifikation: Build 0 Fehler, 207 Tests gruen, --smoke-ui Container-Aufbau ok.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Richard
2026-07-09 11:53:12 +02:00
co-authored by Claude Opus 4.8
parent bb929fa23a
commit ad8f7b0d03
6 changed files with 108 additions and 3 deletions
@@ -66,6 +66,10 @@ namespace PolyTrader.Modules.CopyTrading
services.AddHostedService<AlchemyWebsocketService>();
services.AddHostedService<PolymarketWssClient>();
// IClobClient-Seam: Leiter/Reconciliation hängen am Interface (mockbar für Integrationstests);
// die Live-Instanz ist der eine PolymarketClobClient-Singleton aus dem App-Container.
services.AddSingleton<IClobClient>(sp => sp.GetRequiredService<PolymarketClobClient>());
// Phase 0.1: SELL-Eskalationsleiter (preist offene Exit-Limits stufenweise nach).
// Singleton + Hosted, damit Engine und TraderMonitor StartLadderAsync aufrufen können.
services.AddSingleton<SellLadderService>();
@@ -4,6 +4,13 @@
<ProjectReference Include="..\PolyTrader.Core\PolyTrader.Core.csproj" />
</ItemGroup>
<!-- Erlaubt dem Testprojekt, interne Service-Methoden (z.B. Leiter-Tick) integrationszutesten. -->
<ItemGroup>
<AssemblyAttribute Include="System.Runtime.CompilerServices.InternalsVisibleToAttribute">
<_Parameter1>PolyTrader.Tests</_Parameter1>
</AssemblyAttribute>
</ItemGroup>
<ItemGroup>
<PackageReference Include="Pomelo.EntityFrameworkCore.MySql" Version="8.0.3" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.11">
@@ -27,7 +27,7 @@ namespace PolyTraderSharp.Services
private readonly CopyTradingState _copyState;
private readonly TradingState _state;
private readonly PolymarketClobClient _clob;
private readonly IClobClient _clob;
private readonly TerminalLogger _logger;
private readonly ThreemaService _threema;
private readonly IPositionRepository _positionRepo;
@@ -35,7 +35,7 @@ namespace PolyTraderSharp.Services
public SellLadderService(
CopyTradingState copyState,
TradingState state,
PolymarketClobClient clob,
IClobClient clob,
TerminalLogger logger,
ThreemaService threema,
IPositionRepository positionRepo)