feat: implement strategy-aware analysis intervals and remove manual leverage controls
- Remove manual leverage field from automation v2 page since AI now handles leverage automatically - Fix scalping strategy analysis intervals from 60 minutes to 2 minutes for proper high-frequency trading - Implement intelligent interval detection based on selected timeframes: * Scalping: 2 minutes (5m, 3m, or multiple short timeframes) * Day trading: 5 minutes (1h, 2h timeframes) * Swing trading: 15 minutes (4h, daily timeframes) - Fix Drift SDK API calls: replace getTotalPerpPositionValue() with getFreeCollateral() - Clean up UI by removing manual controls since AI systems handle optimization - Fix syntax errors in automation service and balance API - Ensure proper margin calculations using correct Drift Protocol methods Tested: Scalping strategy now correctly analyzes every 2 minutes instead of 60 minutes
This commit is contained in:
@@ -168,6 +168,35 @@ export class AutomationService {
|
||||
}
|
||||
|
||||
private getIntervalFromTimeframe(timeframe: string): number {
|
||||
// Check if this is a scalping strategy (multiple short timeframes)
|
||||
if (this.config?.selectedTimeframes) {
|
||||
const timeframes = this.config.selectedTimeframes
|
||||
const isScalping = timeframes.includes('5') || timeframes.includes('3') || (timeframes.length > 1 && timeframes.every(tf => ['1', '3', '5', '15', '30'].includes(tf)))
|
||||
if (isScalping) {
|
||||
console.log('🎯 Scalping strategy detected - using frequent analysis (2-3 minutes)')
|
||||
return 2 * 60 * 1000 // 2 minutes for scalping
|
||||
}
|
||||
|
||||
// Day trading strategy (short-medium timeframes)
|
||||
const isDayTrading = timeframes.includes('60') || timeframes.includes('120') ||
|
||||
timeframes.some(tf => ['30', '60', '120'].includes(tf))
|
||||
|
||||
if (isDayTrading) {
|
||||
console.log('⚡ Day trading strategy detected - using moderate analysis (5-10 minutes)')
|
||||
return 5 * 60 * 1000 // 5 minutes for day trading
|
||||
}
|
||||
|
||||
// Swing trading (longer timeframes)
|
||||
const isSwingTrading = timeframes.includes('240') || timeframes.includes('D') ||
|
||||
timeframes.some(tf => ['240', '480', 'D', '1d'].includes(tf))
|
||||
|
||||
if (isSwingTrading) {
|
||||
console.log('🎯 Swing trading strategy detected - using standard analysis (15-30 minutes)')
|
||||
return 15 * 60 * 1000 // 15 minutes for swing trading
|
||||
}
|
||||
}
|
||||
|
||||
// Fallback to timeframe-based intervals
|
||||
const intervals: { [key: string]: number } = {
|
||||
'1m': 60 * 1000,
|
||||
'3m': 3 * 60 * 1000,
|
||||
|
||||
Reference in New Issue
Block a user