Baseline: Ausgangszustand vor Modularisierung
Erster Commit des bestehenden monolithischen WinForms-Copytraders, inklusive der Alt-Backups (*.bak), damit diese dauerhaft in der Historie rekonstruierbar bleiben. Threema-Lib unter libs/ wurde vendored (nested .git entfernt). Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
using System.Collections.Concurrent;
|
||||
using PolyTraderSharp.Models;
|
||||
|
||||
namespace PolyTraderSharp
|
||||
{
|
||||
public enum TradingMode
|
||||
{
|
||||
Inactive,
|
||||
SellOnly,
|
||||
Active
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// In-Memory Hot-Path State for PolyTrader.
|
||||
/// Replaces database lookups for core trading logic.
|
||||
/// </summary>
|
||||
public class TradingState
|
||||
{
|
||||
// Settings
|
||||
public bool GlobalTradingPaused { get; set; } = false;
|
||||
public TradingMode LiveTradingMode { get; set; } = TradingMode.Inactive;
|
||||
public TradingMode DemoTradingMode { get; set; } = TradingMode.Inactive;
|
||||
public bool IsAlchemyHealthy { get; set; } = false;
|
||||
public bool EnableBlockchainParser { get; set; } = true;
|
||||
public bool DebugPollingLog { get; set; } = false;
|
||||
public bool DebugOrderPayloadLog { get; set; } = false;
|
||||
public bool SixSharesMinimum { get; set; } = true;
|
||||
|
||||
// Accounts (AccountId -> State)
|
||||
public ConcurrentDictionary<int, AccountState> Accounts { get; } = new();
|
||||
|
||||
// Tracked Traders (TraderId -> TrackedTrader)
|
||||
public ConcurrentDictionary<int, TrackedTrader> Traders { get; } = new();
|
||||
|
||||
private int _totalCopyTrades = 0;
|
||||
public int TotalCopyTrades
|
||||
{
|
||||
get => _totalCopyTrades;
|
||||
set => _totalCopyTrades = value;
|
||||
}
|
||||
|
||||
public int GetNextTradeId()
|
||||
{
|
||||
return Interlocked.Increment(ref _totalCopyTrades);
|
||||
}
|
||||
|
||||
public decimal GlobalPnl { get; set; } = 0.0m;
|
||||
// Analytics Cache (AccountId -> List<TraderAnalyticsResult>)
|
||||
public ConcurrentDictionary<int, List<TraderAnalyticsResult>> TraderAnalyticsCache { get; } = new();
|
||||
|
||||
// Tracks when live orders were placed for stale order cleanup
|
||||
// Key: "AccountId_TokenId", Value: (PlacedAt, SourceTraderId)
|
||||
public ConcurrentDictionary<string, (DateTime PlacedAt, int SourceTraderId)> PendingOrderTimestamps { get; } = new();
|
||||
|
||||
// High-Performance Global Market Cache to prevent LiteDB bottlenecks during signal processing
|
||||
public ConcurrentDictionary<string, MarketData> MarketCache { get; } = new(StringComparer.OrdinalIgnoreCase);
|
||||
|
||||
// Master Trader Position Tracker: Tracks how many shares each master trader holds per token.
|
||||
// Key: "{TraderId}_{TokenId}", Value: (Shares, LastUpdated)
|
||||
// Used to determine if a SELL signal is a partial sell (ignore) or a full exit (copy).
|
||||
public ConcurrentDictionary<string, (decimal Shares, DateTime LastUpdated)> MasterTraderPositions { get; } = new();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user