reset_data.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899
  1. #!/bin/bash
  2. echo "🗑️ Resetting Hyperliquid Trading Bot Data"
  3. echo "========================================="
  4. # Confirm with user
  5. read -p "⚠️ This will delete ALL trading data, state, alarms, and logs. Are you sure? (yes/no): " confirm
  6. if [ "$confirm" != "yes" ]; then
  7. echo "❌ Reset cancelled."
  8. exit 1
  9. fi
  10. echo "🧹 Clearing data files..."
  11. DATA_DIR="data"
  12. # Create data directory if it doesn't exist (for idempotency, though removal is primary goal)
  13. # mkdir -p $DATA_DIR
  14. # Remove trading statistics
  15. if [ -f "$DATA_DIR/trading_stats.sqlite" ]; then
  16. rm "$DATA_DIR/trading_stats.sqlite"
  17. echo "✅ Removed $DATA_DIR/trading_stats.sqlite"
  18. fi
  19. # Remove legacy files (if they still exist)
  20. rm -f "$DATA_DIR/trading_stats.json"
  21. rm -f trading_stats.json.backup* # Old root backups
  22. rm -f "$DATA_DIR/trading_stats.json.backup*"
  23. echo "✅ Removed legacy stats files (if any)"
  24. # Remove market monitor state (legacy - now in SQLite)
  25. rm -f "$DATA_DIR/market_monitor_state.json"
  26. echo "✅ Removed legacy market monitor state (if any)"
  27. # Remove legacy bot state files (no longer used - all state now in SQLite)
  28. rm -f "$DATA_DIR/trading_engine_state.json"
  29. rm -f "bot_state.json"
  30. echo "✅ Removed legacy bot state files (if any)"
  31. # Remove alarm data
  32. if [ -f "$DATA_DIR/price_alarms.json" ]; then
  33. rm "$DATA_DIR/price_alarms.json"
  34. echo "✅ Removed $DATA_DIR/price_alarms.json"
  35. fi
  36. rm -f alarms.json alarms.db # Legacy alarm files at root
  37. echo "✅ Removed legacy alarm data from root (if any)"
  38. # Optionally, remove the entire data directory if it's now empty
  39. # Check if directory exists and is empty
  40. if [ -d "$DATA_DIR" ] && [ -z "$(ls -A $DATA_DIR)" ]; then
  41. rmdir "$DATA_DIR"
  42. echo "✅ Removed empty $DATA_DIR directory"
  43. elif [ -d "$DATA_DIR" ]; then
  44. echo "ℹ️ $DATA_DIR directory still contains other files."
  45. fi
  46. # Remove log files
  47. rm -f *.log # Root logs (if any)
  48. rm -rf logs/
  49. echo "✅ Removed log files and logs/ directory"
  50. # Remove any temporary files
  51. rm -f *.tmp *.temp
  52. echo "✅ Removed temporary files"
  53. # Remove any Python cache
  54. find . -type d -name "__pycache__" -exec rm -rf {} +
  55. echo "✅ Removed Python cache directories"
  56. echo ""
  57. echo "🎉 Data reset complete!"
  58. echo ""
  59. echo "📝 What was cleared:"
  60. echo " • Persistent data from the '$DATA_DIR/' directory (stats, state, alarms)"
  61. echo " • Log files from 'logs/' directory and root"
  62. echo " • Legacy data files from the root directory (if found)"
  63. echo " • Trading statistics and P&L history"
  64. echo " • All completed trade records"
  65. echo " • Daily/weekly/monthly performance data"
  66. echo " • Bot state persistence (pending stop losses, order tracking)"
  67. echo " • Price alarms and notifications"
  68. echo " • Log files and debugging data"
  69. echo " • Enhanced position tracking data"
  70. echo ""
  71. echo "🚀 Your bot is now ready for a fresh start!"
  72. echo " • Initial balance will be reset by the bot logic"
  73. echo " • All stats will start from zero"
  74. echo " • Position tracking will reinitialize"
  75. echo " • Bot state persistence will restart fresh"
  76. echo " • Pending stop losses will be cleared"
  77. echo ""
  78. echo "💡 Next steps:"
  79. echo " 1. Run your bot: python trading_bot.py (or your main script)"
  80. echo " 2. Check /balance for initial balance status"
  81. echo " 3. Start trading to build new statistics"