File: //opt/trading-bot/reset_all.py
import os
import pymysql
from dotenv import load_dotenv
load_dotenv()
def reset_all_strategies():
conn = pymysql.connect(
host=os.getenv('MYSQL_HOST'),
user=os.getenv('MYSQL_USER'),
password=os.getenv('MYSQL_PASSWORD'),
database=os.getenv('MYSQL_DATABASE'),
port=int(os.getenv('MYSQL_PORT', 3306))
)
strategies = [
"FundingHarvester", "FearGreedContrarian", "WhaleTracker",
"PairsArbitrage", "LiquidationCascade"
]
try:
with conn.cursor() as cur:
print(f"Purging and resetting {len(strategies)} strategies to $10,000...")
for strat in strategies:
# 1. Clear Positions (All history)
cur.execute("DELETE FROM positions WHERE strategy_name = %s", (strat,))
# 2. Clear PnL History (All history)
cur.execute("DELETE FROM pnl_history WHERE strategy_name = %s", (strat,))
# 3. Clear Portfolio State (All history to prevent timestamp drift issues)
cur.execute("DELETE FROM portfolio_state WHERE strategy_name = %s", (strat,))
# 4. Insert fresh Portfolio State
cur.execute("""
INSERT INTO portfolio_state (strategy_name, equity, cash, exposure, drawdown, ts)
VALUES (%s, 10000.0, 10000.0, 0.0, 0.0, NOW())
""", (strat,))
conn.commit()
print("Successfully purged and reset all strategies to $10,000.")
except Exception as e:
print(f"Error during reset: {e}")
conn.rollback()
finally:
conn.close()
if __name__ == "__main__":
reset_all_strategies()