Jesse Algorithmic Trading Framework

website·Indexed 32 days ago

https://docs.jesse.trade/

A professional framework for algorithmic trading featuring backtesting, hyperparameter optimization, and advanced research tools. It includes support for machine learning (binary and multiclass classification, meta-labeling), custom indicators, Monte Carlo simulations, and rule significance testing. The platform provides a comprehensive API for strategy development, including spot and futures modes, and integrates with Jupyter Notebooks for data research.

Tokens
81.6K
Snippets
347
Records
621
Agent score
59%

What's inside Jesse

  1. Overview of the Jesse ML pipeline workflow

    The jesse.research module provides a pipeline for integrating machine learning into trading strategies. The typical workflow consists of five stages:

    1. Strategy Development: Implement record_features({...}) at signal bars and record_label(name, value) when outcomes are known. Use before()/after() for continuous observation or on_open_position/on_close_position for trade-based labeling.
    2. Data Gathering: Run gather_ml_data() to collect labeled samples. Data is auto-saved to strategies/<Name>/ml_data/<Name>_data.csv. A healthy sample range is 2,000–5,000 points.
    3. Model Training: Run train_model() with a scikit-learn compatible estimator. This produces model.pkl, scaler.pkl, and feature_importance.pkl in the strategy folder.
    4. Deployment: Set self.ml_mode = "deploy" in the strategy. Use ml_predict() (regression) or ml_predict_proba() (classification) to filter or weight signals.
    5. Evaluation: Backtest the filtered strategy against the baseline and iterate on features or estimators.
    from jesse.research import (
        gather_ml_data,
        load_ml_data_csv,
        train_model,
    )
  2. Overview of Monte Carlo Analysis in Jesse

    Monte Carlo analysis is used to determine if a trading strategy's backtest results are due to genuine skill or luck. It helps prevent overfitting by simulating many alternate market scenarios and shuffled trade sequences to see if the original results were an outlier. If most simulations perform worse than the original backtest, the strategy is likely overfitted to specific historical price moves or timing.

    Key benefits include:

    • Identifying fragile parameter choices to reduce curve-fitting.
    • Determining the expected range of results.
    • Testing strategy performance across different market conditions.
  3. Overview of Jesse MCP integration

    Jesse utilizes the Model Context Protocol (MCP) to create a shared language between AI assistants (such as Cursor, VS Code, or Zed) and the Jesse application. This allows the assistant to perform controlled actions and read information directly from Jesse on your local machine, rather than relying on general knowledge or guessing how the framework works. All data and strategies remain local and under the user's control.
  4. Overview of Meta-Labeling for Trading

    Meta-labeling is a technique used to refine trading models by separating the decision of trade direction from the decision of trade execution and sizing. It consists of two components:

    1. Primary Model: Decides the direction (Long or Short). This can be rule-based, technical, fundamental, or an ML classifier. It is designed for high recall (catching as many opportunities as possible), even if precision is low.
    2. Meta-Label Model: A binary classifier that decides whether to act on the primary model's signal. It predicts a label of {0, 1}, where 0 means 'pass' and 1 means 'take the bet'.

    By using a meta-label model to filter out false positives from a high-recall primary model, traders can increase the overall F1-score (the harmonic mean of precision and recall) of their strategy.

  5. Use Model Context Protocol (MCP) with Jesse

    Jesse supports the Model Context Protocol (MCP), allowing AI coding assistants (such as Claude, Cursor, and Codex) to interact directly with the framework. Through the MCP server, AI agents can run backtests, import candles, read/write strategies, and manage configuration via a standardized tool interface. MCP responses include the dashboard URL of the session for direct inspection of charts, trades, and equity curves.
  6. Integrate Jesse MCP with AI Coding Assistants

    Jesse MCP allows you to connect MCP-compatible assistants—such as Claude, Codex, Cursor, VS Code, and Zed—directly to your local Jesse trading project. Once connected, the assistant can interact with strategies and candles, execute backtests, optimize parameters, perform significance tests and Monte Carlo analysis, and provide links to saved dashboard results.
  7. Use the Jesse research module for programmatic analysis

    The research module in Jesse provides a collection of features—typically accessed via the GUI dashboard—as functions. These functions allow developers to perform research and analysis within custom Python scripts or Jupyter Notebooks.
    from jesse import research
  8. Optimize strategy hyperparameters in Jesse

    The optimize mode in Jesse allows developers to tune strategy parameters (hyperparameters) to find combinations that maximize performance. It uses Optuna for hyperparameter optimization and Ray for parallel processing, enabling a more efficient search of the parameter space compared to random or grid search methods.
  9. Prevent strategy overfitting using Monte Carlo analysis

    Monte Carlo analysis helps determine if a strategy's performance is due to skill or luck by running simulations across alternate market scenarios and shuffled trade sequences. If the original backtest is an outlier compared to simulations, the strategy is likely overfitted to specific historical price moves or timing.

    Jesse provides two methods:

    1. Trade-Order Shuffling (monte_carlo_trades): Tests if the timing of trades affects performance.
    2. Candles-Based (monte_carlo_candles): Tests robustness across different market conditions by modifying candle data.

    Note: Plotting scenario distributions or equity curves requires the matplotlib package.

    pip install matplotlib
  10. Understand the Bootstrap Significance Test methodology

    The Bootstrap Significance Test determines if a trading rule's average next-bar detrended return is statistically greater than zero. It builds a null distribution by resampling the rule's own return series thousands of times to measure how often a zero-edge resample outperforms the actual observed result.

    Key Characteristics:

    • No Normality Assumption: It resamples the empirical return distribution directly, accounting for heavy-tailed financial returns.
    • Time-Series Aware: It uses a stationary bootstrap (Politis and Romano) that preserves short-run serial dependence by resampling contiguous blocks rather than individual bars.
    • Null Hypothesis: The test assumes the rule has no edge (expected return = 0).
  11. Understand differences between Traditional Markets and Crypto in Jesse

    Jesse is primarily a crypto framework, but supports traditional markets (stocks, forex, indices, and futures) with the following key differences:

    • Data Sourcing: Unlike crypto, where candles come from the exchange, traditional market candles come from a separate data provider (e.g., Massive or Custom CSV files). The provider is treated as the 'exchange' during import and backtesting.
    • Gapped Data: Traditional markets have closures (nights, weekends, holidays). Jesse does not invent candles to fill these gaps; it only stores observed bars. This affects how timeframes are built and how backtests are executed.
    • Simulation Models: Since data providers are not trading venues, you must manually select a Simulation Model (e.g., spot or perpetual futures with leverage) and a Trading Fee in the session's exchange settings.
    • Annualization: Performance metrics (Sharpe, Sortino, Omega, and annual return) are annualized based on 252 trading days instead of 365.
    • Live Trading: Currently supported via crypto exchanges that offer tokenized traditional instruments. Direct traditional broker integration (e.g., Alpaca) is under development.