Supervisor S-3-Rest + RF-Designer-Konvertierung: Counterfactual, Tagesbericht, UI

RF-UI designerfaehig (Richards Vorgabe, letzter code-only-Altbestand):
- ResolutionFarmingMainForm auf partial + .Designer.cs umgestellt (4 Tabs Kandidaten/
  Positionen/Historie/Settings, alle Controls im Designer; Verhalten unveraendert).

S-3 Counterfactual ('Was waere aus abgelehnten BUYs geworden?'):
- CounterfactualJob (alle 6h, API-gedrosselt): nimmt Rejected-BUY-Entscheidungen mit
  abgelaufenem MarketEndDate aus dem Journal, prueft die Marktaufloesung
  (ICounterfactualResolutionSource; live = Adapter um CheckMarketResolutionAsync) und
  speichert IsWinner + hypothetischen PnL/Share (CounterfactualMath, pur) nach
  sup_counterfactuals (unique je DecisionId -> idempotent). Migration generiert+angewendet.
- Agent-Tool query_counterfactuals + UI-Tab 'Counterfactual' (via Designer).

S-3 Threema-Tagesbericht:
- DailyReportService: taeglich zur konfigurierten Stunde (OPT-IN via
  POLYTRADER_SUPERVISOR_DAILY=0-23) laesst der Agent einen 24h-Kurzbericht erstellen
  (KPIs je Modul, Fehler, Reject-Haeufungen), sendet via Threema und legt ihn als
  sup_report ab. Ohne OpenRouter-Key: stiller Skip mit Log.

