Update messaging

This commit is contained in:
2025-10-06 01:34:13 +07:00
parent dab4807334
commit 347c78afc7
8 changed files with 144 additions and 171 deletions

View File

@@ -65,7 +65,7 @@ public class SynthApiClient : ISynthApiClient, IDisposable
{
try
{
_logger.LogInformation("🔍 **Synth API** - Fetching leaderboard");
_logger.LogInformation("🔍 Synth API - Fetching leaderboard");
var response = await _httpClient.GetAsync("/leaderboard/latest");
@@ -79,7 +79,7 @@ public class SynthApiClient : ISynthApiClient, IDisposable
var jsonContent = await response.Content.ReadAsStringAsync();
var miners = JsonSerializer.Deserialize<List<MinerInfo>>(jsonContent, _jsonOptions);
_logger.LogInformation($"📊 **Synth API** - Retrieved {miners?.Count ?? 0} miners from leaderboard");
_logger.LogInformation($"📊 Synth API - Retrieved {miners?.Count ?? 0} miners from leaderboard");
return miners ?? new List<MinerInfo>();
}
@@ -118,7 +118,7 @@ public class SynthApiClient : ISynthApiClient, IDisposable
var url = $"/leaderboard/historical?start_time={startTimeStr}&end_time={endTimeStr}";
_logger.LogInformation($"🔍 **Synth API** - Fetching historical leaderboard from {startTime:yyyy-MM-dd HH:mm} to {endTime:yyyy-MM-dd HH:mm}");
_logger.LogInformation($"🔍 Synth API - Fetching historical leaderboard from {startTime:yyyy-MM-dd HH:mm} to {endTime:yyyy-MM-dd HH:mm}");
var response = await _httpClient.GetAsync(url);
@@ -132,7 +132,7 @@ public class SynthApiClient : ISynthApiClient, IDisposable
var jsonContent = await response.Content.ReadAsStringAsync();
var miners = JsonSerializer.Deserialize<List<MinerInfo>>(jsonContent, _jsonOptions);
_logger.LogInformation($"📊 **Synth API** - Retrieved {miners?.Count ?? 0} miners from historical leaderboard");
_logger.LogInformation($"📊 Synth API - Retrieved {miners?.Count ?? 0} miners from historical leaderboard");
return miners ?? new List<MinerInfo>();
}
@@ -193,7 +193,7 @@ public class SynthApiClient : ISynthApiClient, IDisposable
var url = $"/prediction/latest?{string.Join("&", queryParams)}";
_logger.LogInformation(
$"🔮 **Synth API** - Fetching predictions for {minerUids.Count} miners, asset: {asset}, time: {timeLength}s");
$"🔮 Synth API - Fetching predictions for {minerUids.Count} miners, asset: {asset}, time: {timeLength}s");
var response = await _httpClient.GetAsync(url);
@@ -209,7 +209,7 @@ public class SynthApiClient : ISynthApiClient, IDisposable
var totalPaths = predictions?.Sum(p => p.NumSimulations) ?? 0;
_logger.LogInformation(
$"📈 **Synth API** - Retrieved {predictions?.Count ?? 0} predictions with {totalPaths} total simulation paths");
$"📈 Synth API - Retrieved {predictions?.Count ?? 0} predictions with {totalPaths} total simulation paths");
return predictions ?? new List<MinerPrediction>();
}
@@ -275,7 +275,7 @@ public class SynthApiClient : ISynthApiClient, IDisposable
var url = $"/prediction/historical?{string.Join("&", queryParams)}";
_logger.LogInformation(
$"🔮 **Synth API** - Fetching historical predictions for {minerUids.Count} miners, asset: {asset}, time: {startTime:yyyy-MM-dd HH:mm}, duration: {timeLength}s");
$"🔮 Synth API - Fetching historical predictions for {minerUids.Count} miners, asset: {asset}, time: {startTime:yyyy-MM-dd HH:mm}, duration: {timeLength}s");
var response = await _httpClient.GetAsync(url);
@@ -291,7 +291,7 @@ public class SynthApiClient : ISynthApiClient, IDisposable
var totalPaths = predictions?.Sum(p => p.NumSimulations) ?? 0;
_logger.LogInformation(
$"📈 **Synth API** - Retrieved {predictions?.Count ?? 0} historical predictions with {totalPaths} total simulation paths");
$"📈 Synth API - Retrieved {predictions?.Count ?? 0} historical predictions with {totalPaths} total simulation paths");
return predictions ?? new List<MinerPrediction>();
}

View File

