""" šŸš€šŸ’Ž DIAMOND HANDS TRADING BOT šŸ’ŽšŸš€ A WSB-inspired crypto trading bot - TO THE MOON! """ import random from datetime import datetime from flask import Flask, render_template, jsonify app = Flask(__name__) # Simulated portfolio portfolio = { "balance": 10000.00, "holdings": {}, "total_gains": 0.0, "trades": [] } # Meme-worthy crypto symbols CRYPTO_TICKERS = ["BTC", "ETH", "DOGE", "SHIB", "PEPE", "BONK", "WIF", "FLOKI"] # WSB-style messages BULL_MESSAGES = [ "šŸš€ TO THE MOON! šŸŒ™", "šŸ’ŽšŸ™Œ DIAMOND HANDS BABY! šŸ’ŽšŸ™Œ", "šŸ¦ APES TOGETHER STRONG! šŸ¦", "TENDIES INCOMING! šŸ—šŸ—šŸ—", "BUY THE DIP, RETARD! šŸ“ˆ", "HODL! NEVER SELL! šŸ’Ŗ", "THIS IS THE WAY šŸŽÆ", "STONKS ONLY GO UP! šŸ“Š", ] BEAR_MESSAGES = [ "šŸ’€ GUH... šŸ’€", "šŸ“‰ BAGS ARE HEAVY...", "🤔 I'M FINANCIALLY RUINED 🤔", "WIFE'S BOYFRIEND IS MAD 😤", "BEHIND WENDY'S DUMPSTER TIME šŸ”", "LOSS PORN INCOMING šŸ“ø", ] def get_random_price(ticker: str) -> float: """Generate a random price for a ticker.""" base_prices = { "BTC": 42000, "ETH": 2200, "DOGE": 0.08, "SHIB": 0.000009, "PEPE": 0.0000012, "BONK": 0.000015, "WIF": 2.50, "FLOKI": 0.00003 } base = base_prices.get(ticker, 100) variance = base * 0.1 # 10% variance return round(base + random.uniform(-variance, variance), 8) def execute_trade() -> dict: """Execute a random trade like a true degen.""" global portfolio ticker = random.choice(CRYPTO_TICKERS) action = random.choice(["BUY", "SELL"]) price = get_random_price(ticker) # Random quantity based on price if price > 100: quantity = round(random.uniform(0.001, 0.1), 6) elif price > 1: quantity = round(random.uniform(1, 100), 4) else: quantity = round(random.uniform(10000, 1000000), 0) trade_value = price * quantity pnl = 0.0 if action == "BUY": if portfolio["balance"] >= trade_value: portfolio["balance"] -= trade_value if ticker in portfolio["holdings"]: portfolio["holdings"][ticker]["quantity"] += quantity portfolio["holdings"][ticker]["avg_price"] = ( portfolio["holdings"][ticker]["avg_price"] + price ) / 2 else: portfolio["holdings"][ticker] = { "quantity": quantity, "avg_price": price } message = random.choice(BULL_MESSAGES) else: return {"error": "NOT ENOUGH TENDIES! šŸ’ø"} else: # SELL if ticker in portfolio["holdings"] and portfolio["holdings"][ticker]["quantity"] >= quantity: avg_price = portfolio["holdings"][ticker]["avg_price"] pnl = (price - avg_price) * quantity portfolio["balance"] += trade_value portfolio["total_gains"] += pnl portfolio["holdings"][ticker]["quantity"] -= quantity if portfolio["holdings"][ticker]["quantity"] <= 0: del portfolio["holdings"][ticker] message = random.choice(BULL_MESSAGES if pnl >= 0 else BEAR_MESSAGES) else: return {"error": "CAN'T SELL WHAT YOU DON'T HAVE, RETARD! 🤔"} trade = { "timestamp": datetime.now().strftime("%H:%M:%S"), "action": action, "ticker": ticker, "quantity": quantity, "price": price, "value": round(trade_value, 2), "pnl": round(pnl, 2), "message": message } portfolio["trades"].insert(0, trade) portfolio["trades"] = portfolio["trades"][:20] # Keep last 20 trades return trade @app.route("/") def index(): """Render the main trading dashboard.""" return render_template("index.html") @app.route("/api/portfolio") def get_portfolio(): """Get current portfolio state.""" # Calculate current holdings value holdings_value = sum( get_random_price(ticker) * data["quantity"] for ticker, data in portfolio["holdings"].items() ) return jsonify({ "balance": round(portfolio["balance"], 2), "holdings": portfolio["holdings"], "holdings_value": round(holdings_value, 2), "total_value": round(portfolio["balance"] + holdings_value, 2), "total_gains": round(portfolio["total_gains"], 2), "trades": portfolio["trades"] }) @app.route("/api/trade", methods=["POST"]) def trade(): """Execute a random trade.""" result = execute_trade() return jsonify(result) @app.route("/api/prices") def get_prices(): """Get current prices for all tickers.""" prices = {ticker: get_random_price(ticker) for ticker in CRYPTO_TICKERS} return jsonify(prices) if __name__ == "__main__": print("\n" + "="*60) print("šŸš€šŸ’Ž DIAMOND HANDS TRADING BOT ACTIVATED šŸ’ŽšŸš€") print("="*60) print("\nšŸ¦ APES TOGETHER STRONG! Starting server...\n") app.run(debug=True, port=6969, host="0.0.0.0")