Skip to content

Commit

Permalink
refactor strategy runner to mirror c++ version
Browse files Browse the repository at this point in the history
  • Loading branch information
bsdz committed Mar 29, 2024
1 parent d739ed1 commit 3c446e6
Show file tree
Hide file tree
Showing 10 changed files with 10,163 additions and 10,124 deletions.
17 changes: 8 additions & 9 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -25,10 +25,10 @@ Below is an example usage (the performance of the example strategy won't be good
```python
import pandas as pd

from yabte.backtest import Strategy, StrategyRunner, SimpleOrder, Book
from yabte.utilities.plot.plotly.strategy_runner import plot_strategy_runner
from yabte.utilities.strategy_helpers import crossover
from yabte.backtest import Book, SimpleOrder, Strategy, StrategyRunner
from yabte.tests._helpers import generate_nasdaq_dataset
from yabte.utilities.plot.plotly.strategy_runner import plot_strategy_runner_result
from yabte.utilities.strategy_helpers import crossover


class SMAXO(Strategy):
Expand Down Expand Up @@ -79,18 +79,17 @@ book = Book(name="Main", cash="100000")
sr = StrategyRunner(
data=df_combined,
assets=assets,
strat_classes=[SMAXO],
strategies=[SMAXO()],
books=[book],
)
sr.run()
srr = sr.run()

# see the trades or book history
th = sr.transaction_history
bch = sr.book_history.loc[:, (slice(None), "cash")]
th = srr.transaction_history
bch = srr.book_history.loc[:, (slice(None), "cash")]

# plot the trades against book value
plot_strategy_runner(sr);

plot_strategy_runner_result(srr, sr)
```

![Output from code](https://raw.githubusercontent.com/bsdz/yabte/main/readme_image.png)
Expand Down
252 changes: 136 additions & 116 deletions notebooks/Delta_Hedging.ipynb

Large diffs are not rendered by default.

83 changes: 48 additions & 35 deletions notebooks/Portfolio_Optimization.ipynb

Large diffs are not rendered by default.

Loading

0 comments on commit 3c446e6

Please sign in to comment.