Files
trading_bot_v3/test-timeframe-intervals.js
mindesbunister 236e2b0d31 feat: Complete AI Learning Integration & Position Scaling DCA System
- Integrated SimplifiedStopLossLearner into automation
- Every AI decision now recorded for learning (stop loss, take profit, confidence)
- Trade outcomes tracked and compared to AI predictions
- Learning patterns improve future AI decisions
- Enhanced status dashboard with learning insights

- Proper DCA: increase position size + adjust existing SL/TP (not create new)
- AI-calculated optimal levels for scaled positions
- Prevents order fragmentation (fixes 24+ order problem)
- Unified risk management for entire scaled position

 TIMEFRAME-AWARE INTERVALS:
- Scalping (5m/15m): 5-15 minute analysis intervals
- Day Trading (1h/4h): 10-30 minute intervals
- Swing Trading (4h/1d): 23-68 minute intervals
- Perfect for 5-minute scalping with DCA protection

- 2-hour DCA cooldown prevents order spam
- Position existence checks before new trades
- Direction matching validation
- Learning-based decision improvements

- AI calculates ALL levels (entry, SL, TP, leverage, scaling)
- Every calculation recorded and learned from
- Position scaling uses AI intelligence
- Timeframe-appropriate analysis frequency
- Professional order management
- Continuous learning and improvement

 ADDRESSES ALL USER CONCERNS:
- 5-minute scalping compatibility 
- Position scaling DCA (adjust existing SL/TP) 
- AI calculations being learned from 
- No order fragmentation 
- Intelligent automation with learning 

Files: automation, consolidation APIs, learning integration, tests, documentation
2025-07-27 23:46:52 +02:00

81 lines
3.4 KiB
JavaScript

// Test the new timeframe-aware interval system
import { simpleAutomation } from './lib/simple-automation.js';
async function testTimeframeIntervals() {
try {
const automation = simpleAutomation;
console.log('=== Testing Timeframe-Aware Interval System ===\n');
// Test different timeframe scenarios
const testScenarios = [
{
description: "Scalping Configuration (5m, 15m)",
selectedTimeframes: ['5m', '15m'],
riskLevels: ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW', 'NONE']
},
{
description: "Day Trading Configuration (1h, 4h)",
selectedTimeframes: ['1h', '4h'],
riskLevels: ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW', 'NONE']
},
{
description: "Swing Trading Configuration (4h, 1d)",
selectedTimeframes: ['4h', '1d'],
riskLevels: ['CRITICAL', 'HIGH', 'MEDIUM', 'LOW', 'NONE']
},
{
description: "No Timeframes Selected (Default)",
selectedTimeframes: [],
riskLevels: ['MEDIUM']
}
];
for (const scenario of testScenarios) {
console.log(`📋 ${scenario.description}`);
console.log(` Timeframes: ${scenario.selectedTimeframes.join(', ') || 'default'}`);
// Mock the selected timeframes (in real app this comes from UI)
automation.selectedTimeframes = scenario.selectedTimeframes;
console.log(` Strategy: ${automation.detectStrategy()}`);
console.log(` Base Interval: ${automation.getTimeframeBasedIntervals() / (60 * 1000)} minutes`);
for (const riskLevel of scenario.riskLevels) {
const interval = automation.getNextInterval(riskLevel);
const minutes = Math.round(interval / (60 * 1000));
console.log(` ${riskLevel.padEnd(8)}: ${minutes} minutes`);
}
console.log('');
}
// Test specific scalping scenario user asked about
console.log('🎯 SPECIFIC TEST: 5-minute scalping compatibility');
automation.selectedTimeframes = ['5m', '15m'];
const scalping = automation.detectStrategy();
const baseInterval = automation.getTimeframeBasedIntervals();
const criticalInterval = automation.getNextInterval('CRITICAL');
const normalInterval = automation.getNextInterval('MEDIUM');
console.log(`Strategy Detected: ${scalping}`);
console.log(`Base Interval: ${baseInterval / (60 * 1000)} minutes`);
console.log(`Critical Risk: ${criticalInterval / (60 * 1000)} minutes (fastest for urgent situations)`);
console.log(`Normal Risk: ${normalInterval / (60 * 1000)} minutes (standard scalping frequency)`);
if (criticalInterval / (60 * 1000) <= 10 && normalInterval / (60 * 1000) <= 15) {
console.log('✅ SUCCESS: Fast enough for 5-minute scalping!');
} else {
console.log('❌ WARNING: Might be too slow for effective 5-minute scalping');
}
console.log('\n=== Test Complete ===');
} catch (error) {
console.error('❌ Test failed:', error.message);
console.error(error.stack);
}
}
// Run the test
testTimeframeIntervals();