Phase 6 (Stufe 6): MongoDB vollstaendig entfernt
- Legacy-Form stillgelegt: frm_main(.Designer/.resx) + frm_analytics(.Designer/.resx) geloescht, 'Open Legacy'-Menue aus LauncherForm entfernt. - Program.cs: IMongoDatabase-Registrierung + closed_trades-Cleanup weg; Trade-Nummerierung liest jetzt hoechste TradeId aus ICopyTradeLogRepository. - StartupHydrationService: Mongo-/Bson-Fallback entfernt (Settings kommen aus dem Repo; fehlende Accounts erhalten Default-Settings). - Alle Mongo*Repository (Core 4 + Modul 4) geloescht; DI-Zweige auf EF/MySQL reduziert (AddCorePersistence, CopyTradingModule). - ConfigMigrator: Mongo-Pfad (Run/MigrateSettings) entfernt; nur noch RunFromJson + VerifyMySql (kein Mongo-Treiber mehr). - Modelle: [BsonId] entfernt (EF-Keys via HasKey); ObjectId-Defaults -> Guid. - LiteDB-Shim (MongoDbLiteDBShim) geloescht; MongoDB.Driver- + LiteDB-Pakete aus App/Core entfernt; stale usings + user-sichtbare Strings bereinigt. - DatabaseOptions/appsettings.json: Mongo-Provider/Connection-Felder entfernt. - Build gruen; --verify-mysql bestaetigt 3 Accounts/3 Settings/32 Trader/2344 Markets. Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
co-authored by
Claude Opus 4.8
parent
d227d24ca8
commit
b951b912f4
@@ -1,24 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MongoDB.Driver;
|
||||
using PolyTraderSharp.Models;
|
||||
|
||||
namespace PolyTrader.Core.Persistence.Mongo
|
||||
{
|
||||
public class MongoAccountRepository : IAccountRepository
|
||||
{
|
||||
private readonly IMongoCollection<AccountState> _col;
|
||||
|
||||
public MongoAccountRepository(IMongoDatabase db)
|
||||
{
|
||||
_col = db.GetCollection<AccountState>("accounts");
|
||||
}
|
||||
|
||||
public List<AccountState> GetAll() => _col.Find(_ => true).ToList();
|
||||
|
||||
public void Upsert(AccountState account) =>
|
||||
_col.ReplaceOne(x => x.AccountId == account.AccountId, account, new ReplaceOptions { IsUpsert = true });
|
||||
|
||||
public void Delete(int accountId) => _col.DeleteMany(x => x.AccountId == accountId);
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MongoDB.Driver;
|
||||
using PolyTraderSharp.Models;
|
||||
|
||||
namespace PolyTrader.Core.Persistence.Mongo
|
||||
{
|
||||
public class MongoMarketRepository : IMarketRepository
|
||||
{
|
||||
private readonly IMongoCollection<MarketData> _col;
|
||||
|
||||
public MongoMarketRepository(IMongoDatabase db)
|
||||
{
|
||||
_col = db.GetCollection<MarketData>("markets");
|
||||
}
|
||||
|
||||
public MarketData? GetById(string id) => _col.Find(x => x.Id == id).FirstOrDefault();
|
||||
|
||||
public MarketData? FindByTokenId(string tokenId) =>
|
||||
_col.Find(x => x.ClobTokenIds != null && x.ClobTokenIds.Contains(tokenId)).FirstOrDefault();
|
||||
|
||||
public List<MarketData> GetActive() => _col.Find(x => !x.Closed).ToList();
|
||||
|
||||
public void Upsert(MarketData market) =>
|
||||
_col.ReplaceOne(x => x.Id == market.Id, market, new ReplaceOptions { IsUpsert = true });
|
||||
|
||||
public void Insert(MarketData market) => _col.InsertOne(market);
|
||||
|
||||
public void Update(MarketData market) => _col.ReplaceOne(x => x.Id == market.Id, market);
|
||||
|
||||
public void EnsureIndexes()
|
||||
{
|
||||
try
|
||||
{
|
||||
var keys = Builders<MarketData>.IndexKeys.Ascending(x => x.Id);
|
||||
_col.Indexes.CreateOne(new CreateIndexModel<MarketData>(keys));
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -1,46 +0,0 @@
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using MongoDB.Driver;
|
||||
using PolyTraderSharp.Models;
|
||||
|
||||
namespace PolyTrader.Core.Persistence.Mongo
|
||||
{
|
||||
public class MongoPositionRepository : IPositionRepository
|
||||
{
|
||||
private readonly IMongoDatabase _db;
|
||||
|
||||
public MongoPositionRepository(IMongoDatabase db)
|
||||
{
|
||||
_db = db;
|
||||
}
|
||||
|
||||
private IMongoCollection<Position> Live(int accountId) =>
|
||||
_db.GetCollection<Position>($"open_positions_{accountId}");
|
||||
|
||||
private IMongoCollection<Position> Demo(int accountId) =>
|
||||
_db.GetCollection<Position>($"demo_positions_{accountId}");
|
||||
|
||||
public List<Position> GetLive(int accountId) => Live(accountId).Find(_ => true).ToList();
|
||||
public List<Position> GetDemo(int accountId) => Demo(accountId).Find(_ => true).ToList();
|
||||
|
||||
public Position? FindLive(int accountId, string tokenId) =>
|
||||
Live(accountId).Find(x => x.TokenId == tokenId).FirstOrDefault();
|
||||
|
||||
public Position? FindDemo(int accountId, string tokenId) =>
|
||||
Demo(accountId).Find(x => x.TokenId == tokenId).FirstOrDefault();
|
||||
|
||||
public void UpsertLive(int accountId, Position position) =>
|
||||
Live(accountId).ReplaceOne(x => x.TokenId == position.TokenId, position, new ReplaceOptions { IsUpsert = true });
|
||||
|
||||
public void UpsertDemo(int accountId, Position position) =>
|
||||
Demo(accountId).ReplaceOne(x => x.TokenId == position.TokenId, position, new ReplaceOptions { IsUpsert = true });
|
||||
|
||||
public void DeleteLive(int accountId, string tokenId) =>
|
||||
Live(accountId).DeleteOne(x => x.TokenId == tokenId);
|
||||
|
||||
public void DeleteDemo(int accountId, string tokenId) =>
|
||||
Demo(accountId).DeleteOne(x => x.TokenId == tokenId);
|
||||
|
||||
public void DropDemo(int accountId) => _db.DropCollection($"demo_positions_{accountId}");
|
||||
}
|
||||
}
|
||||
@@ -1,41 +0,0 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
using System.Linq.Expressions;
|
||||
using MongoDB.Driver;
|
||||
using PolyTraderSharp.Models;
|
||||
|
||||
namespace PolyTrader.Core.Persistence.Mongo
|
||||
{
|
||||
public class MongoTradeLogRepository : ITradeLogRepository
|
||||
{
|
||||
private readonly IMongoCollection<TradeRecord> _col;
|
||||
|
||||
public MongoTradeLogRepository(IMongoDatabase db)
|
||||
{
|
||||
_col = db.GetCollection<TradeRecord>("trade_log");
|
||||
}
|
||||
|
||||
public void EnsureIndexes()
|
||||
{
|
||||
try
|
||||
{
|
||||
_col.Indexes.CreateOne(new CreateIndexModel<TradeRecord>(
|
||||
Builders<TradeRecord>.IndexKeys.Descending(x => x.ClosedAt)));
|
||||
_col.Indexes.CreateOne(new CreateIndexModel<TradeRecord>(
|
||||
Builders<TradeRecord>.IndexKeys.Ascending(x => x.ModuleName)));
|
||||
_col.Indexes.CreateOne(new CreateIndexModel<TradeRecord>(
|
||||
Builders<TradeRecord>.IndexKeys.Ascending(x => x.AccountId)));
|
||||
}
|
||||
catch { }
|
||||
}
|
||||
|
||||
public void Insert(TradeRecord record) => _col.InsertOne(record);
|
||||
|
||||
public List<TradeRecord> GetRecent(int limit) =>
|
||||
_col.Find(_ => true).SortByDescending(x => x.ClosedAt).Limit(limit).ToList();
|
||||
|
||||
public List<TradeRecord> Find(Expression<Func<TradeRecord, bool>> predicate) =>
|
||||
_col.Find(predicate).ToList();
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user