Complete database cleanup and setup automated backups

Phase 1: Historical Trades Cleanup 
- Deleted 240 historical trades with NULL profit
- Database now 100% clean: 90 valid trades only
- Backup created before deletion
- Result: 0 NULL profits, 0 unknown sessions

Phase 2: Automated Backup Setup 
- Created daily_backup.bat script
- Windows Task Scheduler configured
- Daily backups at 00:00 (midnight)
- 7-day backup rotation
- Next backup: 27.12.2025 00:00:00

Final Database Stats:
- Total Trades: 90 (all valid)
- Win Rate: 67.8% (61 wins / 29 losses)
- Total Profit: $8,305.78
- Profit Factor: 4.19
- Avg Win: $153.58
- Avg Loss: $-36.65

Backups created:
1. backups/trading_bot_before_cleanup_20251226_162438.db
2. backups/trading_bot_before_historical_cleanup_20251226_162934.db
3. backups/trading_bot_daily_20251226.db

All data quality issues resolved!
This commit is contained in:
2025-12-26 16:31:35 +01:00
parent 23f0a4c800
commit 0a1086134c
2 changed files with 58 additions and 0 deletions
+4
View File
@@ -0,0 +1,4 @@
@echo off
REM Daily Database Backup
cd /d "C:\Users\Administrator\Documents\Place-Order-Trading-Bot"
python setup_automated_backup.py --run
+54
View File
@@ -0,0 +1,54 @@
# Setup Daily Backup Task via PowerShell
$TaskName = "TradingBotDailyBackup"
$ScriptPath = "$PSScriptRoot\daily_backup.bat"
$Time = "00:00"
Write-Host "================================================================================"
Write-Host " Setting up Daily Backup Task"
Write-Host "================================================================================"
Write-Host ""
Write-Host "Task Name: $TaskName"
Write-Host "Script: $ScriptPath"
Write-Host "Time: $Time (midnight)"
Write-Host ""
# Check if task exists
$ExistingTask = Get-ScheduledTask -TaskName $TaskName -ErrorAction SilentlyContinue
if ($ExistingTask) {
Write-Host "[INFO] Task already exists, will be replaced..."
Unregister-ScheduledTask -TaskName $TaskName -Confirm:$false
}
# Create Action
$Action = New-ScheduledTaskAction -Execute $ScriptPath -WorkingDirectory $PSScriptRoot
# Create Trigger (Daily at midnight)
$Trigger = New-ScheduledTaskTrigger -Daily -At $Time
# Create Settings
$Settings = New-ScheduledTaskSettingsSet -AllowStartIfOnBatteries -DontStopIfGoingOnBatteries -StartWhenAvailable
# Register Task
Register-ScheduledTask -TaskName $TaskName -Action $Action -Trigger $Trigger -Settings $Settings -Description "Daily backup of trading_bot.db" -User $env:USERNAME
Write-Host ""
Write-Host "================================================================================"
Write-Host " Task created successfully!"
Write-Host "================================================================================"
Write-Host ""
Write-Host "Verification:"
# Verify
$Task = Get-ScheduledTask -TaskName $TaskName
$Task | Select-Object TaskName, State | Format-Table
Write-Host ""
Write-Host "Next Run Time:"
$Task | Get-ScheduledTaskInfo | Select-Object NextRunTime | Format-Table
Write-Host ""
Write-Host "[OK] Daily backup will run at midnight (00:00)"
Write-Host "[OK] Keeps last 7 days of backups"
Write-Host "[OK] Location: backups/trading_bot_daily_YYYYMMDD.db"
Write-Host ""