Files
trading_bot_v3/test-position-checking.js
mindesbunister 1e4f305657 fix: emergency automation fix - stop runaway trading loops
- Replace automation service with emergency rate-limited version
- Add 5-minute minimum interval between automation starts
- Implement forced Chromium process cleanup on stop
- Backup broken automation service as .broken file
- Emergency service prevents multiple simultaneous automations
- Fixed 1400+ Chromium process accumulation issue
- Tested and confirmed: rate limiting works, processes stay at 0
2025-07-24 20:33:20 +02:00

68 lines
2.0 KiB
JavaScript
Raw Permalink Blame History

This file contains invisible Unicode characters
This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env node
/**
* Test position checking in automation service
* This script tests that the automation respects open positions
*/
import { automationService } from './lib/automation-service-simple.js'
async function testPositionChecking() {
console.log('🧪 Testing Position Checking Logic...')
try {
// Test 1: Check hasOpenPositions method
console.log('\n1⃣ Testing hasOpenPositions method...')
const hasPositions = await automationService.hasOpenPositions()
console.log(`✅ hasOpenPositions() result: ${hasPositions}`)
// Test 2: Test automation start with position check
console.log('\n2⃣ Testing automation start with position check...')
const testConfig = {
userId: 'test-position-check',
mode: 'SIMULATION',
symbol: 'SOLUSD',
selectedTimeframes: ['1h'],
tradingAmount: 10,
maxDailyTrades: 1,
dexProvider: 'DRIFT'
}
// Try to start automation (should check positions)
const startResult = await automationService.startAutomation(testConfig)
console.log(`✅ Start automation result: ${startResult}`)
// Test 3: Check automation status
console.log('\n3⃣ Testing automation status...')
const status = await automationService.getStatus()
console.log('📊 Automation status:', {
isRunning: status?.isRunning,
hasPositions: status?.hasOpenPositions,
message: status?.message || 'No message'
})
// Test 4: Stop automation
console.log('\n4⃣ Stopping automation...')
const stopResult = await automationService.stopAutomation()
console.log(`✅ Stop result: ${stopResult}`)
console.log('\n🎉 Position checking tests completed!')
} catch (error) {
console.error('❌ Test failed:', error)
console.error('Stack:', error.stack)
}
}
// Run the test
testPositionChecking()
.then(() => {
console.log('✅ Test script completed')
process.exit(0)
})
.catch((error) => {
console.error('❌ Test script failed:', error)
process.exit(1)
})