- 46Contributors
- Aug 5, 2026Last commit
- AGPL-3.0License
- Nevertrades
Backtesting.py tests an entry and exit rule on any OHLCV, including the Solana candles your agent pulls from Moby, with stats and a chart of every trade.
About
Backtesting.py is a small Python library. Give it a pandas table of OHLCV candles and a strategy class with entry and exit rules, and it returns the usual statistics (return, win rate, drawdown, Sharpe, exposure) and an interactive chart of every trade. It also has a parameter optimizer.
What it adds to Moby. A quick backtest on the exact data your Moby agent trades. It does not care where candles come from, so your agent can test a rule on a Solana token's own history, new launches included, once there is enough of it.
How to pair it. Turn a strategy idea (for example a breakout with Moby's default -30% stop and +100% take-profit) into a Backtesting.py strategy, run it on a few tokens from get_token_ohlcv, and show the stats before you save it as a Moby strategy. Moby returns candles newest-first; reverse them before you feed them in.
What it does not do. It tests one instrument at a time with a simple fill model, so slippage on thin Solana pools is understated; add a generous commission. It does not trade. Its license is AGPL-3.0, which matters only if you ship it inside a product.
What's inside this repo
- Backtest and Strategy classes: write init() and next() with self.buy() and self.sell()
- Any instrument with OHLC(V) candles in a pandas DataFrame
- Stats: return, Sharpe, Sortino, Calmar, max drawdown, win rate, profit factor, SQN, Kelly
- Interactive plot of the equity curve and every trade (bt.plot())
- Built-in optimizer (SAMBO) with heatmaps of parameter results
- backtesting.lib: crossover() helper and composable base strategies
- Commission and exclusive_orders options; trade list and equity curve as pandas objects
Install steps
Third-party code: Moby does not audit or control it. Read the source before you run it.
pip install backtesting- Read the quick-start: https://kernc.github.io/backtesting.py/
- Ask:
Pull 30 days of hourly candles for <token> with get_token_ohlcv, put them oldest-first, and backtest a breakout rule with a -30% stop and +100% take-profit in Backtesting.py. Include 1% commission.
Permissions
- Reads
- OHLCV candles your agent fetches from Moby (get_token_ohlcv) or any other source
- Writes
- Local result files and HTML charts
- Tools
- Python library `backtesting`
- Trade
- Never trades
Review
Reviewed Nov 1, 2026. Source matches repo at commit ca2e261
Links
On GitHub
- Stars
- 9,251
- Forks
- 1,585
How it works with Moby
Backtesting.py works on its own. With Moby your agent can also trade on what it finds.
- Set up AI Trading
In the Moby app: create your agent and fund its Solana wallet.
Get the app - Connect Moby MCP
Whale, KOL and smart-money data, plus buy, sell, SL and TP from the agent wallet.
View Moby MCP - Install Backtesting.py
Your agent runs it alongside Moby's onchain data and trades inside your Guardrails.
Install
Related
- APSchedulerAPScheduler is an open-source Python job scheduler, so your agent…
- CCXTCCXT is a unified library for crypto exchange market data, balances…
- CryptofeedCryptofeed is a Python websocket handler for live cryptocurrency…
- DuckDBDuckDB is an in-process analytical database for SQL over local and…
- Moby MCP connectorConnect any MCP-capable agent to Moby for live onchain research on…
- Moby KnowledgeThe /agents page and agents.md as your agent's Moby reference: how…
Reviewed Nov 1, 2026 · Report this item
