Skip to content

Commit

Permalink
Merge pull request #487 from Lumiwealth/dev
Browse files Browse the repository at this point in the history
docs updatee
  • Loading branch information
grzesir authored Jul 7, 2024
2 parents eb9b121 + 004dd84 commit b954c8e
Show file tree
Hide file tree
Showing 324 changed files with 7,590 additions and 1,460 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -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 👇

Expand Down
2 changes: 1 addition & 1 deletion docs/.buildinfo
Original file line number Diff line number Diff line change
@@ -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
Original file line number Diff line number Diff line change
@@ -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.
Expand Down
6 changes: 6 additions & 0 deletions docs/_sources/backtesting.backtesting_function.rst.txt
Original file line number Diff line number Diff line change
@@ -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
16 changes: 16 additions & 0 deletions docs/_sources/backtesting.indicators_files.rst.txt
Original file line number Diff line number Diff line change
@@ -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
6 changes: 6 additions & 0 deletions docs/_sources/backtesting.logs_csv.rst.txt
Original file line number Diff line number Diff line change
@@ -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.
1 change: 1 addition & 0 deletions docs/_sources/backtesting.polygon.rst.txt
Original file line number Diff line number Diff line change
Expand Up @@ -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",
Expand Down
21 changes: 15 additions & 6 deletions docs/_sources/backtesting.rst.txt
Original file line number Diff line number Diff line change
@@ -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
36 changes: 36 additions & 0 deletions docs/_sources/backtesting.tearsheet_html.rst.txt
Original file line number Diff line number Diff line change
@@ -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 <https://www.lumiwealth.com/?utm_source=documentation&utm_medium=referral&utm_campaign=lumibot_backtesting_section>`_ to access the code and start optimizing your investments. For any questions, email us at [email protected].
13 changes: 13 additions & 0 deletions docs/_sources/backtesting.trades_files.rst.txt
Original file line number Diff line number Diff line change
@@ -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
51 changes: 48 additions & 3 deletions docs/_static/custom.css
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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 */
}
}
Binary file added docs/_static/images/indicators_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added docs/_static/images/trades_example.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
16 changes: 10 additions & 6 deletions docs/backtesting.all.html
Original file line number Diff line number Diff line change
Expand Up @@ -3,14 +3,14 @@
<head><meta charset="utf-8"/>
<meta name="viewport" content="width=device-width,initial-scale=1"/>
<meta name="color-scheme" content="light dark"><meta name="viewport" content="width=device-width, initial-scale=1" />
<link rel="index" title="Index" href="genindex.html" /><link rel="search" title="Search" href="search.html" /><link rel="next" title="Yahoo" href="backtesting.yahoo.html" /><link rel="prev" title="Backtesting" href="backtesting.html" />
<link rel="index" title="Index" href="genindex.html" /><link rel="search" title="Search" href="search.html" /><link rel="next" title="Yahoo" href="backtesting.yahoo.html" /><link rel="prev" title="Logs CSV" href="backtesting.logs_csv.html" />

<!-- Generated with Sphinx 7.2.6 and Furo 2024.01.29 -->
<title>All Backtesting - Lumibot: Algorithmic Trading and Backtesting Library Documentation</title>
<title>All Backtesting - Lumibot Documentation</title>
<link rel="stylesheet" type="text/css" href="_static/pygments.css?v=a746c00c" />
<link rel="stylesheet" type="text/css" href="_static/styles/furo.css?v=135e06be" />
<link rel="stylesheet" type="text/css" href="_static/styles/furo-extensions.css?v=36a5483c" />
<link rel="stylesheet" type="text/css" href="_static/custom.css?v=8fc1b8d9" />
<link rel="stylesheet" type="text/css" href="_static/custom.css?v=3791830b" />
<link rel="stylesheet" type="text/css" href="_static/bootstrap/css/bootstrap.css?v=7edfbd0b" />


Expand Down Expand Up @@ -134,7 +134,7 @@ <h5>Need Extra Help?</h5>
</label>
</div>
<div class="header-center">
<a href="index.html"><div class="brand">Lumibot: Algorithmic Trading and Backtesting Library Documentation</div></a>
<a href="index.html"><div class="brand">Lumibot Documentation</div></a>
</div>
<div class="header-right">
<div class="theme-toggle-container theme-toggle-header">
Expand Down Expand Up @@ -297,6 +297,10 @@ <h5>Need Extra Help?</h5>
</ul>
</li>
<li class="toctree-l1 current has-children"><a class="reference internal" href="backtesting.html">Backtesting</a><input checked="" class="toctree-checkbox" id="toctree-checkbox-12" name="toctree-checkbox-12" role="switch" type="checkbox"/><label for="toctree-checkbox-12"><div class="visually-hidden">Toggle navigation of Backtesting</div><i class="icon"><svg><use href="#svg-arrow-right"></use></svg></i></label><ul class="current">
<li class="toctree-l2"><a class="reference internal" href="backtesting.tearsheet_html.html">Tearsheet HTML</a></li>
<li class="toctree-l2"><a class="reference internal" href="backtesting.trades_files.html">Trades Files</a></li>
<li class="toctree-l2"><a class="reference internal" href="backtesting.indicators_files.html">Indicators Files</a></li>
<li class="toctree-l2"><a class="reference internal" href="backtesting.logs_csv.html">Logs CSV</a></li>
<li class="toctree-l2 current current-page"><a class="current reference internal" href="#">All Backtesting</a></li>
<li class="toctree-l2"><a class="reference internal" href="backtesting.yahoo.html">Yahoo</a></li>
<li class="toctree-l2"><a class="reference internal" href="backtesting.pandas.html">Pandas (CSV or other data)</a></li>
Expand Down Expand Up @@ -458,14 +462,14 @@ <h1>All Backtesting<a class="headerlink" href="#all-backtesting" title="Link to
</div>
<svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg>
</a>
<a class="prev-page" href="backtesting.html">
<a class="prev-page" href="backtesting.logs_csv.html">
<svg class="furo-related-icon"><use href="#svg-arrow-right"></use></svg>
<div class="page-info">
<div class="context">
<span>Previous</span>
</div>

<div class="title">Backtesting</div>
<div class="title">Logs CSV</div>

</div>
</a>
Expand Down
Loading

0 comments on commit b954c8e

Please sign in to comment.