Back to Community
Need Help - Modify Algo to Maintain a Set Percentage of Gold at All Times

I'd like to modify the attached algo to maintain a 20% position in gold (using the 'GLD'
ETF).

Current = Buys 5 stocks and rebalances daily

Proposed = Buys 4 stocks (80% of holdings) and holds GLD (20% of holdings). Maintains this configuration after rebalancing.

Questions:
1) Is this possible? If so I'd like to get actual code modifications or a modified algo if someone is willing as my coding skills aren't real strong.

2) Can someone also help with the following warnings?

Your algorithm uses APIs that have been deprecated in favor of newer, more powerful versions. For more information, go here.
Line 109: Function update_universe is deprecated.
Line 45: Checking whether an asset is in data is deprecated.
Line 36: Checking whether an asset is in data is deprecated.
These deprecated APIs will stop working in the future. Please switch to the new APIs as soon as possible.

I would appreciate specifics or code modifications to fix this if possible.

Thanks,

Troy

Clone Algorithm
4
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 589a85a974375b5e01c73726
There was a runtime error.
2 responses

This is a start. I modified the code to reduce the original weights to 0.8, then added code to buy gold at 25% of the total value of those positions.

Clone Algorithm
2
Loading...
Backtest from to with initial capital
Total Returns
--
Alpha
--
Beta
--
Sharpe
--
Sortino
--
Max Drawdown
--
Benchmark Returns
--
Volatility
--
Returns 1 Month 3 Month 6 Month 12 Month
Alpha 1 Month 3 Month 6 Month 12 Month
Beta 1 Month 3 Month 6 Month 12 Month
Sharpe 1 Month 3 Month 6 Month 12 Month
Sortino 1 Month 3 Month 6 Month 12 Month
Volatility 1 Month 3 Month 6 Month 12 Month
Max Drawdown 1 Month 3 Month 6 Month 12 Month
# Backtest ID: 589a8fcd6051b461ca2acec9
There was a runtime error.

Thanks Frank! I appreciate the help and quick response. That's what I was looking for on Question #1.

Thanks again,

Troy