Add net Pnl in db
This commit is contained in:
1445
src/Managing.Infrastructure.Database/Migrations/20250928144516_AddNetPnLToAgentSummary.Designer.cs
generated
Normal file
1445
src/Managing.Infrastructure.Database/Migrations/20250928144516_AddNetPnLToAgentSummary.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,29 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Managing.Infrastructure.Databases.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddNetPnLToAgentSummary : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<decimal>(
|
||||
name: "NetPnL",
|
||||
table: "AgentSummaries",
|
||||
type: "numeric",
|
||||
nullable: false,
|
||||
defaultValue: 0m);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "NetPnL",
|
||||
table: "AgentSummaries");
|
||||
}
|
||||
}
|
||||
}
|
||||
1449
src/Managing.Infrastructure.Database/Migrations/20250928145325_AddNetPnLToBot.Designer.cs
generated
Normal file
1449
src/Managing.Infrastructure.Database/Migrations/20250928145325_AddNetPnLToBot.Designer.cs
generated
Normal file
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,31 @@
|
||||
using Microsoft.EntityFrameworkCore.Migrations;
|
||||
|
||||
#nullable disable
|
||||
|
||||
namespace Managing.Infrastructure.Databases.Migrations
|
||||
{
|
||||
/// <inheritdoc />
|
||||
public partial class AddNetPnLToBot : Migration
|
||||
{
|
||||
/// <inheritdoc />
|
||||
protected override void Up(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.AddColumn<decimal>(
|
||||
name: "NetPnL",
|
||||
table: "Bots",
|
||||
type: "numeric(18,8)",
|
||||
precision: 18,
|
||||
scale: 8,
|
||||
nullable: false,
|
||||
defaultValue: 0m);
|
||||
}
|
||||
|
||||
/// <inheritdoc />
|
||||
protected override void Down(MigrationBuilder migrationBuilder)
|
||||
{
|
||||
migrationBuilder.DropColumn(
|
||||
name: "NetPnL",
|
||||
table: "Bots");
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -92,6 +92,9 @@ namespace Managing.Infrastructure.Databases.Migrations
|
||||
b.Property<int>("Losses")
|
||||
.HasColumnType("integer");
|
||||
|
||||
b.Property<decimal>("NetPnL")
|
||||
.HasColumnType("numeric");
|
||||
|
||||
b.Property<DateTime?>("Runtime")
|
||||
.HasColumnType("timestamp with time zone");
|
||||
|
||||
@@ -250,6 +253,10 @@ namespace Managing.Infrastructure.Databases.Migrations
|
||||
.HasMaxLength(255)
|
||||
.HasColumnType("character varying(255)");
|
||||
|
||||
b.Property<decimal>("NetPnL")
|
||||
.HasPrecision(18, 8)
|
||||
.HasColumnType("numeric(18,8)");
|
||||
|
||||
b.Property<decimal>("Pnl")
|
||||
.HasPrecision(18, 8)
|
||||
.HasColumnType("numeric(18,8)");
|
||||
|
||||
@@ -189,9 +189,9 @@ public class AgentSummaryRepository : IAgentSummaryRepository
|
||||
var isDescending = sortOrder.ToLowerInvariant() == "desc";
|
||||
query = sortBy switch
|
||||
{
|
||||
SortableFields.TotalPnL => isDescending
|
||||
? query.OrderByDescending(a => a.TotalPnL)
|
||||
: query.OrderBy(a => a.TotalPnL),
|
||||
SortableFields.NetPnL => isDescending
|
||||
? query.OrderByDescending(a => a.NetPnL)
|
||||
: query.OrderBy(a => a.NetPnL),
|
||||
SortableFields.TotalROI => isDescending
|
||||
? query.OrderByDescending(a => a.TotalROI)
|
||||
: query.OrderBy(a => a.TotalROI),
|
||||
@@ -241,6 +241,7 @@ public class AgentSummaryRepository : IAgentSummaryRepository
|
||||
UserId = domain.UserId,
|
||||
AgentName = domain.AgentName,
|
||||
TotalPnL = domain.TotalPnL,
|
||||
NetPnL = domain.NetPnL,
|
||||
TotalROI = domain.TotalROI,
|
||||
Wins = domain.Wins,
|
||||
Losses = domain.Losses,
|
||||
@@ -259,6 +260,7 @@ public class AgentSummaryRepository : IAgentSummaryRepository
|
||||
entity.UserId = domain.UserId;
|
||||
entity.AgentName = domain.AgentName;
|
||||
entity.TotalPnL = domain.TotalPnL;
|
||||
entity.NetPnL = domain.NetPnL;
|
||||
entity.TotalROI = domain.TotalROI;
|
||||
entity.Wins = domain.Wins;
|
||||
entity.Losses = domain.Losses;
|
||||
@@ -277,6 +279,7 @@ public class AgentSummaryRepository : IAgentSummaryRepository
|
||||
UserId = entity.UserId,
|
||||
AgentName = entity.AgentName,
|
||||
TotalPnL = entity.TotalPnL,
|
||||
NetPnL = entity.NetPnL,
|
||||
TotalROI = entity.TotalROI,
|
||||
Wins = entity.Wins,
|
||||
Losses = entity.Losses,
|
||||
|
||||
@@ -16,6 +16,7 @@ public class AgentSummaryEntity
|
||||
public decimal TotalVolume { get; set; }
|
||||
public decimal TotalBalance { get; set; }
|
||||
public decimal TotalFees { get; set; }
|
||||
public decimal NetPnL { get; set; }
|
||||
|
||||
// Navigation property
|
||||
public UserEntity User { get; set; }
|
||||
|
||||
@@ -24,6 +24,7 @@ public class BotEntity
|
||||
public int TradeWins { get; set; }
|
||||
public int TradeLosses { get; set; }
|
||||
public decimal Pnl { get; set; }
|
||||
public decimal NetPnL { get; set; }
|
||||
public decimal Roi { get; set; }
|
||||
public decimal Volume { get; set; }
|
||||
public decimal Fees { get; set; }
|
||||
|
||||
@@ -447,6 +447,7 @@ public class ManagingDbContext : DbContext
|
||||
entity.Property(e => e.TradeWins).IsRequired();
|
||||
entity.Property(e => e.TradeLosses).IsRequired();
|
||||
entity.Property(e => e.Pnl).HasPrecision(18, 8);
|
||||
entity.Property(e => e.NetPnL).HasPrecision(18, 8);
|
||||
entity.Property(e => e.Roi).HasPrecision(18, 8);
|
||||
entity.Property(e => e.Volume).HasPrecision(18, 8);
|
||||
entity.Property(e => e.Fees).HasPrecision(18, 8);
|
||||
|
||||
@@ -69,6 +69,7 @@ public class PostgreSqlBotRepository : IBotRepository
|
||||
existingEntity.TradeWins = bot.TradeWins;
|
||||
existingEntity.TradeLosses = bot.TradeLosses;
|
||||
existingEntity.Pnl = bot.Pnl;
|
||||
existingEntity.NetPnL = bot.NetPnL;
|
||||
existingEntity.Roi = bot.Roi;
|
||||
existingEntity.Volume = bot.Volume;
|
||||
existingEntity.Fees = bot.Fees;
|
||||
|
||||
@@ -694,6 +694,7 @@ public static class PostgreSqlMappers
|
||||
TradeWins = entity.TradeWins,
|
||||
TradeLosses = entity.TradeLosses,
|
||||
Pnl = entity.Pnl,
|
||||
NetPnL = entity.NetPnL,
|
||||
Roi = entity.Roi,
|
||||
Volume = entity.Volume,
|
||||
Fees = entity.Fees,
|
||||
@@ -720,6 +721,7 @@ public static class PostgreSqlMappers
|
||||
TradeWins = bot.TradeWins,
|
||||
TradeLosses = bot.TradeLosses,
|
||||
Pnl = bot.Pnl,
|
||||
NetPnL = bot.NetPnL,
|
||||
Roi = bot.Roi,
|
||||
Volume = bot.Volume,
|
||||
Fees = bot.Fees,
|
||||
|
||||
Reference in New Issue
Block a user