★ STRATEGY BUILDER

Configure Your Bot.
Download & Deploy.

Pick a strategy, configure your parameters, enter your LMEX symbol and get a complete, ready-to-run Python bot in seconds. No coding required.

EMA CrossoverTREND

Goes long when fast EMA crosses above slow EMA, short when it crosses below. Classic trend-following.

RSI Mean ReversionREVERSION

Buys when RSI drops below oversold threshold, sells when RSI rises above overbought threshold.

MACD Trend FollowTREND

Enters long on bullish MACD crossover, short on bearish. Filters out noise in trending markets.

Bollinger Band ReversionREVERSION

Mean reversion strategy using Bollinger Bands. Buys lower band touches, sells upper band touches.

Grid TradingGRID

Places buy and sell orders at regular price intervals. Profits from price oscillation in ranging markets.

Funding Rate ArbitrageARBITRAGE

Delta-neutral strategy: long spot + short perp to collect positive funding rates. Market-neutral yield.

SupertrendTREND

ATR-based trend indicator. Highly effective in trending markets with clear stop-loss levels.

VWAP ReversionREVERSION

Intraday mean reversion using VWAP as the anchor. Fades moves away from fair value.

Momentum (ROC)MOMENTUM

Rate of change momentum strategy. Buys strong upward momentum, shorts strong downward momentum.

DCAACCUMULATION

Dollar cost average on scheduled intervals and price dips. Reduces average entry over time.

ScalpingSCALPING

High-frequency scalping using tight Bollinger Bands. Many small trades targeting 0.1-0.3% per trade.

Kelly Criterion SizerRISK MANAGEMENT

Mathematically optimal position sizing using Kelly Criterion with ADX trend filter.

EMA Crossover

Goes long when fast EMA crosses above slow EMA, short when it crosses below. Classic trend-following.

ema_crossover.py
#!/usr/bin/env python3
"""
EMA Crossover Strategy for LMEX Exchange
Generated by lmex.ai Strategy Builder
"""
import os, time, hmac, hashlib, requests
import numpy as np
import pandas as pd

# ── Configuration ─────────────────────────────────
SYMBOL     = "BTC-PERP"
API_KEY    = os.environ.get("LMEX_API_KEY", "")
API_SECRET = os.environ.get("LMEX_API_SECRET", "")
BASE_URL   = "https://api.lmex.io/futures/api/v2.3"
PAPER_TRADE = True

FAST_EMA = 9
SLOW_EMA = 21
LEVERAGE = 5

def sign(path: str) -> dict:
    nonce = str(int(time.time() * 1000))
    sig   = hmac.new(API_SECRET.encode(), (path+nonce).encode(), hashlib.sha384).hexdigest()
    return {"request-api": API_KEY, "request-nonce": nonce, "request-sign": sig}

def get_ohlcv(limit=200):
    r = requests.get(f"{BASE_URL}/ohlcv", params={"symbol":SYMBOL,"resolution":60,"limit":limit})
    data = r.json()
    df = pd.DataFrame(list(reversed(data)), columns=["time","open","high","low","close","volume"])
    return df.astype({"open":float,"high":float,"low":float,"close":float,"volume":float})

def place_order(side: str, size: float, price: float = None):
    if PAPER_TRADE:
        print(f"[PAPER] {side.upper()} {size} {SYMBOL}" + (f" @ {price}" if price else ""))
        return
    body = {"symbol":SYMBOL,"side":side,"orderType":"LIMIT" if price else "MARKET","size":size}
    if price: body["price"] = price
    path = "/api/v2.3/order"
    r = requests.post(BASE_URL+path, json=body, headers={**sign(path),"Content-Type":"application/json"})
    print(r.json())


def compute_signal(df):
    df["ema_fast"] = df["close"].ewm(span=FAST_EMA).mean()
    df["ema_slow"] = df["close"].ewm(span=SLOW_EMA).mean()
    cross_up   = df["ema_fast"].iloc[-1] > df["ema_slow"].iloc[-1] and df["ema_fast"].iloc[-2] <= df["ema_slow"].iloc[-2]
    cross_down = df["ema_fast"].iloc[-1] < df["ema_slow"].iloc[-1] and df["ema_fast"].iloc[-2] >= df["ema_slow"].iloc[-2]
    return "long" if cross_up else "short" if cross_down else None


def main():
    print(f"Starting EMA Crossover on {SYMBOL} ({'PAPER' if PAPER_TRADE else 'LIVE'})")
    
    while True:
        try:
            df     = get_ohlcv()
            signal = compute_signal(df)
            price  = float(df["close"].iloc[-1])
            if signal:
                print(f"Signal: {signal.upper()} @ {price}")
                place_order(signal, 1)
        except Exception as e:
            print(f"Error: {e}")
        time.sleep(60)

if __name__ == "__main__":
    main()