Skip to main content

    Calculation method

    How MoonMath calculates past entry backtest

    What if I had bought on this date — What would an entry on that date have meant?

    The formula

    The multiple is the exit close divided by the entry close, and the return is that minus one. A stated amount is carried through the same ratio: it buys amount ÷ entry close tokens, valued at the exit close. A requested date resolves to the nearest observation only if it lies within half the series' own spacing; otherwise the calculation is refused.

    What it reads

    • A series of price observations with timestamps in seconds
    • The entry date to analyse
    • The amount to invest, so the result is stated in money rather than as a multiple
    • Optionally an exit date, defaulting to the most recent observation

    What it assumes

    • A candle's closing price is the price attributed to that moment; nothing within the interval is modelled
    • The whole amount executes at that day's closing price: no fee, no slippage, no partial fill, and no effect on the price it is paying
    • The tolerance comes from the series' own spacing, so a denser series answers more precisely and a sparser one refuses more often
    • At least two usable observations must exist

    What this does not establish

    • A past price is an observation, not a forecast: it says what an entry then would have produced, not what a future entry will
    • The multiple is a ratio of two closing prices — no fee, tax, slippage or gas term exists in it
    • The series is one pool's trading history, so a token whose liquidity migrated has an earlier life this data does not hold
    • A comparison omits dates the series cannot cover, so it is not necessarily over every date requested

    Run it

    Pick a past date and an amount, and see what that entry would have produced by the most recent observation in the series — as money, not as a multiple, with the price chart it was read from. The result is stated against the two observations it was computed from, not against the dates that were typed, and a date the series does not cover is refused rather than answered with a neighbouring candle.

    Open the Past Entry Backtest calculator

    How the market itself works

    This page describes MoonMath's arithmetic. The mechanics section describes the market: how an order book forms a price, why order-book depth is not the same thing as pool liquidity, and what a public book does and does not let you observe.

    Read the market mechanics