Skip to content

Commit

Permalink
MNT: Adapt examples for updated jupytext behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
kernc committed Mar 1, 2019
1 parent 76465a4 commit a7d1d4f
Show file tree
Hide file tree
Showing 5 changed files with 15 additions and 5 deletions.
4 changes: 3 additions & 1 deletion doc/examples/Multiple Time Frames.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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:
Expand Down
4 changes: 3 additions & 1 deletion doc/examples/Parameter Heatmap.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down
6 changes: 5 additions & 1 deletion doc/examples/Quick Start User Guide.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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.
Expand Down Expand Up @@ -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
Expand Down
4 changes: 3 additions & 1 deletion doc/examples/Strategies Library.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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**.
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@
extras_require={
'doc': [
'pdoc3',
'jupytext >= 0.7.0',
'jupytext >= 1.0.2',
'nbconvert',
'ipykernel', # for nbconvert
'jupyter_client', # for nbconvert
Expand Down

0 comments on commit a7d1d4f

Please sign in to comment.