From a7d1d4f3fa658290182dfa2fdbf69bffe6a8f018 Mon Sep 17 00:00:00 2001 From: Kernc Date: Fri, 1 Mar 2019 17:27:27 +0100 Subject: [PATCH] MNT: Adapt examples for updated jupytext behavior --- doc/examples/Multiple Time Frames.py | 4 +++- doc/examples/Parameter Heatmap.py | 4 +++- doc/examples/Quick Start User Guide.py | 6 +++++- doc/examples/Strategies Library.py | 4 +++- setup.py | 2 +- 5 files changed, 15 insertions(+), 5 deletions(-) diff --git a/doc/examples/Multiple Time Frames.py b/doc/examples/Multiple Time Frames.py index 8a933489..59fb4ea5 100644 --- a/doc/examples/Multiple Time Frames.py +++ b/doc/examples/Multiple Time Frames.py @@ -5,7 +5,7 @@ # extension: .py # format_name: light # format_version: '1.3' -# jupytext_version: 0.8.6 +# jupytext_version: 1.0.2 # kernelspec: # display_name: Python 3 # language: python @@ -51,6 +51,8 @@ def RSI(array, n): loss[loss > 0] = 0 rs = gain.ewm(n).mean() / loss.abs().ewm(n).mean() return 100 - 100 / (1 + rs) + + # - # The strategy roughly goes like this: diff --git a/doc/examples/Parameter Heatmap.py b/doc/examples/Parameter Heatmap.py index 494da05c..b505955a 100644 --- a/doc/examples/Parameter Heatmap.py +++ b/doc/examples/Parameter Heatmap.py @@ -6,7 +6,7 @@ # extension: .py # format_name: light # format_version: '1.3' -# jupytext_version: 0.8.6 +# jupytext_version: 1.0.2 # kernelspec: # display_name: Python 3 # language: python @@ -83,6 +83,8 @@ def next(self): crossover(self.data.Close, self.sma_exit)): self.position.close() + + # - # It's not a robust strategy, but we can optimize it. Let's optimize our strategy on Google stock data. diff --git a/doc/examples/Quick Start User Guide.py b/doc/examples/Quick Start User Guide.py index b6c689e6..8d29c3b6 100644 --- a/doc/examples/Quick Start User Guide.py +++ b/doc/examples/Quick Start User Guide.py @@ -6,7 +6,7 @@ # extension: .py # format_name: light # format_version: '1.3' -# jupytext_version: 0.8.6 +# jupytext_version: 1.0.2 # kernelspec: # display_name: Python 3 # language: python @@ -58,6 +58,8 @@ def SMA(values, n): each step taking into account `n` previous values. """ return pd.Series(values).rolling(n).mean() + + # - # Note, this is the exact same helper function as the one used in the project unit tests, so we could just import that instead. @@ -99,6 +101,8 @@ def next(self): # Else, if sma1 crosses below sma2, sell it elif crossover(self.sma2, self.sma1): self.sell() + + # - # In `init()` as well as in `next()`, the data the strategy is simulated on is available as an instance variable diff --git a/doc/examples/Strategies Library.py b/doc/examples/Strategies Library.py index 04c79659..2914622a 100644 --- a/doc/examples/Strategies Library.py +++ b/doc/examples/Strategies Library.py @@ -5,7 +5,7 @@ # extension: .py # format_name: light # format_version: '1.3' -# jupytext_version: 0.8.6 +# jupytext_version: 1.0.2 # kernelspec: # display_name: Python 3 # language: python @@ -79,6 +79,8 @@ def init(self): # Set trailing stop-loss to 4x ATR # using the method provided by TrailingStrategy self.set_trailing_sl(4) + + # - # Note, since the strategies in _lib_ may require their own intialization and next-tick logic, be sure to **always call `super().init()` and `super().next()` in your overridden methods**. diff --git a/setup.py b/setup.py index a48f4afb..7bfa54c8 100644 --- a/setup.py +++ b/setup.py @@ -38,7 +38,7 @@ extras_require={ 'doc': [ 'pdoc3', - 'jupytext >= 0.7.0', + 'jupytext >= 1.0.2', 'nbconvert', 'ipykernel', # for nbconvert 'jupyter_client', # for nbconvert