Big refactoring
This commit is contained in:
46
frontend/src/lib/recommendation.ts
Normal file
46
frontend/src/lib/recommendation.ts
Normal file
@@ -0,0 +1,46 @@
|
||||
import type { TradeSetup } from './types';
|
||||
|
||||
export type RecommendationAction = NonNullable<TradeSetup['recommended_action']>;
|
||||
|
||||
export const RECOMMENDATION_ACTION_LABELS: Record<RecommendationAction, string> = {
|
||||
LONG_HIGH: 'LONG (High Confidence)',
|
||||
LONG_MODERATE: 'LONG (Moderate Confidence)',
|
||||
SHORT_HIGH: 'SHORT (High Confidence)',
|
||||
SHORT_MODERATE: 'SHORT (Moderate Confidence)',
|
||||
NEUTRAL: 'NEUTRAL (Conflicting Signals)',
|
||||
};
|
||||
|
||||
export const RECOMMENDATION_ACTION_GLOSSARY: Array<{ action: RecommendationAction; description: string }> = [
|
||||
{
|
||||
action: 'LONG_HIGH',
|
||||
description: 'Ticker bias favors LONG strongly. LONG confidence is above the high threshold and clearly above SHORT.',
|
||||
},
|
||||
{
|
||||
action: 'LONG_MODERATE',
|
||||
description: 'Ticker bias favors LONG, but with moderate conviction.',
|
||||
},
|
||||
{
|
||||
action: 'SHORT_HIGH',
|
||||
description: 'Ticker bias favors SHORT strongly. SHORT confidence is above the high threshold and clearly above LONG.',
|
||||
},
|
||||
{
|
||||
action: 'SHORT_MODERATE',
|
||||
description: 'Ticker bias favors SHORT, but with moderate conviction.',
|
||||
},
|
||||
{
|
||||
action: 'NEUTRAL',
|
||||
description: 'No strong directional edge. Signals are mixed or confidence gap is too small.',
|
||||
},
|
||||
];
|
||||
|
||||
export function recommendationActionLabel(action: TradeSetup['recommended_action']): string {
|
||||
if (!action) return RECOMMENDATION_ACTION_LABELS.NEUTRAL;
|
||||
return RECOMMENDATION_ACTION_LABELS[action] ?? RECOMMENDATION_ACTION_LABELS.NEUTRAL;
|
||||
}
|
||||
|
||||
export function recommendationActionDirection(action: TradeSetup['recommended_action']): 'long' | 'short' | 'neutral' {
|
||||
if (!action || action === 'NEUTRAL') return 'neutral';
|
||||
if (action.startsWith('LONG')) return 'long';
|
||||
if (action.startsWith('SHORT')) return 'short';
|
||||
return 'neutral';
|
||||
}
|
||||
Reference in New Issue
Block a user