Skip to content

Commit

Permalink
Fixed autodoc settings of result.rst
Browse files Browse the repository at this point in the history
  • Loading branch information
enzbus committed Sep 25, 2023
1 parent d71f5a2 commit f26ff9d
Show file tree
Hide file tree
Showing 2 changed files with 73 additions and 8 deletions.
25 changes: 17 additions & 8 deletions cvxportfolio/result.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,15 @@
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.
"""This module defines :class:`BacktestResult`.
This is the object that is returned by a market simulator's
``backtest`` method. it contains all relevant information from
a backtest and implements the logic to compute various performance metrics,
in addition to a ``plot`` method and a rich ``__repr__`` magic method
(which is called when the user prints the object).
"""


from __future__ import print_function

Expand Down Expand Up @@ -255,12 +264,12 @@ def excess_returns(self):

@property
def average_excess_return(self):
"""The average excess return :math:`\overline{R^\text{e}}`."""
r"""The average excess return :math:`\overline{R^\text{e}}`."""
return np.mean(self.excess_returns)

@property
def annualized_average_excess_return(self):
r"""The average excess return, annualized."""
"""The average excess return, annualized."""
return self.average_excess_return * self.periods_per_year

@property
Expand All @@ -281,9 +290,9 @@ def sharpe_ratio(self):
.. math::
\text{SR} = \overline{\R^\text{e}}/\sigma^\text{e}
\text{SR} = \overline{R^\text{e}}/\sigma^\text{e}
where :math:`\overline{\R^\text{e}}` is the average excess portfolio
where :math:`\overline{R^\text{e}}` is the average excess portfolio
return and :math:`\sigma^\text{e}` its standard deviation. Both are
annualized.
"""
Expand All @@ -293,20 +302,20 @@ def sharpe_ratio(self):
@property
def excess_growth_rates(self):
r"""The growth rate of the portfolio, relative to cash.
This is defined as:
.. math::
G^\text{e}_t = \log(1 + R^\text{e}_t)
where :math:`\R^\text{e}_t` are the excess portfolio returns.
where :math:`R^\text{e}_t` are the excess portfolio returns.
"""
return np.log(self.excess_returns + 1)

@property
def average_excess_growth_rate(self):
"""The average excess growth rate :math:`\overline{G^\text{e}}`."""
r"""The average excess growth rate :math:`\overline{G^\text{e}}`."""
return np.mean(self.excess_growth_rates)

@property
Expand Down
56 changes: 56 additions & 0 deletions docs/result.rst
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,62 @@ Backtests

.. autoclass:: BacktestResult

.. autoproperty:: cash_key

.. autoproperty:: periods_per_year

.. autoproperty:: v

.. autoproperty:: profit

.. autoproperty:: w

.. autoproperty:: h_plus

.. autoproperty:: w_plus

.. autoproperty:: leverage

.. autoproperty:: turnover

.. autoproperty:: returns

.. autoproperty:: average_return

.. autoproperty:: annualized_average_return

.. autoproperty:: growth_rates

.. autoproperty:: average_growth_rate

.. autoproperty:: annualized_average_growth_rate

.. autoproperty:: volatility

.. autoproperty:: annualized_volatility

.. autoproperty:: quadratic_risk

.. autoproperty:: annualized_quadratic_risk

.. autoproperty:: excess_returns

.. autoproperty:: average_excess_return

.. autoproperty:: annualized_average_excess_return

.. autoproperty:: annualized_excess_volatility

.. autoproperty:: sharpe_ratio

.. autoproperty:: excess_growth_rates

.. autoproperty:: average_excess_growth_rate

.. autoproperty:: annualized_average_excess_growth_rate

.. autoproperty:: drawdown

.. automethod:: plot


0 comments on commit f26ff9d

Please sign in to comment.