feat(bot): add FinlyticBot autonomous paper trading microservice with Alpaca Markets API integration
This commit is contained in:
@@ -0,0 +1,45 @@
|
||||
using System;
|
||||
using FinlyticBot.Entities;
|
||||
using FinlyticCore.Database;
|
||||
using FinlyticCore.Entities.Settings;
|
||||
using Microsoft.EntityFrameworkCore;
|
||||
|
||||
namespace FinlyticBot.Database;
|
||||
|
||||
public class BotDbContext : DbContext, ISettingsDbContext
|
||||
{
|
||||
public BotDbContext(DbContextOptions<BotDbContext> options) : base(options) { }
|
||||
|
||||
public DbSet<SettingEntity> DynamicSettings => Set<SettingEntity>();
|
||||
public DbSet<ExecutedPaperTradeEntity> ExecutedPaperTrades => Set<ExecutedPaperTradeEntity>();
|
||||
public DbSet<BotAuditLogEntity> BotAuditLogs => Set<BotAuditLogEntity>();
|
||||
|
||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||
{
|
||||
base.OnModelCreating(modelBuilder);
|
||||
|
||||
modelBuilder.Entity<SettingEntity>(entity =>
|
||||
{
|
||||
entity.HasKey(e => e.Id);
|
||||
entity.HasIndex(e => e.Key).IsUnique();
|
||||
});
|
||||
|
||||
modelBuilder.Entity<ExecutedPaperTradeEntity>(entity =>
|
||||
{
|
||||
entity.HasIndex(e => e.TradeId).IsUnique();
|
||||
entity.HasIndex(e => e.Symbol);
|
||||
entity.HasIndex(e => e.Isin);
|
||||
entity.HasIndex(e => e.AlpacaOrderId);
|
||||
entity.HasIndex(e => e.Status);
|
||||
entity.HasIndex(e => e.PlacedAt);
|
||||
});
|
||||
|
||||
modelBuilder.Entity<BotAuditLogEntity>(entity =>
|
||||
{
|
||||
entity.HasIndex(e => e.TradeId);
|
||||
entity.HasIndex(e => e.Symbol);
|
||||
entity.HasIndex(e => e.Action);
|
||||
entity.HasIndex(e => e.Timestamp);
|
||||
});
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user