- 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
58 lines
1.8 KiB
JavaScript
58 lines
1.8 KiB
JavaScript
/**
|
||
* Execute Position Consolidation
|
||
* Converts 24+ fragmented orders into clean 3-order structure
|
||
*/
|
||
|
||
async function executeConsolidation() {
|
||
console.log('🧹 EXECUTING POSITION CONSOLIDATION');
|
||
console.log('==================================================');
|
||
|
||
const baseUrl = process.env.INTERNAL_API_URL || 'http://localhost:3000';
|
||
|
||
try {
|
||
// Step 1: Analyze current position
|
||
console.log('1️⃣ Analyzing current position...');
|
||
const response = await fetch(`${baseUrl}/api/drift/consolidate-position`, {
|
||
method: 'POST',
|
||
headers: { 'Content-Type': 'application/json' },
|
||
body: JSON.stringify({ dryRun: false })
|
||
});
|
||
|
||
const result = await response.json();
|
||
|
||
if (result.success) {
|
||
console.log('✅ CONSOLIDATION SUCCESSFUL!');
|
||
console.log('📊 Summary:');
|
||
console.log(` Orders before: ${result.ordersBefore}`);
|
||
console.log(` Orders after: ${result.ordersAfter}`);
|
||
console.log(` Reduction: ${result.ordersBefore} → ${result.ordersAfter} orders`);
|
||
|
||
if (result.newOrders) {
|
||
console.log('🆕 New clean orders:');
|
||
result.newOrders.forEach((order, index) => {
|
||
console.log(` ${index + 1}. ${order.orderType} at $${order.price} for ${order.size} SOL`);
|
||
});
|
||
}
|
||
} else {
|
||
console.log('❌ CONSOLIDATION FAILED:');
|
||
console.log(` Error: ${result.error}`);
|
||
if (result.details) {
|
||
console.log(` Details: ${JSON.stringify(result.details, null, 2)}`);
|
||
}
|
||
}
|
||
|
||
} catch (error) {
|
||
console.log('💥 EXECUTION ERROR:');
|
||
console.log(` ${error.message}`);
|
||
}
|
||
|
||
console.log('==================================================');
|
||
}
|
||
|
||
// Execute if run directly
|
||
if (require.main === module) {
|
||
executeConsolidation();
|
||
}
|
||
|
||
module.exports = { executeConsolidation };
|