Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

How to get combined strategies of combined strategies working? #415

Open
Pirat83 opened this issue Jun 16, 2023 · 3 comments
Open

How to get combined strategies of combined strategies working? #415

Pirat83 opened this issue Jun 16, 2023 · 3 comments

Comments

@Pirat83
Copy link

Pirat83 commented Jun 16, 2023

BT composite strategies

This repository shows the effect of the issue #415.
For more details see the test_interpreter.py unit test or use the Jupyter notebook example.ipynb

Simple buy and hold strategy:

We create a simple buy and hold strategy with the QQQ.

  • Everything is fine.
  • We have transactions.
  • The backtest works fine.
  • The portfolio gets rebalanced every day.

First level composite strategy

  • Everything is fine.
  • We have transactions.
  • The backtest works fine.
  • The portfolio gets rebalanced every day.

Second level composite strategy

We create a combined strategy containing to combined strategies and one asset.

  • The execution fails with
E   AttributeError: 'Strategy' object has no attribute '_values'

bt/core.py:763: AttributeError

How to get this working?

git clone https://github.com/Pirat83/bt-composite-strategies.git
cd bt-composite-strategies/
conda create --name bt-composite-strategies
conda env update

If you can contribute to the solution I would appreciate it very much.

Pirat83 pushed a commit to Pirat83/bt-composite-strategies that referenced this issue Jun 16, 2023
@Pirat83
Copy link
Author

Pirat83 commented Jun 16, 2023

@Pirat83
Copy link
Author

Pirat83 commented Jun 18, 2023

How to get rid of this error:

_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 
../../../.conda/envs/bt-composite-strategies/lib/python3.11/site-packages/bt/backtest.py:28: in run
    bkt.run()
../../../.conda/envs/bt-composite-strategies/lib/python3.11/site-packages/bt/backtest.py:253: in run
    self.strategy.update(dt)
bt/core.py:732: in bt.core.StrategyBase.update
    ???
bt/core.py:856: in bt.core.StrategyBase.update
    ???
bt/core.py:2144: in bt.core.Strategy.run
    ???
bt/core.py:2140: in bt.core.Strategy.run
    ???
bt/core.py:2079: in bt.core.AlgoStack.__call__
    ???
../../../.conda/envs/bt-composite-strategies/lib/python3.11/site-packages/bt/algos.py:1809: in __call__
    target.root.update(target.now)
bt/core.py:732: in bt.core.StrategyBase.update
    ???
bt/core.py:732: in bt.core.StrategyBase.update
    ???
_ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ _ 

>   ???
E   AttributeError: 'Strategy' object has no attribute '_values'

bt/core.py:763: AttributeError


======================== 1 failed, 4 warnings in 2.36s =========================

Process finished with exit code 1

Thank you very much.

@Pirat83
Copy link
Author

Pirat83 commented Jun 18, 2023

Seems like #333 has similar issues.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant