reset_data.sh 3.3 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100
  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.json" ]; then
  16. rm "$DATA_DIR/trading_stats.json"
  17. echo "✅ Removed $DATA_DIR/trading_stats.json"
  18. fi
  19. # Remove backup stats (if any were made at root or in data)
  20. rm -f trading_stats.json.backup* # Old root backups
  21. rm -f "$DATA_DIR/trading_stats.json.backup*"
  22. echo "✅ Removed stats backups (if any)"
  23. # Remove trading engine state persistence file
  24. if [ -f "$DATA_DIR/trading_engine_state.json" ]; then
  25. rm "$DATA_DIR/trading_engine_state.json"
  26. echo "✅ Removed $DATA_DIR/trading_engine_state.json"
  27. fi
  28. # Remove old bot_state.json if it exists at root from previous versions
  29. if [ -f "bot_state.json" ]; then
  30. rm bot_state.json
  31. echo "✅ Removed legacy bot_state.json from root"
  32. fi
  33. # Remove alarm data
  34. if [ -f "$DATA_DIR/price_alarms.json" ]; then
  35. rm "$DATA_DIR/price_alarms.json"
  36. echo "✅ Removed $DATA_DIR/price_alarms.json"
  37. fi
  38. rm -f alarms.json alarms.db # Legacy alarm files at root
  39. echo "✅ Removed legacy alarm data from root (if any)"
  40. # Optionally, remove the entire data directory if it's now empty
  41. # Check if directory exists and is empty
  42. if [ -d "$DATA_DIR" ] && [ -z "$(ls -A $DATA_DIR)" ]; then
  43. rmdir "$DATA_DIR"
  44. echo "✅ Removed empty $DATA_DIR directory"
  45. elif [ -d "$DATA_DIR" ]; then
  46. echo "ℹ️ $DATA_DIR directory still contains other files."
  47. fi
  48. # Remove log files
  49. rm -f *.log # Root logs (if any)
  50. rm -rf logs/
  51. echo "✅ Removed log files and logs/ directory"
  52. # Remove any temporary files
  53. rm -f *.tmp *.temp
  54. echo "✅ Removed temporary files"
  55. # Remove any Python cache
  56. find . -type d -name "__pycache__" -exec rm -rf {} +
  57. echo "✅ Removed Python cache directories"
  58. echo ""
  59. echo "🎉 Data reset complete!"
  60. echo ""
  61. echo "📝 What was cleared:"
  62. echo " • Persistent data from the '$DATA_DIR/' directory (stats, state, alarms)"
  63. echo " • Log files from 'logs/' directory and root"
  64. echo " • Legacy data files from the root directory (if found)"
  65. echo " • Trading statistics and P&L history"
  66. echo " • All completed trade records"
  67. echo " • Daily/weekly/monthly performance data"
  68. echo " • Bot state persistence (pending stop losses, order tracking)"
  69. echo " • Price alarms and notifications"
  70. echo " • Log files and debugging data"
  71. echo " • Enhanced position tracking data"
  72. echo ""
  73. echo "🚀 Your bot is now ready for a fresh start!"
  74. echo " • Initial balance will be reset by the bot logic"
  75. echo " • All stats will start from zero"
  76. echo " • Position tracking will reinitialize"
  77. echo " • Bot state persistence will restart fresh"
  78. echo " • Pending stop losses will be cleared"
  79. echo ""
  80. echo "💡 Next steps:"
  81. echo " 1. Run your bot: python trading_bot.py (or your main script)"
  82. echo " 2. Check /balance for initial balance status"
  83. echo " 3. Start trading to build new statistics"