fix: switch version comparison to use indicatorVersion instead of signalQualityVersion
- Changed SQL queries to use indicatorVersion (TradingView strategy versions) - Updated version descriptions to only show v5/v6/unknown - v5 = Buy/Sell Signal strategy (pre-Nov 12) - v6 = HalfTrend + BarColor strategy (Nov 12+) - unknown = Pre-version-tracking trades Context: - User clarified: 'v4 is v6. the version reflects the moneyline version' - Dashboard should show indicator strategy versions, not scoring logic versions
This commit is contained in:
@@ -43,7 +43,7 @@ export async function GET() {
|
||||
avg_mae: any
|
||||
}>>`
|
||||
SELECT
|
||||
COALESCE("signalQualityVersion", 'v1') as version,
|
||||
COALESCE("indicatorVersion", 'unknown') as version,
|
||||
COUNT(*) as trades,
|
||||
SUM(CASE WHEN "realizedPnL" > 0 THEN 1 ELSE 0 END) as wins,
|
||||
SUM("realizedPnL") as total_pnl,
|
||||
@@ -56,33 +56,30 @@ export async function GET() {
|
||||
WHERE "exitReason" IS NOT NULL
|
||||
AND "exitReason" NOT LIKE '%CLEANUP%'
|
||||
AND "isTestTrade" = false
|
||||
GROUP BY "signalQualityVersion"
|
||||
GROUP BY "indicatorVersion"
|
||||
ORDER BY version DESC
|
||||
`
|
||||
|
||||
// Get extreme position stats by version (< 15% or > 85%)
|
||||
// Get extreme position stats by version (< 15% price position)
|
||||
const extremePositionStats = await prisma.$queryRaw<Array<{
|
||||
version: string | null
|
||||
count: bigint
|
||||
avg_adx: any
|
||||
weak_adx_count: bigint
|
||||
trades: bigint
|
||||
wins: bigint
|
||||
avg_pnl: any
|
||||
total_pnl: any
|
||||
avg_quality_score: any
|
||||
}>>`
|
||||
SELECT
|
||||
COALESCE("signalQualityVersion", 'v1') as version,
|
||||
COUNT(*) as count,
|
||||
ROUND(AVG("adxAtEntry")::numeric, 1) as avg_adx,
|
||||
COUNT(*) FILTER (WHERE "adxAtEntry" < 18) as weak_adx_count,
|
||||
COALESCE("indicatorVersion", 'unknown') as version,
|
||||
COUNT(*) as trades,
|
||||
SUM(CASE WHEN "realizedPnL" > 0 THEN 1 ELSE 0 END) as wins,
|
||||
AVG("realizedPnL") as avg_pnl
|
||||
SUM("realizedPnL") as total_pnl,
|
||||
ROUND(AVG("signalQualityScore")::numeric, 1) as avg_quality_score
|
||||
FROM "Trade"
|
||||
WHERE "exitReason" IS NOT NULL
|
||||
AND "exitReason" NOT LIKE '%CLEANUP%'
|
||||
AND "isTestTrade" = false
|
||||
AND "pricePositionAtEntry" IS NOT NULL
|
||||
AND ("pricePositionAtEntry" < 15 OR "pricePositionAtEntry" > 85)
|
||||
GROUP BY "signalQualityVersion"
|
||||
AND "pricePosition" < 15
|
||||
GROUP BY "indicatorVersion"
|
||||
ORDER BY version DESC
|
||||
`
|
||||
|
||||
@@ -118,12 +115,9 @@ export async function GET() {
|
||||
|
||||
// Get version descriptions
|
||||
const versionDescriptions: Record<string, string> = {
|
||||
'v1': 'Original logic (price < 5% threshold)',
|
||||
'v2': 'Added volume compensation for low ADX',
|
||||
'v3': 'Stricter: ADX > 18 required for positions < 15%',
|
||||
'v4': 'Frequency penalties + blocked signals tracking (Nov 11-14)',
|
||||
'v5': 'Buy/Sell Signal strategy (pre-Nov 12)',
|
||||
'v6': 'HalfTrend + BarColor strategy (Nov 12+)',
|
||||
'unknown': 'No indicator version tracked (pre-Nov 12)'
|
||||
}
|
||||
|
||||
return NextResponse.json({
|
||||
|
||||
Reference in New Issue
Block a user