- Python 3.8+ installed
- pip for package management
- Basic knowledge of trading concepts (e.g., candlesticks, moving averages, order types)
Run the following to install Jesse:
pip install jesse
After installation, initialize a Jesse project directory:
jesse init-project
cd my-jesse-project
## Install dependencies
pip install -r requirements.txt
This scaffolds a config file (config.py), folders for strategies (strategies/), and data management scripts.
In my experience, the config defaults tend to be fine for testnet/demo trading, but you’ll want to adjust API keys for your chosen exchange and set the desired trading pairs.
Pro tip: Jesse supports multiple exchanges via CCXT under the hood — just update your config accordingly.
Jesse Framework Strategy Example: A Simple Moving Average Crossover
Here’s a minimal strategy that buys when the fast moving average crosses above the slow one and sells when it crosses below.
Create a file: strategies/sample_sma_crossover.py
import jesse.indicators as ta
from jesse.strategies import Strategy
class SampleSMACrossover(Strategy):
def __init__(self):
super().__init__()
self.fast_ma = None
self.slow_ma = None
def before(self):
## Calculate moving averages
self.fast_ma = ta.sma(self.candles, 10)
self.slow_ma = ta.sma(self.candles, 30)
def should_long(self) -> bool:
return self.fast_ma[-2] < self.slow_ma[-2] and self.fast_ma[-1] > self.slow_ma[-1]
def should_short(self) -> bool:
return self.fast_ma[-2] > self.slow_ma[-2] and self.fast_ma[-1] < self.slow_ma[-1]
def go_long(self):
qty = self.capital / self.price # simple full capital allocation
self.buy = qty, self.price
def go_short(self):
qty = self.capital / self.price
self.sell = qty, self.price
def should_exit_long(self) -> bool:
return self.fast_ma[-1] < self.slow_ma[-1]
def should_exit_short(self) -> bool:
return self.fast_ma[-1] > self.slow_ma[-1]
Run backtesting:
jesse backtest 2022-01-01 2022-06-01 --strategy SampleSMACrossover
This loads historical candles and runs the strategy over those periods, printing performance metrics.
What I like about Jesse’s API here is the clear hooks — you control entry and exit logic independently while leveraging built-in indicator utilities.
Monte Carlo Backtesting in Jesse
Monte Carlo backtesting helps reveal strategy robustness by simulating random variations in trade sequences or price data.
Currently, Jesse supports Monte Carlo via configurable noise injection and data shuffling.
Execute Monte Carlo runs with:
jesse monte_carlo 2022-01-01 2022-06-01 --strategy SampleSMACrossover --runs 100
Expect an output distribution of returns rather than a single point estimate.
Under the hood, each run perturbs candle timestamps or slight price adjustments, testing if the strategy overfits specific patterns.
I’ve found this method invaluable for stress-testing strategies before deploying them live.
Warning: Monte Carlo adds runtime overhead, so consider limiting runs or date ranges initially.
Live Trading Setup with Jesse
Beyond backtesting, Jesse can execute live orders on exchanges via CCXT.
Key steps:
- Update
config.py with your exchange API keys.
- Set
env = 'live' in your Jesse run commands.
- Wire up your strategy to handle live fills carefully.
Run live trading like:
jesse run-live --strategy SampleSMACrossover
This starts the bot with live data feed and order submission.
From my hands-on time, real-world catches include:
- Latency in order fills
- Unexpected API errors (handle with retries)
- Sudden liquidity drops triggering partial fills
So definitely build in robust error handling around self.buy / self.sell calls.
Jesse vs Freqtrade: Feature & Architecture Comparison
Picking a framework sometimes boils down to differences in language ecosystem, extensibility, and operational footprint.
The table below compares Jesse and Freqtrade along key axes:
| Feature |
Jesse |
Freqtrade |
| Language |
Python |
Python |
| Backtesting |
Tick-based, candle-based, Monte Carlo |
Candle-based, Monte Carlo |
| Strategy Structure |
Class-based, hooks (should_* methods) |
Functional configs + class-based |
| Live Trading Exchanges |
CCXT-supported |
CCXT-supported |
| Machine Learning |
Limited out of the box |
Integrations available (FreqAI) |
| Community & Ecosystem |
Smaller, growing |
Larger, more third-party bots |
| Config Complexity |
Low-medium |
Medium-high |
| Documentation |
Concise, sometimes sparse |
Detailed, tutorial-rich |
Neither is hands-down better. Jesse excels when you want straightforward Python-class strategies and granular control over backtests, including Monte Carlo methods. Freqtrade shines if you want larger community support, ML integrations, and more config-driven customization.
For more on Freqtrade setup, check out Freqtrade Tutorials.
Building an Algo Trading Crypto Bot from Scratch in Python
If you’re curious about how to build your algo bot from zero, Jesse shows a nice blueprint but with batteries included.
Steps would roughly be:
- Market Data Ingestion: Use CCXT or exchange websockets for candle & tick data.
- Strategy Logic: Define signal generation rules (e.g., moving averages, RSI).
- Order Management: Implement order execution, tracking fills, partial fills.
- Risk Management: Apply position sizing, stop-loss, take-profit.
- Backtesting Framework: Replay historical data, compute PnL and risk metrics.
- Live Trading Integration: Hook order placement to exchange APIs with proper error handling.
Jesse handles steps 1, 3, 5, and 6 internally, letting you focus on step 2 and 4.
If you prefer a minimal bot to hack on, a starter from scratch might look like this pseudocode:
## Pseudo-code
class MyStrategy:
def on_new_candle(self, candle):
## Update indicators
## Check conditions
## Send orders
while True:
candle = fetch_latest_candle()
my_strategy.on_new_candle(candle)
sleep(interval)
For real-world usage, I suggest adding modular data pipelines and error recovery from the start.
Security Considerations and Best Practices
When I wired up Jesse for live trading, handling private keys and API credentials securely was top priority.
- Never hardcode keys in your strategy files.
- Use environment variables or encrypted config stores.
- Restrict API keys with IP whitelisting and limited permissions (e.g., no withdrawal rights).
- Monitor exchange rate limits and API call frequency to avoid bans.
- Beware of overexposure: session keys or unlimited approvals in smart contracts can drain wallets instantly.
From a bot security angle, isolate your execution environment to limit blast radius from exploits.
And always do paper trading or dry-runs before giving your bot live fund access.
Troubleshooting Common Jesse Issues
Some gotchas developers commonly hit:
Data not loading for backtesting: Confirm that candle data is downloaded locally (jesse import-candles) and matches specified date ranges.
Strategy script errors: Make sure any custom indicators or strategy classes conform to Jesse’s expected API surface; watch for indexing errors in arrays.
Order submissions failing in live mode: Check API keys, network connectivity, and rate limits. Logs often reveal detailed error messages.
Monte Carlo runs very slow: Reduce the number of runs or narrow backtest periods.
For detailed error diagnostics, trading-bot-troubleshooting can help.
Conclusion: Picking the Right Tool for Your Needs
Jesse is a solid Python framework for crypto algo trading that offers clean API design, integrated Monte Carlo backtesting, and straightforward live trading connectivity. It’s a good fit when you want to build well-structured strategies and experiment with robust evaluation methods.
I believe developers should prototype serious bots on Jesse for its simplicity, then consider broader ecosystems like Freqtrade if ML integrations or community tooling matter.
Experiment, measure, fail fast — that’s the trader’s mantra. And if you want to add AI elements or smart-contract security to your trading pipeline, dive into related topics like ai-smart-contract-security or mev-bot-development alongside your bot-building efforts.
Happy coding!
For more on related projects, check these:
Related: TradingAgents