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

Example: Zipline with Quandl bundle #64

Open
jankrepl opened this issue Jun 18, 2020 · 6 comments
Open

Example: Zipline with Quandl bundle #64

jankrepl opened this issue Jun 18, 2020 · 6 comments

Comments

@jankrepl
Copy link
Owner

jankrepl commented Jun 18, 2020

Unfortunately installing Zipline is a nightmare, only supports Python 3.5.

So maybe investigate open-source backtesters

@turmeric-blend
Copy link
Contributor

bt is a good choice.

@jankrepl
Copy link
Owner Author

bt is a good choice.

Have you used it? I know there are some others in the Python ecosystem but there does not seem to be a clear-cut winner, or is there?

@turmeric-blend
Copy link
Contributor

I have played around with bt. I think most of the python opensource libraries fall into two categories, individual asset-by-asset backtest (most of them), and portfolio-based backtest. bt so happen to have both (it also accepts weights as model output, unlike many others), but only because it emphasizes modularity/flexibility. At least this is what I can remember from memory.

@jankrepl
Copy link
Owner Author

jankrepl commented Feb 24, 2021

Cool! I might give it a try! It would be nice to create minimalistic example of deepdow +bt:) Anyway, if by any chance you are interested you can also give it a go:)

@turmeric-blend
Copy link
Contributor

I actually tried awhile back but it seems that to utilize bt well, lots of stuff (in terms the workflow towards plotting/visualizing) in the current deepdow library might have to be changed (which you might not want to), from my perspective at least. One example of bt's visualization is that it just plots the backtested portfolio value (Equity Progression), comparing different strategies (eg. s1, s2) and produces a report, like:

Stat                 s1          s2
-------------------  ----------  ----------
Start                2010-01-03  2010-01-03
End                  2017-02-22  2017-02-22
Risk-free rate       0.00%       0.00%

Total Return         81.30%      40.79%
Daily Sharpe         1.19        1.45
Daily Sortino        1.57        2.00
CAGR                 8.69%       4.91%
Max Drawdown         -7.83%      -4.07%
Calmar Ratio         1.11        1.21

MTD                  2.08%       1.56%
3m                   4.08%       2.66%
6m                   3.26%       0.47%
YTD                  3.11%       2.27%
1Y                   12.04%      5.49%
3Y (ann.)            6.82%       3.97%
5Y (ann.)            8.12%       4.02%
10Y (ann.)           8.69%       4.91%
Since Incep. (ann.)  8.69%       4.91%

Daily Sharpe         1.19        1.45
Daily Sortino        1.57        2.00
Daily Mean (ann.)    8.61%       4.85%
Daily Vol (ann.)     7.23%       3.34%
Daily Skew           -0.35       -0.29
Daily Kurt           3.80        2.87
Best Day             2.48%       1.20%
Worst Day            -3.11%      -1.13%

Monthly Sharpe       1.41        1.68
Monthly Sortino      2.61        2.61
Monthly Mean (ann.)  8.61%       5.04%
Monthly Vol (ann.)   6.10%       3.00%
Monthly Skew         0.01        -0.59
Monthly Kurt         0.18        0.03
Best Month           5.69%       1.91%
Worst Month          -3.39%      -2.09%

Yearly Sharpe        1.62        1.61
Yearly Sortino       -           -
Yearly Mean          7.25%       4.08%
Yearly Vol           4.46%       2.53%
Yearly Skew          0.15        -0.45
Yearly Kurt          -0.71       -0.03
Best Year            14.10%      7.02%
Worst Year           1.17%       -0.13%

Avg. Drawdown        -0.79%      -0.40%
Avg. Drawdown Days   13.31       13.28
Avg. Up Month        1.64%       0.83%
Avg. Down Month      -1.27%      -0.69%
Win Year %           100.00%     85.71%
Win 12m %            96.00%      94.67%

So this is different from your current setup whereby you plot the moving metrics (Sharpe, Mean etc). I ended up doing halfway and gave up. I will dig up what I can when I am free and post it here :)

@jankrepl
Copy link
Owner Author

jankrepl commented Mar 1, 2021

Interesting! I guess one major thing that is missing in deepdow is that it is not dynamic - it does not tell you when to change the weights of the portfolio. It is meant to predict an ideal portfolio at a given point in time and then we should buy it and hold it. Of course one can always just recompute a new allocation after each horizon and then adjust your portfolio accordingly.

However, if we start with simple things, backtesting a buy and hold strategy should be trivial in any backtester, right?

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

2 participants