from django.core.management.base import BaseCommand
from core.models import Cryptocurrency
from decimal import Decimal

class Command(BaseCommand):
    help = 'Seeds the database with common cryptocurrencies'

    def handle(self, *args, **options):
        cryptos = [
            ('BTC', 'Bitcoin', 65000.00),
            ('ETH', 'Ethereum', 3500.00),
            ('BNB', 'BNB', 600.00),
            ('SOL', 'Solana', 150.00),
            ('XRP', 'XRP', 0.60),
            ('ADA', 'Cardano', 0.50),
            ('AVAX', 'Avalanche', 40.00),
            ('DOT', 'Polkadot', 7.00),
            ('DOGE', 'Dogecoin', 0.15),
            ('SHIB', 'Shiba Inu', 0.000025),
            ('MATIC', 'Polygon', 0.70),
            ('LINK', 'Chainlink', 15.00),
            ('UNI', 'Uniswap', 8.00),
            ('LTC', 'Litecoin', 80.00),
            ('BCH', 'Bitcoin Cash', 450.00),
            ('ATOM', 'Cosmos', 10.00),
            ('XLM', 'Stellar', 0.12),
            ('ETC', 'Ethereum Classic', 30.00),
            ('NEAR', 'NEAR Protocol', 6.00),
            ('FIL', 'Filecoin', 6.00),
            ('ICP', 'Internet Computer', 12.00),
            ('HBAR', 'Hedera', 0.10),
            ('VET', 'VeChain', 0.04),
            ('ALGO', 'Algorand', 0.20),
            ('GRT', 'The Graph', 0.30),
            ('FTM', 'Fantom', 0.80),
            ('SAND', 'The Sandbox', 0.50),
            ('MANA', 'Decentraland', 0.50),
            ('AAVE', 'Aave', 100.00),
            ('THETA', 'Theta Network', 2.50),
            ('EGLD', 'MultiversX', 45.00),
            ('XTZ', 'Tezos', 1.20),
            ('EOS', 'EOS', 0.80),
            ('FLOW', 'Flow', 1.00),
            ('CHZ', 'Chiliz', 0.15),
            ('AXS', 'Axie Infinity', 8.00),
            ('GALA', 'Gala', 0.05),
            ('KAVA', 'Kava', 0.70),
            ('ZEC', 'Zcash', 30.00),
            ('DASH', 'Dash', 35.00),
            ('NEO', 'NEO', 15.00),
            ('IOTA', 'IOTA', 0.25),
            ('KLAY', 'Klaytn', 0.20),
            ('BSV', 'Bitcoin SV', 70.00),
            ('MINA', 'Mina', 0.90),
            ('XEC', 'eCash', 0.00005),
            ('BTT', 'BitTorrent', 0.000001),
            ('LUNC', 'Terra Classic', 0.0001),
            ('USTC', 'TerraClassicUSD', 0.02),
        ]

        for symbol, name, price in cryptos:
            Cryptocurrency.objects.update_or_create(
                symbol=symbol,
                defaults={
                    'name': name,
                    'current_price': Decimal(str(price)),
                    'change_24h': Decimal('0.00'),
                    'is_active': True
                }
            )
            self.stdout.write(self.style.SUCCESS(f'Successfully seeded {symbol}'))
