Back to Community
Getting top 10% of traded stocks

I am trying to create an algorithm where I iterate through the top 10% of all traded stocks and buy the one with least volatility and short the one with most. I have taken care of writing the algorithm. My problem is that I am having trouble iterating through each stock. When I iterate through the stocks, I do not get the correct ticker symbol to place a trade. Can someone help me? I have attached my code.

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: 570bf3e4ce42640f33e072b1
There was a runtime error.
2 responses

You have a typo on line 163... should be stockList not stockLst

Fix it and it will trade :)

I fixed that and it still does not trade. Any suggestions?

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: 570c021f86387d0f3bf2c5f1
There was a runtime error.