Tests: +7 (CounterfactualMath, Job aufgeloest/unaufgeloest/idempotent, Tagesbericht
mit/ohne Key). Build 0 Fehler, 367 Tests gruen, --smoke-ui alle 5 Views gruen.

Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
Richard
2026-07-18 11:14:45 +02:00
co-authored by Claude Opus 4.8
parent b7b2a141e3
commit c7668170a4
14 changed files with 1252 additions and 95 deletions
@@ -0,0 +1,352 @@
namespace PolyTrader.Modules.ResolutionFarming.Ui
{
partial class ResolutionFarmingMainForm
{
private System.ComponentModel.IContainer components = null;
protected override void Dispose(bool disposing)
{
if (disposing && (components != null))
{
components.Dispose();
}
base.Dispose(disposing);
}
#region Vom Komponenten-Designer generierter Code
private void InitializeComponent()
{
this.tabControlRf = new System.Windows.Forms.TabControl();
this.tabKandidaten = new System.Windows.Forms.TabPage();
this.dgvCandidates = new System.Windows.Forms.DataGridView();
this.pnlCandTop = new System.Windows.Forms.Panel();
this.lblCandKonto = new System.Windows.Forms.Label();
this.cbCandAccount = new System.Windows.Forms.ComboBox();
this.btnCandRefresh = new System.Windows.Forms.Button();
this.tabPositionen = new System.Windows.Forms.TabPage();
this.dgvPositions = new System.Windows.Forms.DataGridView();
this.pnlPosTop = new System.Windows.Forms.Panel();
this.btnPosRefresh = new System.Windows.Forms.Button();
this.tabHistorie = new System.Windows.Forms.TabPage();
this.dgvHistory = new System.Windows.Forms.DataGridView();
this.lblHistSummary = new System.Windows.Forms.Label();
this.pnlHistTop = new System.Windows.Forms.Panel();
this.btnHistRefresh = new System.Windows.Forms.Button();
this.tabSettings = new System.Windows.Forms.TabPage();
this.pgSettings = new System.Windows.Forms.PropertyGrid();
this.pnlSetTop = new System.Windows.Forms.Panel();
this.lblSetKonto = new System.Windows.Forms.Label();
this.cbSettingsAccount = new System.Windows.Forms.ComboBox();
this.btnSettingsSave = new System.Windows.Forms.Button();
this.lblRfStatus = new System.Windows.Forms.Label();
this.tabControlRf.SuspendLayout();
this.tabKandidaten.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgvCandidates)).BeginInit();
this.pnlCandTop.SuspendLayout();
this.tabPositionen.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgvPositions)).BeginInit();
this.pnlPosTop.SuspendLayout();
this.tabHistorie.SuspendLayout();
((System.ComponentModel.ISupportInitialize)(this.dgvHistory)).BeginInit();
this.pnlHistTop.SuspendLayout();
this.tabSettings.SuspendLayout();
this.pnlSetTop.SuspendLayout();
this.SuspendLayout();
//
// tabControlRf
//
this.tabControlRf.Controls.Add(this.tabKandidaten);
this.tabControlRf.Controls.Add(this.tabPositionen);
this.tabControlRf.Controls.Add(this.tabHistorie);
this.tabControlRf.Controls.Add(this.tabSettings);
this.tabControlRf.Dock = System.Windows.Forms.DockStyle.Fill;
this.tabControlRf.Location = new System.Drawing.Point(0, 0);
this.tabControlRf.Name = "tabControlRf";
this.tabControlRf.SelectedIndex = 0;
this.tabControlRf.Size = new System.Drawing.Size(1000, 596);
this.tabControlRf.TabIndex = 0;
//
// tabKandidaten
//
this.tabKandidaten.Controls.Add(this.dgvCandidates);
this.tabKandidaten.Controls.Add(this.pnlCandTop);
this.tabKandidaten.Location = new System.Drawing.Point(4, 24);
this.tabKandidaten.Name = "tabKandidaten";
this.tabKandidaten.Padding = new System.Windows.Forms.Padding(3);
this.tabKandidaten.Size = new System.Drawing.Size(992, 568);
this.tabKandidaten.TabIndex = 0;
this.tabKandidaten.Text = "Kandidaten";
this.tabKandidaten.UseVisualStyleBackColor = true;
//
// dgvCandidates
//
this.dgvCandidates.AllowUserToAddRows = false;
this.dgvCandidates.AllowUserToDeleteRows = false;
this.dgvCandidates.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvCandidates.Dock = System.Windows.Forms.DockStyle.Fill;
this.dgvCandidates.Location = new System.Drawing.Point(3, 37);
this.dgvCandidates.Name = "dgvCandidates";
this.dgvCandidates.ReadOnly = true;
this.dgvCandidates.RowHeadersVisible = false;
this.dgvCandidates.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dgvCandidates.Size = new System.Drawing.Size(986, 528);
this.dgvCandidates.TabIndex = 1;
//
// pnlCandTop
//
this.pnlCandTop.Controls.Add(this.btnCandRefresh);
this.pnlCandTop.Controls.Add(this.cbCandAccount);
this.pnlCandTop.Controls.Add(this.lblCandKonto);
this.pnlCandTop.Dock = System.Windows.Forms.DockStyle.Top;
this.pnlCandTop.Location = new System.Drawing.Point(3, 3);
this.pnlCandTop.Name = "pnlCandTop";
this.pnlCandTop.Size = new System.Drawing.Size(986, 34);
this.pnlCandTop.TabIndex = 0;
//
// lblCandKonto
//
this.lblCandKonto.AutoSize = true;
this.lblCandKonto.Location = new System.Drawing.Point(6, 9);
this.lblCandKonto.Name = "lblCandKonto";
this.lblCandKonto.Size = new System.Drawing.Size(43, 15);
this.lblCandKonto.TabIndex = 0;
this.lblCandKonto.Text = "Konto:";
//
// cbCandAccount
//
this.cbCandAccount.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbCandAccount.Location = new System.Drawing.Point(55, 5);
this.cbCandAccount.Name = "cbCandAccount";
this.cbCandAccount.Size = new System.Drawing.Size(260, 23);
this.cbCandAccount.TabIndex = 1;
//
// btnCandRefresh
//
this.btnCandRefresh.Location = new System.Drawing.Point(325, 4);
this.btnCandRefresh.Name = "btnCandRefresh";
this.btnCandRefresh.Size = new System.Drawing.Size(110, 26);
this.btnCandRefresh.TabIndex = 2;
this.btnCandRefresh.Text = "Aktualisieren";
this.btnCandRefresh.UseVisualStyleBackColor = true;
//
// tabPositionen
//
this.tabPositionen.Controls.Add(this.dgvPositions);
this.tabPositionen.Controls.Add(this.pnlPosTop);
this.tabPositionen.Location = new System.Drawing.Point(4, 24);
this.tabPositionen.Name = "tabPositionen";
this.tabPositionen.Padding = new System.Windows.Forms.Padding(3);
this.tabPositionen.Size = new System.Drawing.Size(992, 568);
this.tabPositionen.TabIndex = 1;
this.tabPositionen.Text = "Positionen";
this.tabPositionen.UseVisualStyleBackColor = true;
//
// dgvPositions
//
this.dgvPositions.AllowUserToAddRows = false;
this.dgvPositions.AllowUserToDeleteRows = false;
this.dgvPositions.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvPositions.Dock = System.Windows.Forms.DockStyle.Fill;
this.dgvPositions.Location = new System.Drawing.Point(3, 37);
this.dgvPositions.Name = "dgvPositions";
this.dgvPositions.ReadOnly = true;
this.dgvPositions.RowHeadersVisible = false;
this.dgvPositions.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dgvPositions.Size = new System.Drawing.Size(986, 528);
this.dgvPositions.TabIndex = 1;
//
// pnlPosTop
//
this.pnlPosTop.Controls.Add(this.btnPosRefresh);
this.pnlPosTop.Dock = System.Windows.Forms.DockStyle.Top;
this.pnlPosTop.Location = new System.Drawing.Point(3, 3);
this.pnlPosTop.Name = "pnlPosTop";
this.pnlPosTop.Size = new System.Drawing.Size(986, 34);
this.pnlPosTop.TabIndex = 0;
//
// btnPosRefresh
//
this.btnPosRefresh.Location = new System.Drawing.Point(6, 4);
this.btnPosRefresh.Name = "btnPosRefresh";
this.btnPosRefresh.Size = new System.Drawing.Size(110, 26);
this.btnPosRefresh.TabIndex = 0;
this.btnPosRefresh.Text = "Aktualisieren";
this.btnPosRefresh.UseVisualStyleBackColor = true;
//
// tabHistorie
//
this.tabHistorie.Controls.Add(this.dgvHistory);
this.tabHistorie.Controls.Add(this.lblHistSummary);
this.tabHistorie.Controls.Add(this.pnlHistTop);
this.tabHistorie.Location = new System.Drawing.Point(4, 24);
this.tabHistorie.Name = "tabHistorie";
this.tabHistorie.Padding = new System.Windows.Forms.Padding(3);
this.tabHistorie.Size = new System.Drawing.Size(992, 568);
this.tabHistorie.TabIndex = 2;
this.tabHistorie.Text = "Historie / Statistik";
this.tabHistorie.UseVisualStyleBackColor = true;
//
// dgvHistory
//
this.dgvHistory.AllowUserToAddRows = false;
this.dgvHistory.AllowUserToDeleteRows = false;
this.dgvHistory.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dgvHistory.Dock = System.Windows.Forms.DockStyle.Fill;
this.dgvHistory.Location = new System.Drawing.Point(3, 85);
this.dgvHistory.Name = "dgvHistory";
this.dgvHistory.ReadOnly = true;
this.dgvHistory.RowHeadersVisible = false;
this.dgvHistory.SelectionMode = System.Windows.Forms.DataGridViewSelectionMode.FullRowSelect;
this.dgvHistory.Size = new System.Drawing.Size(986, 480);
this.dgvHistory.TabIndex = 2;
//
// lblHistSummary
//
this.lblHistSummary.Dock = System.Windows.Forms.DockStyle.Top;
this.lblHistSummary.Location = new System.Drawing.Point(3, 37);
this.lblHistSummary.Name = "lblHistSummary";
this.lblHistSummary.Padding = new System.Windows.Forms.Padding(6);
this.lblHistSummary.Size = new System.Drawing.Size(986, 48);
this.lblHistSummary.TabIndex = 1;
this.lblHistSummary.Text = "";
//
// pnlHistTop
//
this.pnlHistTop.Controls.Add(this.btnHistRefresh);
this.pnlHistTop.Dock = System.Windows.Forms.DockStyle.Top;
this.pnlHistTop.Location = new System.Drawing.Point(3, 3);
this.pnlHistTop.Name = "pnlHistTop";
this.pnlHistTop.Size = new System.Drawing.Size(986, 34);
this.pnlHistTop.TabIndex = 0;
//
// btnHistRefresh
//
this.btnHistRefresh.Location = new System.Drawing.Point(6, 4);
this.btnHistRefresh.Name = "btnHistRefresh";
this.btnHistRefresh.Size = new System.Drawing.Size(110, 26);
this.btnHistRefresh.TabIndex = 0;
this.btnHistRefresh.Text = "Aktualisieren";
this.btnHistRefresh.UseVisualStyleBackColor = true;
//
// tabSettings
//
this.tabSettings.Controls.Add(this.pgSettings);
this.tabSettings.Controls.Add(this.pnlSetTop);
this.tabSettings.Location = new System.Drawing.Point(4, 24);
this.tabSettings.Name = "tabSettings";
this.tabSettings.Padding = new System.Windows.Forms.Padding(3);
this.tabSettings.Size = new System.Drawing.Size(992, 568);
this.tabSettings.TabIndex = 3;
this.tabSettings.Text = "Settings";
this.tabSettings.UseVisualStyleBackColor = true;
//
// pgSettings
//
this.pgSettings.Dock = System.Windows.Forms.DockStyle.Fill;
this.pgSettings.Location = new System.Drawing.Point(3, 37);
this.pgSettings.Name = "pgSettings";
this.pgSettings.Size = new System.Drawing.Size(986, 528);
this.pgSettings.TabIndex = 1;
//
// pnlSetTop
//
this.pnlSetTop.Controls.Add(this.btnSettingsSave);
this.pnlSetTop.Controls.Add(this.cbSettingsAccount);
this.pnlSetTop.Controls.Add(this.lblSetKonto);
this.pnlSetTop.Dock = System.Windows.Forms.DockStyle.Top;
this.pnlSetTop.Location = new System.Drawing.Point(3, 3);
this.pnlSetTop.Name = "pnlSetTop";
this.pnlSetTop.Size = new System.Drawing.Size(986, 34);
this.pnlSetTop.TabIndex = 0;
//
// lblSetKonto
//
this.lblSetKonto.AutoSize = true;
this.lblSetKonto.Location = new System.Drawing.Point(6, 9);
this.lblSetKonto.Name = "lblSetKonto";
this.lblSetKonto.Size = new System.Drawing.Size(43, 15);
this.lblSetKonto.TabIndex = 0;
this.lblSetKonto.Text = "Konto:";
//
// cbSettingsAccount
//
this.cbSettingsAccount.DropDownStyle = System.Windows.Forms.ComboBoxStyle.DropDownList;
this.cbSettingsAccount.Location = new System.Drawing.Point(55, 5);
this.cbSettingsAccount.Name = "cbSettingsAccount";
this.cbSettingsAccount.Size = new System.Drawing.Size(260, 23);
this.cbSettingsAccount.TabIndex = 1;
//
// btnSettingsSave
//
this.btnSettingsSave.Location = new System.Drawing.Point(325, 4);
this.btnSettingsSave.Name = "btnSettingsSave";
this.btnSettingsSave.Size = new System.Drawing.Size(110, 26);
this.btnSettingsSave.TabIndex = 2;
this.btnSettingsSave.Text = "Speichern";
this.btnSettingsSave.UseVisualStyleBackColor = true;
//
// lblRfStatus
//
this.lblRfStatus.Dock = System.Windows.Forms.DockStyle.Bottom;
this.lblRfStatus.Location = new System.Drawing.Point(0, 596);
this.lblRfStatus.Name = "lblRfStatus";
this.lblRfStatus.Padding = new System.Windows.Forms.Padding(6, 2, 6, 2);
this.lblRfStatus.Size = new System.Drawing.Size(1000, 22);
this.lblRfStatus.TabIndex = 1;
this.lblRfStatus.Text = "";
//
// ResolutionFarmingMainForm
//
this.AutoScaleDimensions = new System.Drawing.SizeF(7F, 15F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(1000, 618);
this.Controls.Add(this.tabControlRf);
this.Controls.Add(this.lblRfStatus);
this.Name = "ResolutionFarmingMainForm";
this.StartPosition = System.Windows.Forms.FormStartPosition.CenterScreen;
this.Text = "ResolutionFarming";
this.tabControlRf.ResumeLayout(false);
this.tabKandidaten.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dgvCandidates)).EndInit();
this.pnlCandTop.ResumeLayout(false);
this.pnlCandTop.PerformLayout();
this.tabPositionen.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dgvPositions)).EndInit();
this.pnlPosTop.ResumeLayout(false);
this.tabHistorie.ResumeLayout(false);
((System.ComponentModel.ISupportInitialize)(this.dgvHistory)).EndInit();
this.pnlHistTop.ResumeLayout(false);
this.tabSettings.ResumeLayout(false);
this.pnlSetTop.ResumeLayout(false);
this.pnlSetTop.PerformLayout();
this.ResumeLayout(false);
}
#endregion
private System.Windows.Forms.TabControl tabControlRf;
private System.Windows.Forms.TabPage tabKandidaten;
private System.Windows.Forms.Panel pnlCandTop;
private System.Windows.Forms.Label lblCandKonto;
private System.Windows.Forms.ComboBox cbCandAccount;
private System.Windows.Forms.Button btnCandRefresh;
private System.Windows.Forms.DataGridView dgvCandidates;
private System.Windows.Forms.TabPage tabPositionen;
private System.Windows.Forms.Panel pnlPosTop;
private System.Windows.Forms.Button btnPosRefresh;
private System.Windows.Forms.DataGridView dgvPositions;
private System.Windows.Forms.TabPage tabHistorie;
private System.Windows.Forms.Panel pnlHistTop;
private System.Windows.Forms.Button btnHistRefresh;
private System.Windows.Forms.Label lblHistSummary;
private System.Windows.Forms.DataGridView dgvHistory;
private System.Windows.Forms.TabPage tabSettings;
private System.Windows.Forms.Panel pnlSetTop;
private System.Windows.Forms.Label lblSetKonto;
private System.Windows.Forms.ComboBox cbSettingsAccount;
private System.Windows.Forms.Button btnSettingsSave;
private System.Windows.Forms.PropertyGrid pgSettings;
private System.Windows.Forms.Label lblRfStatus;
}
}
@@ -9,11 +9,11 @@ using PolyTraderSharp;
namespace PolyTrader.Modules.ResolutionFarming.Ui
{
/// <summary>
/// Hauptfenster des ResolutionFarming-Moduls: ein TabControl mit Kandidaten, Positionen,
/// Historie/Statistik und Settings. Bewusst code-only konstruiert (kein Designer/.resx). DB-Zugriffe
/// sind defensiv (try/catch) die UI bleibt bedienbar, auch bevor die rf_-Migration angewendet ist.
/// Hauptfenster des ResolutionFarming-Moduls: Tabs Kandidaten, Positionen, Historie/Statistik,
/// Settings. Layout im Designer (ResolutionFarmingMainForm.Designer.cs), Verhalten/Daten hier.
/// DB-Zugriffe defensiv (Guarded), damit die UI auch ohne angewendete rf_-Migration bedienbar bleibt.
/// </summary>
public sealed class ResolutionFarmingMainForm : Form
public partial class ResolutionFarmingMainForm : Form
{
private IRfCandidateRepository? _candidates;
private IRfPositionRepository? _positions;
@@ -21,24 +21,18 @@ namespace PolyTrader.Modules.ResolutionFarming.Ui
private IRfSettingsRepository? _settingsRepo;
private TradingState? _state;
private readonly ComboBox _candAccount = new() { DropDownStyle = ComboBoxStyle.DropDownList, Width = 260 };
private readonly ComboBox _settingsAccount = new() { DropDownStyle = ComboBoxStyle.DropDownList, Width = 260 };
private readonly DataGridView _candGrid = NewGrid();
private readonly DataGridView _posGrid = NewGrid();
private readonly DataGridView _histGrid = NewGrid();
private readonly PropertyGrid _settingsGrid = new() { Dock = DockStyle.Fill };
private readonly Label _histSummary = new() { Dock = DockStyle.Top, Height = 48, Padding = new Padding(6), Text = "" };
private readonly Label _status = new() { Dock = DockStyle.Bottom, Height = 22, Padding = new Padding(6, 2, 6, 2), Text = "" };
private RfSettings? _currentSettings;
public ResolutionFarmingMainForm()
{
Text = "ResolutionFarming";
Width = 1000;
Height = 640;
StartPosition = FormStartPosition.CenterScreen;
BuildUi();
InitializeComponent();
btnCandRefresh.Click += (_, _) => RefreshCandidates();
cbCandAccount.SelectedIndexChanged += (_, _) => RefreshCandidates();
btnPosRefresh.Click += (_, _) => RefreshPositions();
btnHistRefresh.Click += (_, _) => RefreshHistory();
btnSettingsSave.Click += (_, _) => SaveSettings();
cbSettingsAccount.SelectedIndexChanged += (_, _) => LoadSettings();
}
/// <summary>Injiziert Repos/State (nach DI-Auflösung) und lädt die Ansichten.</summary>
@@ -56,72 +50,6 @@ namespace PolyTrader.Modules.ResolutionFarming.Ui
RefreshHistory();
}
// ---------------- UI-Aufbau ----------------
private static DataGridView NewGrid() => new()
{
Dock = DockStyle.Fill,
ReadOnly = true,
AllowUserToAddRows = false,
AllowUserToDeleteRows = false,
AutoGenerateColumns = true,
AutoSizeColumnsMode = DataGridViewAutoSizeColumnsMode.DisplayedCells,
SelectionMode = DataGridViewSelectionMode.FullRowSelect,
RowHeadersVisible = false
};
private void BuildUi()
{
var tabs = new TabControl { Dock = DockStyle.Fill };
// --- Kandidaten ---
var candTab = new TabPage("Kandidaten");
var candTop = new FlowLayoutPanel { Dock = DockStyle.Top, Height = 34, Padding = new Padding(4) };
candTop.Controls.Add(new Label { Text = "Konto:", AutoSize = true, Padding = new Padding(0, 6, 4, 0) });
candTop.Controls.Add(_candAccount);
var candRefresh = new Button { Text = "Aktualisieren" };
candRefresh.Click += (_, _) => RefreshCandidates();
candTop.Controls.Add(candRefresh);
candTab.Controls.Add(_candGrid);
candTab.Controls.Add(candTop);
_candAccount.SelectedIndexChanged += (_, _) => RefreshCandidates();
// --- Positionen ---
var posTab = new TabPage("Positionen");
var posTop = new FlowLayoutPanel { Dock = DockStyle.Top, Height = 34, Padding = new Padding(4) };
var posRefresh = new Button { Text = "Aktualisieren" };
posRefresh.Click += (_, _) => RefreshPositions();
posTop.Controls.Add(posRefresh);
posTab.Controls.Add(_posGrid);
posTab.Controls.Add(posTop);
// --- Historie / Statistik ---
var histTab = new TabPage("Historie / Statistik");
var histTop = new FlowLayoutPanel { Dock = DockStyle.Top, Height = 34, Padding = new Padding(4) };
var histRefresh = new Button { Text = "Aktualisieren" };
histRefresh.Click += (_, _) => RefreshHistory();
histTop.Controls.Add(histRefresh);
histTab.Controls.Add(_histGrid);
histTab.Controls.Add(_histSummary);
histTab.Controls.Add(histTop);
// --- Settings ---
var setTab = new TabPage("Settings");
var setTop = new FlowLayoutPanel { Dock = DockStyle.Top, Height = 34, Padding = new Padding(4) };
setTop.Controls.Add(new Label { Text = "Konto:", AutoSize = true, Padding = new Padding(0, 6, 4, 0) });
setTop.Controls.Add(_settingsAccount);
var setSave = new Button { Text = "Speichern" };
setSave.Click += (_, _) => SaveSettings();
setTop.Controls.Add(setSave);
setTab.Controls.Add(_settingsGrid);
setTab.Controls.Add(setTop);
_settingsAccount.SelectedIndexChanged += (_, _) => LoadSettings();
tabs.TabPages.AddRange(new[] { candTab, posTab, histTab, setTab });
Controls.Add(tabs);
Controls.Add(_status);
}
// ---------------- Daten ----------------
private void PopulateAccounts()
@@ -132,7 +60,7 @@ namespace PolyTrader.Modules.ResolutionFarming.Ui
.Select(a => new AccountItem(a.AccountId, string.IsNullOrEmpty(a.Name) ? $"#{a.AccountId}" : $"{a.Name} (#{a.AccountId}){(a.IsDemo ? " · Demo" : "")}"))
.ToList();
foreach (var combo in new[] { _candAccount, _settingsAccount })
foreach (var combo in new[] { cbCandAccount, cbSettingsAccount })
{
combo.DisplayMember = nameof(AccountItem.Label);
combo.ValueMember = nameof(AccountItem.Id);
@@ -148,14 +76,14 @@ namespace PolyTrader.Modules.ResolutionFarming.Ui
private void RefreshCandidates()
{
if (_candidates == null || SelectedAccountId(_candAccount) is not int accId) return;
Guarded("Kandidaten", () => _candGrid.DataSource = _candidates.GetRecent(accId, 200));
if (_candidates == null || SelectedAccountId(cbCandAccount) is not int accId) return;
Guarded("Kandidaten", () => dgvCandidates.DataSource = _candidates.GetRecent(accId, 200));
}
private void RefreshPositions()
{
if (_positions == null) return;
Guarded("Positionen", () => _posGrid.DataSource = _positions.GetAllOpen());
Guarded("Positionen", () => dgvPositions.DataSource = _positions.GetAllOpen());
}
private void RefreshHistory()
@@ -164,8 +92,8 @@ namespace PolyTrader.Modules.ResolutionFarming.Ui
Guarded("Historie", () =>
{
var trades = _closed.Find(_ => true);
_histGrid.DataSource = trades;
_histSummary.Text = BuildSummary(trades);
dgvHistory.DataSource = trades;
lblHistSummary.Text = BuildSummary(trades);
});
}
@@ -187,11 +115,11 @@ namespace PolyTrader.Modules.ResolutionFarming.Ui
private void LoadSettings()
{
if (_settingsRepo == null || SelectedAccountId(_settingsAccount) is not int accId) return;
if (_settingsRepo == null || SelectedAccountId(cbSettingsAccount) is not int accId) return;
Guarded("Settings", () =>
{
_currentSettings = _settingsRepo.Get(accId) ?? new RfSettings { AccountId = accId };
_settingsGrid.SelectedObject = _currentSettings;
pgSettings.SelectedObject = _currentSettings;
SetStatus($"Einstellungen für Konto #{accId}.");
});
}
@@ -212,7 +140,7 @@ namespace PolyTrader.Modules.ResolutionFarming.Ui
catch (Exception ex) { SetStatus($"{what}: DB nicht bereit ({ex.Message}). Migration angewendet?"); }
}
private void SetStatus(string text) => _status.Text = text;
private void SetStatus(string text) => lblRfStatus.Text = text;
private sealed record AccountItem(int Id, string Label);
}