feat(Trades): refactor trades MQTT client and DTOs
This commit is contained in:
@@ -0,0 +1,146 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.ComponentModel.DataAnnotations;
|
||||
using System.ComponentModel.DataAnnotations.Schema;
|
||||
using FinlyticCore.Models.Analyzer;
|
||||
using FinlyticCore.Models.Trades;
|
||||
|
||||
namespace FinlyticTrades.Entities;
|
||||
|
||||
[Table("trades")]
|
||||
public class TradeEntity
|
||||
{
|
||||
[Key]
|
||||
public Guid Id { get; set; } = Guid.NewGuid();
|
||||
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string TradeId { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string AnalysisId { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[MaxLength(100)]
|
||||
public string EventId { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[MaxLength(50)]
|
||||
public string Sector { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[MaxLength(30)]
|
||||
public string Symbol { get; set; } = string.Empty;
|
||||
|
||||
[Required]
|
||||
[MaxLength(30)]
|
||||
public string Isin { get; set; } = string.Empty;
|
||||
|
||||
[MaxLength(150)]
|
||||
public string CompanyName { get; set; } = string.Empty;
|
||||
|
||||
public TradeStatus Status { get; set; } = TradeStatus.Proposed;
|
||||
|
||||
[MaxLength(100)]
|
||||
public string? UserId { get; set; }
|
||||
|
||||
public bool IsGlobalProposal { get; set; } = true;
|
||||
|
||||
[Column(TypeName = "decimal(18,4)")]
|
||||
public decimal EntryPrice { get; set; }
|
||||
|
||||
[Column(TypeName = "decimal(18,4)")]
|
||||
public decimal StopLoss { get; set; }
|
||||
|
||||
[Column(TypeName = "decimal(18,4)")]
|
||||
public decimal TakeProfit { get; set; }
|
||||
|
||||
[MaxLength(10)]
|
||||
public string SignalType { get; set; } = "BUY";
|
||||
|
||||
[MaxLength(30)]
|
||||
public string RiskTolerance { get; set; } = "Moderate";
|
||||
|
||||
[MaxLength(20)]
|
||||
public string Timeframe { get; set; } = "1D";
|
||||
|
||||
[MaxLength(30)]
|
||||
public string InstrumentType { get; set; } = "Stock";
|
||||
|
||||
public double WinRate { get; set; }
|
||||
public VixMarketRegime VixRegime { get; set; }
|
||||
|
||||
[Column(TypeName = "decimal(18,4)")]
|
||||
public decimal VixValue { get; set; }
|
||||
|
||||
public int TtlMinutes { get; set; } = 60;
|
||||
public string Reasoning { get; set; } = string.Empty;
|
||||
|
||||
// --- New Fields for Detailed Execution & Rationale ---
|
||||
[Column(TypeName = "decimal(18,4)")]
|
||||
public decimal? EntryZoneMin { get; set; }
|
||||
|
||||
[Column(TypeName = "decimal(18,4)")]
|
||||
public decimal? EntryZoneMax { get; set; }
|
||||
|
||||
public string? TakeProfitTargets { get; set; } // Stored as comma separated values
|
||||
|
||||
[Column(TypeName = "decimal(18,4)")]
|
||||
public decimal? RiskRewardRatio { get; set; }
|
||||
|
||||
[Column(TypeName = "decimal(18,4)")]
|
||||
public decimal? MaxLeverage { get; set; }
|
||||
|
||||
public string TechnicalRationale { get; set; } = string.Empty;
|
||||
public string FundamentalRationale { get; set; } = string.Empty;
|
||||
public string RiskWarning { get; set; } = string.Empty;
|
||||
|
||||
// --- User Exit Data ---
|
||||
[Column(TypeName = "decimal(18,4)")]
|
||||
public decimal? UserExitPrice { get; set; }
|
||||
|
||||
public DateTime? UserExitTimestamp { get; set; }
|
||||
|
||||
// --- Real Trade Execution Data ---
|
||||
[Column(TypeName = "decimal(18,4)")]
|
||||
public decimal? ActualEntryPrice { get; set; }
|
||||
|
||||
[Column(TypeName = "decimal(18,4)")]
|
||||
public decimal? PositionSize { get; set; }
|
||||
|
||||
[Column(TypeName = "decimal(18,4)")]
|
||||
public decimal? LeverageUsed { get; set; }
|
||||
|
||||
[Column(TypeName = "decimal(18,4)")]
|
||||
public decimal? EntryFee { get; set; }
|
||||
|
||||
[Column(TypeName = "decimal(18,4)")]
|
||||
public decimal? ExitFee { get; set; }
|
||||
|
||||
public DateTime? ExecutionTimestamp { get; set; }
|
||||
|
||||
[Column(TypeName = "decimal(18,4)")]
|
||||
public decimal? Quantity { get; set; }
|
||||
|
||||
[Column(TypeName = "decimal(18,4)")]
|
||||
public decimal? KnockoutThreshold { get; set; }
|
||||
|
||||
public bool IsRecurring { get; set; } = false;
|
||||
|
||||
[MaxLength(50)]
|
||||
public string? CloseReason { get; set; }
|
||||
|
||||
[Column(TypeName = "decimal(18,4)")]
|
||||
public decimal? PnlAbsolute { get; set; }
|
||||
|
||||
[Column(TypeName = "decimal(18,4)")]
|
||||
public decimal? PnlPercent { get; set; }
|
||||
|
||||
public bool? IsWin { get; set; }
|
||||
|
||||
public DateTime CreatedAt { get; set; } = DateTime.UtcNow;
|
||||
public DateTime? ClosedAt { get; set; }
|
||||
|
||||
public List<TradeHourlyUpdateEntity> HourlyUpdates { get; set; } = new();
|
||||
}
|
||||
Reference in New Issue
Block a user