Slice 2 (Fable-Fixes): K2 – Neustart-Reconciliation
Ruhende GTC-Leiter-/MakerEntry-Orders ueberleben Neustarts auf dem CLOB, der Verwaltungszustand (ExitLadders/ExitPending/PendingOrderTimestamps) ist transient. Ohne Bereinigung liefe die Engine gegen Waisen-Orders (Doppel-Leiter, Kaskaden). - StartupOrderReconciliationService (IHostedService): storniert beim Start je Live-Account alle offenen CLOB-Orders; danach entscheidet die Engine sauber neu. Registriert als ERSTER Modul-HostedService (nach Hydration, vor Monitor/Engine), pro Account fehlertolerant. - GetOpenOrdersAsync: assetId jetzt optional (default "") -> ohne Filter ALLE offenen Orders des Accounts. Signaturneutral (HMAC geht ueber Pfad ohne Query), rueckwaertskompatibel fuer die bestehenden per-Asset-Aufrufer. IClobClient + FakeClobClient nachgezogen. Hinweis: "/data/orders ohne asset_id = alle Orders" ist API-gated und im Zielland live zu verifizieren (wie M6). Tests: 3 neue (cancelt alle Orders je Live-Account, ueberspringt Demo/credential-los, no-op ohne offene Orders). Build 0 Fehler, 218 Tests gruen, --smoke-ui ok. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
0200a726e7
commit
98109b78f6
@@ -25,8 +25,11 @@ namespace PolyTraderSharp.Services
|
||||
/// <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>
|
||||
/// Liefert die offenen Orders (Id, Side, Price). Mit <paramref name="assetId"/> nur für dieses
|
||||
/// Asset; ohne (leer) ALLE offenen Orders des Accounts – genutzt von der Startup-Reconciliation.
|
||||
/// </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);
|
||||
|
||||
@@ -364,7 +364,7 @@ namespace PolyTraderSharp.Services
|
||||
return 0;
|
||||
}
|
||||
|
||||
public async Task<System.Collections.Generic.List<(string Id, string Side, decimal Price)>> GetOpenOrdersAsync(AccountState acc, string assetId)
|
||||
public async Task<System.Collections.Generic.List<(string Id, string Side, decimal Price)>> GetOpenOrdersAsync(AccountState acc, string assetId = "")
|
||||
{
|
||||
var result = new System.Collections.Generic.List<(string Id, string Side, decimal Price)>();
|
||||
if (string.IsNullOrEmpty(acc.ApiKey) || string.IsNullOrEmpty(acc.ApiSecret) || string.IsNullOrEmpty(acc.ApiPassphrase) || string.IsNullOrEmpty(acc.PrivateKey))
|
||||
@@ -373,7 +373,10 @@ namespace PolyTraderSharp.Services
|
||||
try
|
||||
{
|
||||
string endpoint = "/data/orders";
|
||||
string requestUrl = $"{endpoint}?asset_id={assetId}";
|
||||
// Ohne assetId: ALLE offenen Orders des Accounts (Startup-Reconciliation K2).
|
||||
// Die HMAC-Signatur geht über den Pfad "/data/orders" ohne Query-String, daher ist
|
||||
// das Weglassen des asset_id-Filters signaturneutral.
|
||||
string requestUrl = string.IsNullOrEmpty(assetId) ? endpoint : $"{endpoint}?asset_id={assetId}";
|
||||
string timestamp = GetClobTimestamp();
|
||||
|
||||
string signature = GenerateHmacSignature(acc.ApiSecret, timestamp, "GET", endpoint);
|
||||
|
||||
Reference in New Issue
Block a user