Python Scripting

Python Examples

Short, read-only scripts with inputs and expected output.

These examples do not place orders. Choose Scripts → Examples → Use example in Furge to create an editable copy. For the CLI, download a .py file below. Public data does not require a funded trading account, but running a script still requires a ready runtime.

ExampleDataBacktestLive
Watch candle closesHyperliquid BTC candles, 60 secondsYesYes
Build a momentum signalHyperliquid BTC candles, 60 secondsYesYes
Watch the spreadHyperliquid BTC orderbookNoYes

Watch candle closes

Download candle-monitor.py

script = {"name": "candle-monitor", "version": "2", "lookback": 2}
SOURCE = "btc@candles@hyperliquidf:timeframe=60"


def on_data(ctx, history):
    candle = history.source(SOURCE, 0)
    if candle is None:
        return
    print(f"BTC close: {candle['c']} | volume: {candle['volume']}")
    return {"metrics": {"close": candle["c"], "volume": candle["volume"]}}

Expected output: One log line per candle and close/volume metrics. Zero closed trades is expected.

Build a momentum signal

Download momentum-signal.py

script = {"name": "momentum-signal", "version": "2", "lookback": 5}
SOURCE = "btc@candles@hyperliquidf:timeframe=60"


def on_data(ctx, history):
    candles = history.source(SOURCE)
    if len(candles) < 5:
        return
    average = sum(row["c"] for row in candles) / len(candles)
    close = candles[-1]["c"]
    signal = "above average" if close > average else "at or below average"
    print(f"BTC {signal}: close={close}, mean={average}")
    return {"metrics": {"close": close, "mean": average}}

Expected output: After five candles, the latest close and retained five-candle mean. This demonstrates a signal; it does not send orders.

Watch the spread

Download book-spread.py

script = {"name": "book-spread", "version": "2", "lookback": 2}
SOURCE = "btc@orderbook@hyperliquidf:depth=5"


def on_data(ctx, history):
    book = history.source(SOURCE, 0)
    if not book or not book["bids"] or not book["asks"]:
        return
    bid = book["bids"][0]["price"]
    ask = book["asks"][0]["price"]
    midpoint = (bid + ask) / 2
    if midpoint <= 0:
        return
    spread_bps = (ask - bid) / midpoint * 10_000
    print(f"BTC bid={bid} ask={ask} spread={spread_bps:.2f} bps")
    return {"metrics": {"bid": bid, "ask": ask, "spread_bps": spread_bps}}

Expected output: Best bid, best ask, and spread in basis points. This source is live-only: use Deploy bot, not Backtest.

Contract markets and execution

Copy the market source from Furge's picker. Start with Nest Scripts or Elysium trades.

When ready to add real orders, use Execution. Live execution can use real funds. Copying a signal example does not make it a safe trading strategy.

Next: First script in Furge · Data Sources · Monitoring.

On this page