Update some docstrings for pdoc 0.5.0

This commit is contained in:
Kernc
2018-12-09 05:36:54 +01:00
parent b1066f16fb
commit ada98ccbd8
3 changed files with 33 additions and 18 deletions

View File

@@ -3,7 +3,7 @@
## Manuals
* [Quick Start User Guide](../examples/Quick Start User Guide.html)
* [**Quick Start User Guide**](../examples/Quick Start User Guide.html)
## Tutorials
@@ -11,9 +11,11 @@
* [Multiple Time Frames](../examples/Multiple Time Frames.html)
* [Parameter Heatmap](../examples/Parameter Heatmap.html)
You can also [try these out] live.
You can also [try these tutorials out] live.
[try these out]: https://mybinder.org/v2/gh/kernc/backtesting.py/master?urlpath=lab%2Ftree%2Fdoc%2Fexamples
[try these tutorials out]: \
https://mybinder.org/v2/gh/kernc/backtesting.py/master?\
urlpath=lab%2Ftree%2Fdoc%2Fexamples%2FQuick%20Start%20User%20Guide.ipynb
## Example Strategies
@@ -21,10 +23,10 @@ You can also [try these out] live.
## License
This software is licensed under the terms of [AGPL 3.0],
This software is licensed under the terms of [AGPL 3.0]{: rel=license},
meaning you can use it for any reasonable purpose and remain in
complete ownership of all the excellent trading strategies you produce,
but you are also encouraged to make sure any upgrades to `backtesting`
but you are also encouraged to make sure any upgrades to _Backtesting.py_
itself find their way back to the community.
[AGPL 3.0]: https://www.gnu.org/licenses/agpl-3.0.html

View File

@@ -25,9 +25,9 @@ from ._util import _as_str, _Indicator, _Data, _data_period
__pdoc__ = {
'Strategy.__init__': None,
'Orders.__init__': None,
'Position.__init__': None,
'Strategy.__init__': False,
'Orders.__init__': False,
'Position.__init__': False,
}
@@ -723,13 +723,16 @@ class Backtest:
inspected or projected onto 2D to plot a heatmap.
Additional keyword arguments represent strategy arguments with
list-like collections of possible values. For example:
list-like collections of possible values. For example, the following
code finds and returns the "best" of the 7 admissible (of the
9 possible) parameter combinations:
backtest.optimize(sma1=[5, 10, 15], sma2=[10, 20, 40],
constraint=lambda p: p.sma1 < p.sma2)
finds and returns the "best" of the 7 admissible (of the
9 possible) parameter combinations.
.. TODO::
Add parameter `max_tries: Union[int, float] = None` which switches
from exhaustive grid search to random search. See notes in the source.
"""
if not kwargs:
raise ValueError('Need some strategy parameters to optimize')
@@ -910,16 +913,17 @@ class Backtest:
If `results` is proided, it should be a particular result
`pd.Series` such as returned by
`backtesting.backtesting.Backtest.run` or
`backtesting.backtesting.Backtest.optimize`.
`backtesting.backtesting.Backtest.optimize`, otherwise the last
run's results are used.
`filename` is the path to save the interactive HTML plot to.
By default, a strategy/parameter-dependent file is created in the
current working directory.
`plot_width` is the width of the plot in pixels. The height is
currently non-adjustable. FIXME: If someone can make the Bokeh
plot span 100% browser width by default, a contribution would
be appreciated.
currently non-adjustable.
.. TODO:: Make Bokeh plot span 100% browser width by default.
If `plot_equity` is `True`, the resulting plot will contain
an equity (cash plus assets) graph section.
@@ -951,7 +955,8 @@ class Backtest:
[Pandas offset string], such as `'5T'` or `'5min'`.
Note, this only works for data with a datetime index.
[Pandas offset string]: http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases
[Pandas offset string]: \
http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases
If `show_legend` is `True`, the resulting plot graphs will contain
labeled legends.

View File

@@ -145,7 +145,8 @@ def resample_apply(rule: str,
`rule` is a valid [Pandas offset string] indicating
a time frame to resample `series` to.
[Pandas offset string]: http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases
[Pandas offset string]: \
http://pandas.pydata.org/pandas-docs/stable/timeseries.html#offset-aliases
`func` is the indicator function to apply on the resampled series.
@@ -205,6 +206,11 @@ def resample_apply(rule: str,
class SignalStrategy(Strategy):
"""
A simple helper strategy that operates on position entry/exit signals.
This makes the backtest of the strategy simulate a [vectorized backtest].
See [tutorials] for usage examples.
[vectorized backtest]: https://www.google.com/search?q=vectorized+backtest
[tutorials]: index.html#tutorials
To use this helper strategy, subclass it, override its
`backtesting.backtesting.Strategy.init` method,
@@ -259,7 +265,9 @@ class TrailingStrategy(Strategy):
A strategy with automatic trailing stop-loss, trailing the current
price at distance of some multiple of average true range (ATR). Call
`TrailingStrategy.set_trailing_sl()` to set said multiple
(`6` by default).
(`6` by default). See [tutorials] for usage examples.
[tutorials]: index.html#tutorials
Remember to call `super().init()` and `super().next()` in your
overridden methods.