Phase 5: CopyTrading-Modul-Migration (Services + Modul-Contract)
- TraderMonitorService, CopyTradingEngine, TraderAnalyticsJob physisch ins Modul-Projekt (src/PolyTrader.Modules.CopyTrading/Services) verschoben. - Neu: CopyTradingModule : IPolyTraderModule — registriert CopyTradingState, die Signal-/Trade-Channels, ICopyTradeLogRepository und die Modul-Services selbst. - Program.cs: Modul-Discovery (foreach module.RegisterServices / RegisterUi); die entsprechenden Direkt-Registrierungen entfernt. StartupHydration laeuft weiterhin als erster HostedService (State-Hydration vor Trading). - MasterTraderAnalyticsJob bleibt vorerst in der App (nutzt noch den App-Shim fuer mt_history -> braucht erst ein History-Repo). RegisterUi noch leer (Modul-Views folgen; Copytrading-UI weiter ueber Legacy erreichbar). - Build 0 Fehler. Launcher zeigt jetzt "Module: 1". Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
4f6c7fdb86
commit
ff1db2aea0
@@ -0,0 +1,55 @@
|
||||
using System.Threading;
|
||||
using System.Threading.Tasks;
|
||||
using System.Threading.Channels;
|
||||
using Microsoft.Extensions.Configuration;
|
||||
using Microsoft.Extensions.DependencyInjection;
|
||||
using PolyTrader.Core.Modularity;
|
||||
using PolyTrader.Modules.CopyTrading.Persistence;
|
||||
using PolyTraderSharp;
|
||||
using PolyTraderSharp.Models;
|
||||
using PolyTraderSharp.Services;
|
||||
|
||||
namespace PolyTrader.Modules.CopyTrading
|
||||
{
|
||||
/// <summary>
|
||||
/// Das Copytrading-Modul: registriert seinen eigenen State, seine Channels, sein
|
||||
/// Trade-Log-Repository und seine Services selbst. Die App kennt nur den Contract.
|
||||
/// </summary>
|
||||
public class CopyTradingModule : IPolyTraderModule
|
||||
{
|
||||
public string Name => "CopyTrading";
|
||||
public string DbPrefix => "ct_";
|
||||
|
||||
public void RegisterServices(IServiceCollection services, IConfiguration configuration)
|
||||
{
|
||||
// Copytrading-Hot-Path-State
|
||||
services.AddSingleton<CopyTradingState>();
|
||||
|
||||
// Signal-/Trade-Channels des Moduls
|
||||
var copySignalChannel = Channel.CreateUnbounded<CopySignal>();
|
||||
var closedTradeChannel = Channel.CreateUnbounded<ClosedTrade>();
|
||||
services.AddSingleton(copySignalChannel.Writer);
|
||||
services.AddSingleton(copySignalChannel.Reader);
|
||||
services.AddSingleton(closedTradeChannel.Writer);
|
||||
services.AddSingleton(closedTradeChannel.Reader);
|
||||
|
||||
// Modul-eigener Trade-Log
|
||||
services.AddSingleton<ICopyTradeLogRepository, MongoCopyTradeLogRepository>();
|
||||
|
||||
// Modul-Services (Signalquelle, Ausführung, Analytics)
|
||||
services.AddSingleton<TraderMonitorService>();
|
||||
services.AddHostedService(sp => sp.GetRequiredService<TraderMonitorService>());
|
||||
services.AddHostedService<CopyTradingEngine>();
|
||||
services.AddHostedService<TraderAnalyticsJob>();
|
||||
}
|
||||
|
||||
public void RegisterUi(IModuleUiHost host)
|
||||
{
|
||||
// TODO: Master-Traders- und Geschlossene-Trades-Views als Modul-UI beisteuern.
|
||||
}
|
||||
|
||||
public Task StartAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
||||
|
||||
public Task StopAsync(CancellationToken cancellationToken) => Task.CompletedTask;
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user