- Call loadDynamicConfig() without dead supabaseService argument (Cosmos-backed). - Use getLegacySupabaseClient() for raw .from() queries in maintenance scripts. - manualOverrideCloseTrades: typed imports + legacy client for lifecycle SELECT. - verify_realtime: ESM .js imports and comment for subscribeToProfiles. - verifyTenantIsolation: comment for singleton monkey-patch. Made-with: Cursor
52 lines
1.7 KiB
TypeScript
52 lines
1.7 KiB
TypeScript
import { supabaseService } from '../src/services/SupabaseService.js';
|
|
import { getLegacySupabaseClient } from '../src/services/legacySupabaseClient.js';
|
|
import logger from '../src/utils/logger.js';
|
|
|
|
async function fixHighRiskRules() {
|
|
logger.info('🔧 Syncing High Risk Rules with Dashboard UI...');
|
|
|
|
const legacyClient = getLegacySupabaseClient();
|
|
if (!legacyClient) {
|
|
logger.error('❌ Legacy Supabase client not configured.');
|
|
return;
|
|
}
|
|
|
|
const profiles = await supabaseService.getActiveProfiles();
|
|
const highRiskProfile = profiles.find(p => p.name.includes('Scalp'));
|
|
|
|
if (!highRiskProfile) {
|
|
logger.error('❌ High Risk Profile not found.');
|
|
return;
|
|
}
|
|
|
|
// Update with Dashboard-compatible Rule IDs
|
|
const newRules = [
|
|
{ ruleId: 'MomentumRule', enabled: true }, // Aggressive Momentum (RSI)
|
|
{ ruleId: 'EntryTriggerRule', enabled: true }, // Pattern Trigger
|
|
{ ruleId: 'AIAnalysisRule', enabled: true } // AI Confirmation
|
|
];
|
|
|
|
// @ts-ignore
|
|
const { error } = await legacyClient
|
|
.from('trade_profiles')
|
|
.update({
|
|
strategy_config: {
|
|
...highRiskProfile.strategy_config,
|
|
rules: newRules
|
|
}
|
|
})
|
|
.eq('id', highRiskProfile.id);
|
|
|
|
if (error) {
|
|
logger.error(`❌ Failed: ${error.message}`);
|
|
} else {
|
|
logger.info(`✅ Rules Updated for [${highRiskProfile.name}]`);
|
|
logger.info(` - MomentumRule: ON`);
|
|
logger.info(` - EntryTriggerRule: ON`);
|
|
logger.info(` - AIAnalysisRule: ON`);
|
|
logger.info(` (Refresh Dashboard to see them selected)`);
|
|
}
|
|
}
|
|
|
|
fixHighRiskRules();
|