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

Allow different target volatilities for each asset #306

Merged
merged 3 commits into from May 15, 2021

Conversation

danilogalisteu
Copy link
Contributor

@danilogalisteu danilogalisteu commented May 14, 2021

This change allows different target volatilities for each asset, by passing a dict of values instead of a single one.

Fixes #307

MWE:

import bt

data = bt.get(["spy", "qqq", "gld"])

vol_target_dict = {
    "spy": 0.07,
    "qqq": 0.05,
    "gld": 0.03,
}

s = bt.Strategy('s', [bt.algos.RunMonthly(),
                      bt.algos.SelectAll(),
                      bt.algos.WeighInvVol(),
                      bt.algos.TargetVol(vol_target_dict),
                      bt.algos.Rebalance()])

b = bt.Backtest(s, data)
res = bt.run(b)
res.display()
res.plot()
res.plot_security_weights('s')

danilogalisteu and others added 3 commits May 14, 2021 12:46
Allow different target volatilities for each asset, by passing a dict of values instead of a single one.
@codecov-commenter
Copy link

codecov-commenter commented May 15, 2021

Codecov Report

Merging #306 (3fc29d4) into master (03e89d3) will increase coverage by 0.04%.
The diff coverage is 50.00%.

Impacted file tree graph

@@            Coverage Diff             @@
##           master     #306      +/-   ##
==========================================
+ Coverage   46.24%   46.29%   +0.04%     
==========================================
  Files           4        4              
  Lines        1905     1903       -2     
  Branches      375      376       +1     
==========================================
  Hits          881      881              
+ Misses        972      970       -2     
  Partials       52       52              
Impacted Files Coverage Δ
bt/algos.py 85.94% <50.00%> (+0.19%) ⬆️

Continue to review full report at Codecov.

Legend - Click here to learn more
Δ = absolute <relative> (impact), ø = not affected, ? = missing data
Powered by Codecov. Last update 03e89d3...3fc29d4. Read the comment docs.

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

Successfully merging this pull request may close these issues.

Request: allow different target volatility values for each asset in bt.algos.TargetVol
3 participants