@@ -123,14 +123,14 @@ public class SynthPredictionService : ISynthPredictionService
await GetCachedPredictionsAsync(asset, timeHorizonSeconds, config, false, DateTime.UtcNow);
if (!predictions.Any())
{
_logger.LogWarning($"🚫 **Synth Probability** - No predictions available for {asset}");
_logger.LogWarning($"🚫 Synth Probability - No predictions available for {asset}");
return 0m;
}
var probability = CalculateProbabilityFromPaths(predictions, currentPrice, targetPrice, timeHorizonSeconds,
isLongPosition);
_logger.LogInformation($"🎯 **Synth Probability** - {asset}\n" +
_logger.LogInformation($"🎯 Synth Probability - {asset}\n" +
$"📊 Target: ${targetPrice:F2} | Current: ${currentPrice:F2}\n" +
$"⏱️ Horizon: {timeHorizonSeconds / 3600.0:F1}h | Position: {(isLongPosition ? "LONG" : "SHORT")}\n" +
$"🎲 Probability: {probability:P2}");
@@ -170,7 +170,7 @@ public class SynthPredictionService : ISynthPredictionService
await GetCachedPredictionsAsync(asset, timeHorizonSeconds, config, isBacktest, signalDate);
if (!predictions.Any())
{
_logger.LogWarning($"🚫 **Synth Multi-Threshold** - No predictions available for {asset}");
_logger.LogWarning($"🚫 Synth Multi-Threshold - No predictions available for {asset}");
return results;
}
@@ -181,7 +181,7 @@ public class SynthPredictionService : ISynthPredictionService
results[threshold.Key] = probability;
}
_logger.LogInformation($"🎯 **Synth Multi-Threshold** - {asset}\n" +
_logger.LogInformation($"🎯 Synth Multi-Threshold - {asset}\n" +
$"📊 Calculated {results.Count} threshold probabilities\n" +
$"⏱️ Horizon: {timeHorizonSeconds / 3600.0:F1}h | Position: {(isLongPosition ? "LONG" : "SHORT")} {(isBacktest ? "(HISTORICAL)" : "(LIVE)")}");
@@ -200,7 +200,7 @@ public class SynthPredictionService : ISynthPredictionService
public async Task ClearCacheAsync()
{
await _synthRepository.CleanupOldDataAsync(0); // Remove all data
_logger.LogInformation("🧹 **Synth Cache** - Cleared all cached individual predictions from MongoDB");
_logger.LogInformation("🧹 Synth Cache - Cleared all cached individual predictions from MongoDB");
}
/// <summary>
@@ -262,7 +262,7 @@ public class SynthPredictionService : ISynthPredictionService
isBacktest, signal.Date);
// Debug logging to understand LONG vs SHORT differences
_logger.LogInformation($"🔍 **Debug Signal Direction Analysis** - {signal.Direction} {signal.Ticker}\n" +
_logger.LogInformation($"🔍 Debug Signal Direction Analysis - {signal.Direction} {signal.Ticker}\n" +
$"💰 Current Price: ${currentPrice:F2}\n" +
$"📊 Price Targets Requested:\n" +
$" {string.Join("\n ", priceThresholds.Select(kvp => $"{kvp.Key}: ${kvp.Value:F2}"))}\n" +
@@ -355,7 +355,7 @@ public class SynthPredictionService : ISynthPredictionService
$"Confidence: {finalConfidence}, Risk: {result.GetUtilityRiskAssessment()}";
_logger.LogInformation(
$"🎯 **Synth Signal Analysis** - {signal.Direction} {signal.Ticker} {(isBacktest ? "(BACKTEST)" : "(LIVE)")}\n" +
$"🎯 Synth Signal Analysis - {signal.Direction} {signal.Ticker} {(isBacktest ? "(BACKTEST)" : "(LIVE)")}\n" +
$"📊 Signal: `{signal.Identifier}`\n" +
$"📊 SL Risk: {slProbability:P2} | TP Probability: {tpProbability:P2}\n" +
$"🎲 Ratio: {tpSlRatio:F2}x (TP/SL) | Win/Loss: {result.WinLossRatio:F2}:1\n" +
@@ -412,7 +412,7 @@ public class SynthPredictionService : ISynthPredictionService
Math.Min(constrainedScore * 0.75m, configLowThreshold + 0.05m); // Small buffer above LOW threshold
_logger.LogDebug(
$"🚨 **Conditional Pass-Through** - Signal exceeded {result.AdverseProbabilityThreshold:P1} threshold " +
$"🚨 Conditional Pass-Through - Signal exceeded {result.AdverseProbabilityThreshold:P1} threshold " +
$"(SL: {result.StopLossProbability:P2}) but has redeeming qualities. " +
$"Constrained score: {constrainedScore:F4} → Penalized: {penalizedScore:F4} → LOW confidence");
@@ -442,7 +442,7 @@ public class SynthPredictionService : ISynthPredictionService
};
// Debug logging to understand scoring breakdown
_logger.LogDebug($"🧮 **Config-Aware Confidence** [{riskConfig.RiskTolerance}] - " +
_logger.LogDebug($"🧮 Config-Aware Confidence [{riskConfig.RiskTolerance}] - " +
$"Composite: {compositeScore:F4} = " +
$"Config({configScore:F4})*0.5 + " +
$"Threshold({thresholdAlignmentScore:F4})*0.3 + " +
@@ -527,7 +527,7 @@ public class SynthPredictionService : ISynthPredictionService
var redeemingPercentage = (decimal)redeemingFactors / totalFactors;
_logger.LogDebug(
$"🔍 **Redeeming Qualities Check** - {redeemingFactors}/{totalFactors} factors positive ({redeemingPercentage:P0}). " +
$"🔍 Redeeming Qualities Check - {redeemingFactors}/{totalFactors} factors positive ({redeemingPercentage:P0}). " +
$"Kelly: {result.KellyFraction:P2} (>2x{riskConfig.KellyMinimumThreshold:P2}), " +
$"EMV: ${result.ExpectedMonetaryValue:F2} (>$100), " +
$"TP/SL: {result.TpSlRatio:F2}x (>2.0), " +
@@ -842,7 +842,7 @@ public class SynthPredictionService : ISynthPredictionService
if (liquidationProbability > config.MaxLiquidationProbability)
{
_logger.LogWarning(
$"🚫 **Synth Risk Block**\n" +
$"🚫 Synth Risk Block\n" +
$"Liquidation probability too high: {liquidationProbability:P2}\n" +
$"📊 Max allowed: {config.MaxLiquidationProbability:P2}\n" +
$"💰 Est. liquidation: ${estimatedLiquidationPrice:F2}\n" +
@@ -851,7 +851,7 @@ public class SynthPredictionService : ISynthPredictionService
}
_logger.LogInformation(
$"✅ **Synth Risk Check**\n" +
$"✅ Synth Risk Check\n" +
$"Liquidation probability acceptable: {liquidationProbability:P2}\n" +
$"📊 Max allowed: {config.MaxLiquidationProbability:P2}");
@@ -893,7 +893,7 @@ public class SynthPredictionService : ISynthPredictionService
{
result.ShouldWarn = true;
result.WarningMessage =
$"⚠️ **High Liquidation Risk**\n" +
$"⚠️ High Liquidation Risk\n" +
$"Position: `{positionIdentifier}`\n" +
$"🎲 Liquidation probability: {liquidationProbability:P2}\n" +
$"💰 Stop loss: ${liquidationPrice:F2}\n" +
@@ -906,7 +906,7 @@ public class SynthPredictionService : ISynthPredictionService
{
result.ShouldAutoClose = true;
result.EmergencyMessage =
$"🚨 **Emergency Close**\n" +
$"🚨 Emergency Close\n" +
$"Extremely high liquidation risk: {liquidationProbability:P2}\n" +
$"Auto-closing position for protection";
}
@@ -974,7 +974,7 @@ public class SynthPredictionService : ISynthPredictionService
if (cachedLeaderboard != null)
{
leaderboard = cachedLeaderboard.Miners;
_logger.LogDebug($"📦 **Synth Cache** - Using cached leaderboard for {asset}");
_logger.LogDebug($"📦 Synth Cache - Using cached leaderboard for {asset}");
}
else
{
@@ -1036,7 +1036,7 @@ public class SynthPredictionService : ISynthPredictionService
if (cachedIndividualPredictions.Count == topMinerUids.Count)
{
_logger.LogDebug(
$"📦 **Synth Individual Cache** - Using all cached individual predictions for {asset} {(isBacktest ? "HISTORICAL" : "LIVE")}");
$"📦 Synth Individual Cache - Using all cached individual predictions for {asset} {(isBacktest ? "HISTORICAL" : "LIVE")}");
return cachedIndividualPredictions.Select(p => p.Prediction).ToList();
}
@@ -1046,7 +1046,7 @@ public class SynthPredictionService : ISynthPredictionService
var missingMinerUids = topMinerUids.Where(uid => !cachedMinerUids.Contains(uid)).ToList();
_logger.LogInformation(
$"🔄 **Synth Individual Cache** - Partial cache hit for {asset}: {cachedIndividualPredictions.Count}/{topMinerUids.Count} cached, fetching {missingMinerUids.Count} fresh predictions {(isBacktest ? "HISTORICAL" : "LIVE")}");
$"🔄 Synth Individual Cache - Partial cache hit for {asset}: {cachedIndividualPredictions.Count}/{topMinerUids.Count} cached, fetching {missingMinerUids.Count} fresh predictions {(isBacktest ? "HISTORICAL" : "LIVE")}");
// Fetch missing predictions from API
List<MinerPrediction> freshPredictions;
@@ -1112,7 +1112,7 @@ public class SynthPredictionService : ISynthPredictionService
}
_logger.LogInformation(
$"📈 **Synth Individual Cache** - Total predictions assembled: {allPredictions.Count} for {asset} {(isBacktest ? "HISTORICAL" : "LIVE")}");
$"📈 Synth Individual Cache - Total predictions assembled: {allPredictions.Count} for {asset} {(isBacktest ? "HISTORICAL" : "LIVE")}");
return allPredictions;
}
@@ -1186,7 +1186,7 @@ public class SynthPredictionService : ISynthPredictionService
var probability = totalPaths > 0 ? (decimal)pathsCrossingThreshold / totalPaths : 0m;
_logger.LogDebug(
$"🧮 **Probability Calculation** - {pathsCrossingThreshold}/{totalPaths} paths crossed threshold = {probability:P2}");
$"🧮 Probability Calculation - {pathsCrossingThreshold}/{totalPaths} paths crossed threshold = {probability:P2}");
return probability;
}