"""Settings from .env (keys, mode). Trading parameters are chosen in the web page."""
import os

try:
    from dotenv import load_dotenv
    load_dotenv()
except ImportError:
    pass

MARGINS = [0.25, 0.5, 0.75, 1.0, 1.25, 1.5, 2.0]   # net profit % choices shown in the UI


class Config:
    mode = os.getenv("MODE", "paper").lower()                 # paper | live
    symbol = os.getenv("SYMBOL", "BNBUSDT")
    base_asset = os.getenv("BASE_ASSET", "BNB")
    quote_asset = os.getenv("QUOTE_ASSET", "USDT")
    spot_url = os.getenv("ASTER_SPOT_URL", "https://sapi.asterdex.com")
    chain_id = int(os.getenv("ASTER_CHAIN_ID", "1666"))

    user_address = os.getenv("ASTER_USER_ADDRESS", "")
    signer_address = os.getenv("ASTER_SIGNER_ADDRESS", "")
    signer_private_key = os.getenv("ASTER_SIGNER_PRIVATE_KEY", "")

    taker_fee = float(os.getenv("TAKER_FEE", "0.0004"))          # Aster spot base tier: 0.04%
    paper_start_usdt = float(os.getenv("PAPER_START_USDT", "500"))
    price_feed = os.getenv("PRICE_FEED", "aster").lower()     # aster | demo (simulated prices, for trying the UI)
    tick_seconds = float(os.getenv("TICK_SECONDS", "1"))
    futures_url = os.getenv("ASTER_FUTURES_URL", "https://fapi.asterdex.com")   # live BNB market price for display

    host = os.getenv("HOST", "127.0.0.1")
    port = int(os.getenv("PORT", "8090"))
    username = os.getenv("DASHBOARD_USER", "").strip() or "admins"
    password = os.getenv("DASHBOARD_PASSWORD", "") or "waveBot2026!"
    data_dir = os.getenv("DATA_DIR", "data")
    signup = os.getenv("SIGNUP", "on").strip().lower() not in ("off", "0", "no", "false")   # open sign-up page
    max_users = int(os.getenv("MAX_USERS", "200"))            # protects the server from runaway sign-ups
    server_ip = os.getenv("SERVER_IP", "").strip()            # shown to users for their Aster API wallet IP list
    public_view = os.getenv("PUBLIC_VIEW", "on").strip().lower() not in ("off", "0", "no", "false")
