diff --git a/README.md b/README.md index 6c4d2fb48..ae95e9be0 100644 --- a/README.md +++ b/README.md @@ -2,7 +2,7 @@ Lumibot is a backtesting and trading library for stocks, options, crypto, futures and more. It is made so that the same code you use for backtesting can be used for live trading, making it easy to transition from backtesting to live trading. Lumibot is a highly flexible library that allows you to create your own strategies and indicators, and backtest them on historical data. It is also highly optimized for speed, so you can backtest your strategies quickly and efficiently. -**IMPORTANT: This library requires data for backtesting. The recommended data source is Polygon, and you can get an API key at https://polygon.io/?utm_source=affiliate&utm_campaign=lumi10 (a free tier is available too) Please use the full link to give us credit for the sale, it helps support this project. You can use the coupon code 'LUMI10' for 10% off.** +**IMPORTANT: This library requires data for backtesting. The recommended data source is [Polygon.io](https://polygon.io/?utm_source=affiliate&utm_campaign=lumi10) (a free tier is available too). Please click the link to give us credit for the sale, it helps support this project. You can use the coupon code 'LUMI10' for 10% off.** ## Documentation - 👇 Start Here 👇 diff --git a/docs/.buildinfo b/docs/.buildinfo index 062174e44..b06ba5c6d 100644 --- a/docs/.buildinfo +++ b/docs/.buildinfo @@ -1,4 +1,4 @@ # Sphinx build info version 1 # This file hashes the configuration used when building these files. When it is not found, a full rebuild will be done. -config: 889a56d9d3058a1633d681a13410595e +config: a7e3393e95f5c868a7c5563e296474bb tags: 645f666f9bcd5a90fca523b33c5a78b7 diff --git a/docsrc/backtesting.all.rst b/docs/_sources/backtesting.backtest_function.rst.txt similarity index 91% rename from docsrc/backtesting.all.rst rename to docs/_sources/backtesting.backtest_function.rst.txt index 83a5dfe3f..df14d88d3 100644 --- a/docsrc/backtesting.all.rst +++ b/docs/_sources/backtesting.backtest_function.rst.txt @@ -1,4 +1,4 @@ -All Backtesting +Backtesting Function --------------------------- Here is a description of the backtest function and all of its parameters. This is true for any kind of backtesting that you will be doing. diff --git a/docs/_sources/backtesting.backtesting_function.rst.txt b/docs/_sources/backtesting.backtesting_function.rst.txt new file mode 100644 index 000000000..df14d88d3 --- /dev/null +++ b/docs/_sources/backtesting.backtesting_function.rst.txt @@ -0,0 +1,6 @@ +Backtesting Function +--------------------------- + +Here is a description of the backtest function and all of its parameters. This is true for any kind of backtesting that you will be doing. + +.. autofunction:: strategies.strategy.Strategy.backtest \ No newline at end of file diff --git a/docs/_sources/backtesting.indicators_files.rst.txt b/docs/_sources/backtesting.indicators_files.rst.txt new file mode 100644 index 000000000..c448e8b6b --- /dev/null +++ b/docs/_sources/backtesting.indicators_files.rst.txt @@ -0,0 +1,16 @@ +Indicators Files +================ + +The **Indicators HTML** and **Indicators CSV** files contain data on the indicators used in the strategy. These files are unique because they use two key functions: + +- **add_marker()**: Adds markers to the indicators. For more details, refer to `add_marker <../docs/strategy_methods.chart/strategies.strategy.Strategy.add_marker.html>`_. +- **add_line()**: Adds lines to the indicators. For more details, refer to `add_line <../docs/strategy_methods.chart/strategies.strategy.Strategy.add_line.html>`_. + +These functions help in visualizing how the indicators influenced the strategy's decisions and performance. Key information includes: + +- **Indicator Values:** The values of each indicator at different points in time. + +.. figure:: _static/images/indicators_example.png + :alt: Indicators example + :width: 600px + :align: center \ No newline at end of file diff --git a/docs/_sources/backtesting.logs_csv.rst.txt b/docs/_sources/backtesting.logs_csv.rst.txt new file mode 100644 index 000000000..651e51548 --- /dev/null +++ b/docs/_sources/backtesting.logs_csv.rst.txt @@ -0,0 +1,6 @@ +Logs CSV +======== + +The **Logs CSV** file logs all events and actions taken by the strategy during the backtest. It is useful for debugging and understanding the decision-making process of the strategy. + +These files collectively provide a comprehensive view of the backtest, allowing for detailed analysis and refinement of trading strategies. \ No newline at end of file diff --git a/docs/_sources/backtesting.polygon.rst.txt b/docs/_sources/backtesting.polygon.rst.txt index 52dcf7a98..67508094b 100644 --- a/docs/_sources/backtesting.polygon.rst.txt +++ b/docs/_sources/backtesting.polygon.rst.txt @@ -26,6 +26,7 @@ Start by importing the PolygonDataBacktesting, BacktestingBroker and other neces Next, create a strategy class that inherits from the Strategy class. This class will be used to define the strategy that will be backtested. In this example, we will create a simple strategy that buys a stock on the first iteration and holds it until the end of the backtest. The strategy will be initialized with a symbol parameter that will be used to determine which stock to buy. The initialize method will be used to set the sleeptime to 1 day. The on_trading_iteration method will be used to buy the stock on the first iteration. The strategy will be run from 2023-01-01 to 2023-05-01. .. code-block:: python + class MyStrategy(Strategy): parameters = { "symbol": "AAPL", diff --git a/docs/_sources/backtesting.rst.txt b/docs/_sources/backtesting.rst.txt index 523ea31fd..4d263eff8 100644 --- a/docs/_sources/backtesting.rst.txt +++ b/docs/_sources/backtesting.rst.txt @@ -1,19 +1,28 @@ Backtesting ************************ -Lumibot has three modes for backtesting. +Lumibot has three modes for backtesting: -#. Yahoo Backtesting: Daily stock backtesting with data from Yahoo. -#. Pandas Backtesting: Intra-day and inter-day testing of stocks and futures using CSV data supplied by you. -#. Polygon Backtesting: Intra-day and inter-day testing of stocks and futures using Polygon data from polygon.io +1. **Yahoo Backtesting:** Daily stock backtesting with data from Yahoo. +2. **Pandas Backtesting:** Intra-day and inter-day testing of stocks and futures using CSV data supplied by you. +3. **Polygon Backtesting:** Intra-day and inter-day testing of stocks and futures using Polygon data from polygon.io. -It is recommended to use the Yahoo Backtesting for daily stock backtesting, or Polygon Backtesting for intra-day and inter-day testing of stocks, options, crypto and FOREX. Pandas Backtesting is an advanced feature that allows you to test any type of data you have in CSV format but requires more work to setup and is not recommended for most users. +It is recommended to use Yahoo Backtesting for daily stock backtesting, or Polygon Backtesting for intra-day and inter-day testing of stocks, options, crypto, and FOREX. Pandas Backtesting is an advanced feature that allows you to test any type of data you have in CSV format but requires more work to setup and is not recommended for most users. + +Files Generated from Backtesting +================================ + +When you run a backtest, several important files are generated, each prefixed by the strategy name and the date. These files provide detailed insights into the performance and behavior of the strategy. .. toctree:: :maxdepth: 2 :caption: Contents: - backtesting.all + backtesting.tearsheet_html + backtesting.trades_files + backtesting.indicators_files + backtesting.logs_csv + backtesting.backtesting_function backtesting.yahoo backtesting.pandas backtesting.polygon \ No newline at end of file diff --git a/docs/_sources/backtesting.tearsheet_html.rst.txt b/docs/_sources/backtesting.tearsheet_html.rst.txt new file mode 100644 index 000000000..78bfd91a8 --- /dev/null +++ b/docs/_sources/backtesting.tearsheet_html.rst.txt @@ -0,0 +1,36 @@ +Tearsheet HTML +============== + +.. note:: + The **Tearsheet HTML** is one of the most important files generated and is created using the `quantstats-lumi` library. It includes a variety of metrics such as: + +- **Average Annual Return:** The yearly return of the strategy. +- **Total Return:** The overall return from the start to the end of the backtest period. +- **Sharpe Ratio:** A measure of risk-adjusted return. +- **RoMaD (Return over Maximum Drawdown):** A ratio that compares return to the maximum drawdown. +- **Sortino Ratio:** A variation of the Sharpe ratio that differentiates harmful volatility from total overall volatility. +- **Max Drawdown:** The maximum observed loss from a peak to a trough of a portfolio, before a new peak is attained. +- **Longest Drawdown Duration:** The longest period during which the portfolio has not reached a new peak. + +These metrics are accompanied by various graphs such as: + +- **Cumulative Returns vs Benchmark:** Shows the strategy's cumulative returns compared to a benchmark. +- **Cumulative Returns (Log Scaled):** A log-scaled version of cumulative returns for better visualization of exponential growth. + +.. figure:: _static/images/tearsheet_condor_martingale.png + :alt: Tearsheet example 1 + :width: 600px + :align: center + +.. figure:: _static/images/tearsheet_crypto_bbands_v2.png + :alt: Tearsheet example 2 + :width: 600px + :align: center + +.. important:: + These tearsheets showcase different strategies we offer. Each strategy is tailored to achieve specific goals: + + - **Condor Martingale Strategy:** Creates an Iron Condor with a defined delta, adjusting quantities based on previous performance. It uses a 1 DTE Iron Condor expiring daily. + - **Crypto BBands v2 Strategy:** Uses Bollinger Bands and exponential moving averages to determine buy and sell points. + + Interested in implementing these strategies? Visit our website at `Lumiwealth `_ to access the code and start optimizing your investments. For any questions, email us at support@lumiwealth.com. \ No newline at end of file diff --git a/docs/_sources/backtesting.trades_files.rst.txt b/docs/_sources/backtesting.trades_files.rst.txt new file mode 100644 index 000000000..96b1c1096 --- /dev/null +++ b/docs/_sources/backtesting.trades_files.rst.txt @@ -0,0 +1,13 @@ +Trades Files +============ + +The **Trades HTML** and **Trades CSV** files provide detailed information about each trade executed by the strategy. This includes: + +- **Buy and Sell Orders:** The times and prices at which buy or sell orders were placed, along with the asset involved (e.g., option strike price or stock ticker). +- **Portfolio Value:** The value of the portfolio at each time point. +- **Cash:** The amount of cash available at each time point. + +.. figure:: _static/images/trades_example.png + :alt: Trades example + :width: 600px + :align: center \ No newline at end of file diff --git a/docs/_static/custom.css b/docs/_static/custom.css index d4e532dc5..2f4d05f8f 100644 --- a/docs/_static/custom.css +++ b/docs/_static/custom.css @@ -36,7 +36,15 @@ margin-bottom: 60px; } -.footer-banner { +/* Ensure the sidebar and other elements have padding/margin to avoid overlap */ +.sidebar-scroll { + padding-bottom: 150px; /* Adjust according to footer height */ +} +.content { + margin-bottom: 150px; /* Adjust according to footer height */ +} + +.announcement { position: fixed; bottom: 0; left: 0; @@ -47,25 +55,62 @@ flex-direction: column; align-items: center; text-align: center; + height: 90px; /* Default height for larger devices */ + overflow-x: hidden; /* Prevent horizontal overflow */ + box-sizing: border-box; /* Ensure padding is included in width */ +} + +/* Media query for very small devices */ +@media (max-width: 480px) { + .announcement { + height: 120px; /* Override height for very small devices */ + } +} + +.announcement-content { + padding: 0; + height: 90px; + width: 100%; + box-sizing: border-box; /* Ensure padding is included in width */ +} + +/* Media query for very small devices */ +@media (max-width: 480px) { + .announcement-content { + height: 120px; /* Override height for very small devices */ + } +} + +.footer-banner { + height: 100%; + width: 100%; + box-sizing: border-box; /* Ensure padding is included in width */ } .footer-banner h5 { margin: 0; + width: 100%; + box-sizing: border-box; /* Ensure padding is included in width */ } .footer-banner p { margin: 0; word-wrap: break-word; + word-break: break-word; /* Add this for better word breaking */ padding: 0 15px; /* Add padding for better text wrapping */ + width: 100%; + box-sizing: border-box; /* Ensure padding is included in width */ } .footer-banner a { text-decoration: underline; + width: 100%; + box-sizing: border-box; /* Ensure padding is included in width */ } -@media (max-width: 768px) { +@media (max-width: 480px) { .footer-banner p { - padding: 0 10px; + padding: 0 10px; /* Adjust padding for smaller screens */ white-space: normal; /* Ensure text wraps on small screens */ } } \ No newline at end of file diff --git a/docs/_static/images/indicators_example.png b/docs/_static/images/indicators_example.png new file mode 100644 index 000000000..a789ccf97 Binary files /dev/null and b/docs/_static/images/indicators_example.png differ diff --git a/docs/_static/images/tearsheet_condor_martingale.png b/docs/_static/images/tearsheet_condor_martingale.png new file mode 100644 index 000000000..125e9e184 Binary files /dev/null and b/docs/_static/images/tearsheet_condor_martingale.png differ diff --git a/docs/_static/images/tearsheet_crypto_bbands_v2.png b/docs/_static/images/tearsheet_crypto_bbands_v2.png new file mode 100644 index 000000000..b06820950 Binary files /dev/null and b/docs/_static/images/tearsheet_crypto_bbands_v2.png differ diff --git a/docs/_static/images/trades_example.png b/docs/_static/images/trades_example.png new file mode 100644 index 000000000..7cd3e6a84 Binary files /dev/null and b/docs/_static/images/trades_example.png differ diff --git a/docs/backtesting.all.html b/docs/backtesting.all.html index 8b776db3b..d3c7ed42f 100644 --- a/docs/backtesting.all.html +++ b/docs/backtesting.all.html @@ -3,14 +3,14 @@ - + - All Backtesting - Lumibot: Algorithmic Trading and Backtesting Library Documentation + All Backtesting - Lumibot Documentation - + @@ -134,7 +134,7 @@
Need Extra Help?
-
Lumibot: Algorithmic Trading and Backtesting Library Documentation
+
Lumibot Documentation
@@ -297,6 +297,10 @@
Need Extra Help?
  • Backtesting
  • @@ -145,7 +145,7 @@
    Need Extra Help?
    -
    -