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:
co-authored by
Claude Opus 4.8
parent
bb929fa23a
commit
ad8f7b0d03
@@ -0,0 +1,34 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Threading.Tasks;
|
||||
using PolyTraderSharp.Models;
|
||||
|
||||
namespace PolyTraderSharp.Services
|
||||
{
|
||||
/// <summary>
|
||||
/// Schmales Interface über die CLOB-Order-Operationen, die die SELL-Eskalationsleiter und die
|
||||
/// Startup-Reconciliation nutzen. Zweck: Diese geldkritischen Service-Interaktionen (Leiter vs.
|
||||
/// Cleanup, Neustart-Cancel) über einen gemockten Client integrationstestbar machen, ohne den
|
||||
/// echten <see cref="PolymarketClobClient"/> anzufassen.
|
||||
///
|
||||
/// Bewusst minimal – nur die tatsächlich von den Modul-Services aufgerufenen Methoden. Die
|
||||
/// Preis-/Mengenberechnung bleibt als statische, reine Methode
|
||||
/// (<see cref="PolymarketClobClient.CalculateExactOrderAmounts"/>) außerhalb des Interfaces.
|
||||
/// </summary>
|
||||
public interface IClobClient
|
||||
{
|
||||
/// <summary>Platziert eine Order und liefert "OK" oder eine Fehlerbeschreibung.</summary>
|
||||
Task<string> PlaceOrderAsync(
|
||||
AccountState account, string tokenId, string sideStr, decimal investAmountUsd, decimal limitPrice,
|
||||
string orderType = "FOK", bool debugPayloadLog = false, bool isNegRisk = false, int actualFeeBps = 0,
|
||||
decimal? overrideTickSize = null, int? overrideMakerDecimals = null, int? overrideTakerDecimals = null);
|
||||
|
||||
/// <summary>Cancelt konfligierende offene Orders desselben Tokens vor dem Nachpreisen/Platzieren.</summary>
|
||||
Task CancelConflictingOrdersAsync(AccountState acc, string assetId, decimal newPrice, string sideStr);
|
||||
|
||||
/// <summary>Liefert die offenen Orders (Id, Side, Price) für ein Asset.</summary>
|
||||
Task<List<(string Id, string Side, decimal Price)>> GetOpenOrdersAsync(AccountState acc, string assetId);
|
||||
|
||||
/// <summary>Cancelt eine einzelne Order per OrderId; true bei Erfolg.</summary>
|
||||
Task<bool> CancelOrderAsync(AccountState acc, string orderId);
|
||||
}
|
||||
}
|
||||
@@ -100,7 +100,7 @@ namespace PolyTraderSharp.Services
|
||||
public byte SignatureType { get; set; }
|
||||
}
|
||||
|
||||
public class PolymarketClobClient
|
||||
public class PolymarketClobClient : IClobClient
|
||||
{
|
||||
private readonly HttpClient _httpClient;
|
||||
private readonly TerminalLogger _logger;
|
||||
|
||||
Reference in New Issue
Block a user