Files
PolyTraderSharp/src/PolyTrader.Modules.CopyTrading/Logic/SellLogic.cs
T
RichardandClaude Opus 4.8 581755029a Testnetz: Micro-Order-Minimum + SELL-Proportionalität extrahiert; SELL-Leiter (Phase 0.1) vorbereitet
Weiter im Muster extrahieren->testen (verhaltensneutral, clob.md):
- CopyTradingRisk.IsBelowPolymarketMinimum (Shares < 5.5 || USDC < 0.10) –
  BUY-Micro-Order-Filter verdrahtet + Tests.
- SellLogic.SellProportion (signalSize/(remaining+signalSize), Denominator<=0 -> 0)
  + Konstante MinSignificantSellRatio (0.30); SELL-Proportionalitätscheck der
  Engine ruft sie jetzt (Charakterisierung, sichert Phase-2-Umbau ab).
- SellLogic-Eskalationsleiter (Phase 0.1, NOCH NICHT verdrahtet): FirstLimit
  (HF-fest/prozentual), Floor (SellFloorPct), NextPrice (relative Stufe, auf Floor
  geclamped), IsAtFloor. Reine Grundlage fuer das spaetere SELL-Wiring.
- Tests: CopyTradingRisk-Minimum (5 Faelle) + SellLogicTests (Proportion +
  Leiter). Gesamt 154 gruen.

Build/Smoke gruen.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
2026-07-07 11:03:44 +02:00

56 lines
2.7 KiB
C#
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
using System;
namespace PolyTrader.Modules.CopyTrading.Logic
{
/// <summary>
/// Reine SELL-Entscheidungs-/Preislogik. Teil davon (Proportionalität) ist 1:1 aus der
/// aktuellen Engine übernommen (Charakterisierung, damit der Phase-2-Umbau abgesichert ist);
/// die Eskalationsleiter ist die Grundlage für Phase 0.1 (noch NICHT in der Engine verdrahtet).
/// </summary>
public static class SellLogic
{
// ----- Proportionalität (aktuelles Verhalten, Schwelle hart 30 %) -----
/// <summary>Ab dieser Verkaufsquote des Masters kopieren wir den SELL (aktuell hart 30 %).</summary>
public const decimal MinSignificantSellRatio = 0.30m;
/// <summary>
/// Anteil, den dieser SELL am Master-Bestand VOR dem Verkauf ausmacht:
/// <c>signalSize / (masterSharesRemaining + signalSize)</c>. Denominator ≤ 0 → 0.
/// </summary>
public static decimal SellProportion(decimal masterSharesRemaining, decimal signalSize)
{
decimal total = masterSharesRemaining + signalSize;
if (total <= 0m) return 0m;
return signalSize / total;
}
// ----- Eskalationsleiter (Phase 0.1, noch nicht verdrahtet) -----
/// <summary>
/// Erster SELL-Limit-Preis (GTD): HF-Trader fester Abschlag von 0.005 unter dem Master-Exit,
/// sonst prozentualer Abschlag (<paramref name="maxPriceDifferencePct"/>).
/// </summary>
public static decimal FirstLimit(decimal referencePrice, bool isHf, decimal maxPriceDifferencePct) =>
isHf ? referencePrice - CopyTradingRisk.HfLimitOffset
: referencePrice * (1.0m - maxPriceDifferencePct / 100.0m);
/// <summary>
/// Absolute Untergrenze der Leiter: <c>referencePrice × (1 SellFloorPct/100)</c>.
/// Darunter wird nicht mehr verkauft (Position halten statt Exit-Liquidity zu werden).
/// </summary>
public static decimal Floor(decimal referencePrice, decimal sellFloorPct) =>
referencePrice * (1.0m - sellFloorPct / 100.0m);
/// <summary>
/// Nächste Stufe nach ausbleibendem Fill: aktuellen Preis um <paramref name="stepPct"/> %
/// relativ senken, aber nie unter den <paramref name="floor"/>.
/// </summary>
public static decimal NextPrice(decimal currentPrice, decimal stepPct, decimal floor) =>
Math.Max(currentPrice * (1.0m - stepPct / 100.0m), floor);
/// <summary>Leiter erschöpft: aktueller Preis hat den Floor erreicht/unterschritten.</summary>
public static bool IsAtFloor(decimal currentPrice, decimal floor) => currentPrice <= floor;
}
}