Include Dollar Cost Averaging Strategy in BT python

I am using bt backtesting to test between an initial lump sum into 'ETH-USD' and a dollar cost average approach. I will then look into a different mix of equally weighted crypto.

What I like about bt is I can get stats including the sharpe ratio and max drawdown after running a backtest. I have this so far:

data = bt.get('ETH-USD', start='2018-01-01')

s2 = bt.Strategy('s2',
[bt.algos.RunMonthly(),
bt.algos.SelectAll(),
bt.algos.CapitalFlow(1000)])

# create a backtest and run it
test = bt.Backtest(s2, data)
res = bt.run(test)


However, I just don't know how to create my own algorithm to invest \$1000 per month. I feel there should be a simple way to do this though.

CapitaFlow Algo requires Rebalance:

the capital will remain in the strategy until a re-allocation/rebalancement is made.

And Rebalance requires Weight if you include it on your strategy you might see the result:

data = bt.get('ETH-USD', start='2018-01-01')

s2 = bt.Strategy('s2',
[bt.algos.RunMonthly(),
bt.algos.SelectAll(),
bt.algos.CapitalFlow(1000),
bt.algos.WeighEqually(),
bt.algos.Rebalance()])

# create a backtest and run it
test = bt.Backtest(s2, data)
res = bt.run(test)


output:

Stat                 s2
-------------------  ----------
Start                2017-12-31
End                  2021-07-18
Risk-free rate       0.00%

Total Return         152.86%
Daily Sharpe         0.64
Daily Sortino        1.04
CAGR                 29.91%
Max Drawdown         -93.95%
Calmar Ratio         0.32

MTD                  -7.45%
3m                   -9.70%
6m                   55.54%
YTD                  165.02%
1Y                   719.83%
3Y (ann.)            60.79%
5Y (ann.)            29.91%
10Y (ann.)           -
Since Incep. (ann.)  29.91%

Daily Sharpe         0.64
Daily Sortino        1.04
Daily Mean (ann.)    53.47%
Daily Vol (ann.)     83.01%
Daily Skew           -0.39
Daily Kurt           5.74
Best Day             25.94%
Worst Day            -42.34%

Monthly Sharpe       0.75
Monthly Sortino      1.84
Monthly Mean (ann.)  88.41%
Monthly Vol (ann.)   117.74%
Monthly Skew         0.49
Monthly Kurt         -0.56
Best Month           78.21%
Worst Month          -55.59%

Yearly Sharpe        0.56
Yearly Sortino       3.35
Yearly Mean          137.07%
Yearly Vol           244.13%
Yearly Skew          1.06
Yearly Kurt          0.43
Best Year            468.90%
Worst Year           -82.73%

Avg. Drawdown        -16.69%
Avg. Drawdown Days   89.71
Avg. Up Month        32.82%
Avg. Down Month      -21.90%
Win Year %           50.00%
Win 12m %            57.58%
​


Regards,