Add scoreMessage
This commit is contained in:
@@ -192,7 +192,8 @@ public class BacktestController : BaseController
|
||||
MaxDrawdown = b.MaxDrawdown,
|
||||
Fees = b.Fees,
|
||||
SharpeRatio = b.SharpeRatio,
|
||||
Score = b.Score
|
||||
Score = b.Score,
|
||||
ScoreMessage = b.ScoreMessage
|
||||
}),
|
||||
TotalCount = totalCount,
|
||||
CurrentPage = page,
|
||||
@@ -256,7 +257,8 @@ public class BacktestController : BaseController
|
||||
MaxDrawdown = b.MaxDrawdown,
|
||||
Fees = b.Fees,
|
||||
SharpeRatio = b.SharpeRatio,
|
||||
Score = b.Score
|
||||
Score = b.Score,
|
||||
ScoreMessage = b.ScoreMessage
|
||||
}),
|
||||
TotalCount = totalCount,
|
||||
CurrentPage = page,
|
||||
|
||||
@@ -10,8 +10,8 @@ public class CryptoHelpersTests
|
||||
public void EncryptAesGcm_And_DecryptAesGcm_RoundTrip_Works()
|
||||
{
|
||||
// Arrange
|
||||
var secretKey = "supersecretkey1234567890123456"; // 32 bytes
|
||||
var token = "0x1234567890abcdef-johndoe";
|
||||
var secretKey = "KaigenXCowchain"; // 32 bytes
|
||||
var token = "0xC6327E7191726EDBcaA7f8b7FBec147dc2A5d830-NotOsasa";
|
||||
|
||||
// Act
|
||||
var encrypted = CryptoHelpers.EncryptAesGcm(token, secretKey);
|
||||
|
||||
@@ -335,7 +335,7 @@ namespace Managing.Application.Backtesting
|
||||
? AggregateValues(indicatorsValues, bot.IndicatorsValues)
|
||||
: new Dictionary<IndicatorType, IndicatorsResultBase>(),
|
||||
Score = scoringResult.Score,
|
||||
ScoreMessage = scoringResult.SummaryMessage,
|
||||
ScoreMessage = scoringResult.GenerateSummaryMessage(),
|
||||
Id = Guid.NewGuid().ToString(),
|
||||
RequestId = requestId,
|
||||
Metadata = metadata,
|
||||
|
||||
@@ -258,6 +258,7 @@ public class MessengerService : IMessengerService
|
||||
$"{(config.MaxPositionTimeHours.HasValue && config.MaxPositionTimeHours.Value > 0 ? $"⏰ Max Position Time (hrs): {config.MaxPositionTimeHours.Value} | " : "")}🏁 Close Early When Profitable: {(config.CloseEarlyWhenProfitable ? "Yes" : "No")}\n" +
|
||||
$"\n📈 Performance Metrics:\n" +
|
||||
$"⭐ Score: {score:F1}/100\n" +
|
||||
$"🔍 Score Analysis: {backtest.ScoreMessage}\n" +
|
||||
$"🏆 Win Rate: {winRate:F1}%\n" +
|
||||
$"📊 Total Trades: {tradeCount}\n" +
|
||||
$"💰 Final PnL: ${finalPnl:F2}\n" +
|
||||
|
||||
@@ -54,22 +54,23 @@ public class BacktestScoringResult
|
||||
|
||||
public string GenerateSummaryMessage()
|
||||
{
|
||||
if (Score == 0)
|
||||
{
|
||||
var earlyExit = Checks.FirstOrDefault(c => c.IsEarlyExit);
|
||||
if (earlyExit != null)
|
||||
{
|
||||
return $"Score: 0 - {earlyExit.Message}";
|
||||
}
|
||||
}
|
||||
|
||||
var passedChecks = Checks.Where(c => c.Passed && !c.IsEarlyExit && !c.IsPenalty).ToList();
|
||||
var failedChecks = Checks.Where(c => !c.Passed && !c.IsEarlyExit && !c.IsPenalty).ToList();
|
||||
var penalties = Checks.Where(c => c.IsPenalty).ToList();
|
||||
var earlyExits = Checks.Where(c => c.IsEarlyExit).ToList();
|
||||
|
||||
var summary = new StringBuilder();
|
||||
summary.AppendLine($"Final Score: {Score:F1}/100");
|
||||
|
||||
if (earlyExits.Any())
|
||||
{
|
||||
summary.AppendLine($"🚫 Early Exit Reasons ({earlyExits.Count}):");
|
||||
foreach (var earlyExit in earlyExits)
|
||||
{
|
||||
summary.AppendLine($" • {earlyExit.Component}: {earlyExit.Message}");
|
||||
}
|
||||
}
|
||||
|
||||
if (passedChecks.Any())
|
||||
{
|
||||
summary.AppendLine($"✅ Passed Checks ({passedChecks.Count}):");
|
||||
|
||||
@@ -104,6 +104,7 @@ public class BacktestRepository : IBacktestRepository
|
||||
.Include(b => b.StartDate)
|
||||
.Include(b => b.EndDate)
|
||||
.Include(b => b.Score)
|
||||
.Include(b => b.ScoreMessage)
|
||||
.Include(b => b.Config)
|
||||
.Include(b => b.Fees)
|
||||
.Include(b => b.Statistics);
|
||||
@@ -232,6 +233,7 @@ public class BacktestRepository : IBacktestRepository
|
||||
.Include(b => b.StartDate)
|
||||
.Include(b => b.EndDate)
|
||||
.Include(b => b.Score)
|
||||
.Include(b => b.ScoreMessage)
|
||||
.Include(b => b.Config)
|
||||
.Include(b => b.Fees)
|
||||
.Include(b => b.Statistics);
|
||||
|
||||
@@ -267,16 +267,36 @@ const BacktestTable: React.FC<BacktestTableProps> = ({list, isFetching, onSortCh
|
||||
{
|
||||
Header: 'Score',
|
||||
accessor: 'score',
|
||||
Cell: ({cell}: any) => (
|
||||
<span style={{
|
||||
color: getScoreColor(cell.row.values.score),
|
||||
fontWeight: 500,
|
||||
display: 'inline-block',
|
||||
width: '60px'
|
||||
}}>
|
||||
{cell.row.values.score.toFixed(2)}
|
||||
</span>
|
||||
),
|
||||
Cell: ({cell}: any) => {
|
||||
const backtest = cell.row.original as LightBacktestResponse;
|
||||
const scoreMessage = backtest.scoreMessage || 'No scoring details available';
|
||||
|
||||
return (
|
||||
<div className="dropdown dropdown-right bg-base-200">
|
||||
<div
|
||||
tabIndex={0}
|
||||
role="button"
|
||||
className="cursor-help"
|
||||
style={{
|
||||
color: getScoreColor(cell.row.values.score),
|
||||
fontWeight: 500,
|
||||
display: 'inline-block',
|
||||
width: '60px'
|
||||
}}
|
||||
>
|
||||
{cell.row.values.score.toFixed(2)}
|
||||
</div>
|
||||
<div
|
||||
tabIndex={0}
|
||||
className="dropdown-content z-[1] menu p-2 shadow bg-base-100 rounded-box w-96 max-h-64 overflow-y-auto"
|
||||
>
|
||||
<div className="text-sm whitespace-pre-wrap">
|
||||
{scoreMessage}
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
);
|
||||
},
|
||||
disableFilters: true,
|
||||
disableSortBy: false,
|
||||
sortType: 'basic',
|
||||
|
||||
@@ -3432,6 +3432,7 @@ export interface Backtest {
|
||||
score: number;
|
||||
requestId?: string;
|
||||
metadata?: any | null;
|
||||
scoreMessage?: string;
|
||||
}
|
||||
|
||||
export interface TradingBotConfig {
|
||||
@@ -3816,6 +3817,7 @@ export interface LightBacktestResponse {
|
||||
fees?: number;
|
||||
sharpeRatio?: number | null;
|
||||
score?: number;
|
||||
scoreMessage?: string | null;
|
||||
}
|
||||
|
||||
export interface RunBacktestRequest {
|
||||
|
||||
@@ -238,6 +238,7 @@ export interface Backtest {
|
||||
score: number;
|
||||
requestId?: string;
|
||||
metadata?: any | null;
|
||||
scoreMessage?: string;
|
||||
}
|
||||
|
||||
export interface TradingBotConfig {
|
||||
@@ -622,6 +623,7 @@ export interface LightBacktestResponse {
|
||||
fees?: number;
|
||||
sharpeRatio?: number | null;
|
||||
score?: number;
|
||||
scoreMessage?: string | null;
|
||||
}
|
||||
|
||||
export interface RunBacktestRequest {
|
||||
|
||||
Reference in New Issue
Block a user