feat(bot): add FinlyticBot autonomous paper trading microservice with Alpaca Markets API integration

This commit is contained in:
2026-08-17 16:32:47 +02:00
parent 3972507cb0
commit 5497cc5de7
21 changed files with 1924 additions and 14 deletions
+37
View File
@@ -0,0 +1,37 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace FinlyticBot.Entities;
[Table("BotAuditLogs")]
public class BotAuditLogEntity
{
[Key]
public Guid Id { get; set; } = Guid.NewGuid();
[Required]
[MaxLength(100)]
public string TradeId { get; set; } = string.Empty;
[Required]
[MaxLength(30)]
public string Symbol { get; set; } = string.Empty;
[Required]
[MaxLength(50)]
public string Action { get; set; } = string.Empty; // "Evaluated", "Rejected", "OrderPlaced", "OrderFilled", "OrderClosed", "EmergencyStopped"
public bool IsAccepted { get; set; }
[MaxLength(500)]
public string? Reason { get; set; }
[Column(TypeName = "decimal(18,4)")]
public decimal? CalculatedSize { get; set; }
[Column(TypeName = "decimal(18,4)")]
public decimal? AccountEquity { get; set; }
public DateTime Timestamp { get; set; } = DateTime.UtcNow;
}
@@ -0,0 +1,78 @@
using System;
using System.ComponentModel.DataAnnotations;
using System.ComponentModel.DataAnnotations.Schema;
namespace FinlyticBot.Entities;
[Table("ExecutedPaperTrades")]
public class ExecutedPaperTradeEntity
{
[Key]
public Guid Id { get; set; } = Guid.NewGuid();
[Required]
[MaxLength(100)]
public string TradeId { get; set; } = string.Empty;
[Required]
[MaxLength(30)]
public string Symbol { get; set; } = string.Empty;
[MaxLength(30)]
public string Isin { get; set; } = string.Empty;
[MaxLength(200)]
public string CompanyName { get; set; } = string.Empty;
public Guid? AlpacaOrderId { get; set; }
[MaxLength(20)]
public string Side { get; set; } = "BUY"; // "BUY", "SELL"
[Column(TypeName = "decimal(18,4)")]
public decimal Quantity { get; set; }
[Column(TypeName = "decimal(18,4)")]
public decimal SignalEntryPrice { get; set; }
[Column(TypeName = "decimal(18,4)")]
public decimal? ActualFillPrice { get; set; }
[Column(TypeName = "decimal(18,4)")]
public decimal StopLossPrice { get; set; }
[Column(TypeName = "decimal(18,4)")]
public decimal TakeProfitPrice1 { get; set; }
[Column(TypeName = "decimal(18,4)")]
public decimal? TakeProfitPrice2 { get; set; }
[Column(TypeName = "decimal(18,4)")]
public decimal CalculatedCrv { get; set; }
public double WinRate { get; set; }
[Column(TypeName = "decimal(18,4)")]
public decimal? SlippagePercent { get; set; }
[Column(TypeName = "decimal(18,4)")]
public decimal RealizedPnl { get; set; }
[Column(TypeName = "decimal(18,4)")]
public decimal? RealizedPnlPercent { get; set; }
[Required]
[MaxLength(30)]
public string Status { get; set; } = "Proposed"; // "Proposed", "Submitted", "Accepted", "PartiallyFilled", "Filled", "Closed", "Rejected", "Canceled"
[MaxLength(1000)]
public string? RejectReason { get; set; }
public DateTime PlacedAt { get; set; } = DateTime.UtcNow;
public DateTime? FilledAt { get; set; }
public DateTime? ClosedAt { get; set; }
public DateTime UpdatedAt { get; set; } = DateTime.UtcNow;
}