Phase 5: AccountState-Split (Copytrading-Limits -> Modul)

- Copytrading-Detail-Einstellungen (PerMarketLimit, MaxBuyPrice, PerMasterLimit,
  Zeit-Limits, PreRedeemLimit, ProfitTarget, MaxPriceDifference) aus dem Core-
  AccountState in das Modul-Modell CopyTradingAccountSettings verschoben.
- CopyTradingState.AccountSettings + GetAccountSettings(accountId) (Default-safe).
- Consumer umgestellt: CopyTradingEngine, TraderMonitorService, PolymarketWssClient,
  frm_main lesen die Limits jetzt aus den Account-Settings.
- Neues Modul-Repo ICopyTradingAccountSettingsRepository (Collection ct_account_settings),
  in CopyTradingModule registriert.
- StartupHydration: Settings laden + EINMALIGE Migration der Alt-Limits aus dem
  Roh-accounts-Dokument (keine konfigurierten Limits gehen verloren).
- Build 0 Fehler.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Richard
2026-07-03 10:32:52 +02:00
co-authored by Claude Opus 4.8
parent 37f9d0fae2
commit 095c4b64aa
11 changed files with 208 additions and 60 deletions
@@ -0,0 +1,17 @@
using System.Collections.Generic;
using PolyTraderSharp.Models;
namespace PolyTrader.Modules.CopyTrading.Persistence
{
/// <summary>
/// Persistenz der copytrading-spezifischen Account-Detail-Einstellungen
/// (Collection "ct_account_settings", Schlüssel = AccountId).
/// </summary>
public interface ICopyTradingAccountSettingsRepository
{
List<CopyTradingAccountSettings> GetAll();
CopyTradingAccountSettings? Get(int accountId);
void Upsert(CopyTradingAccountSettings settings);
void Delete(int accountId);
}
}
@@ -0,0 +1,27 @@
using System.Collections.Generic;
using System.Linq;
using MongoDB.Driver;
using PolyTraderSharp.Models;
namespace PolyTrader.Modules.CopyTrading.Persistence
{
public class MongoCopyTradingAccountSettingsRepository : ICopyTradingAccountSettingsRepository
{
private readonly IMongoCollection<CopyTradingAccountSettings> _col;
public MongoCopyTradingAccountSettingsRepository(IMongoDatabase db)
{
_col = db.GetCollection<CopyTradingAccountSettings>("ct_account_settings");
}
public List<CopyTradingAccountSettings> GetAll() => _col.Find(_ => true).ToList();
public CopyTradingAccountSettings? Get(int accountId) =>
_col.Find(x => x.AccountId == accountId).FirstOrDefault();
public void Upsert(CopyTradingAccountSettings settings) =>
_col.ReplaceOne(x => x.AccountId == settings.AccountId, settings, new ReplaceOptions { IsUpsert = true });
public void Delete(int accountId) => _col.DeleteOne(x => x.AccountId == accountId);
}
}