Back to Community
ETF 20 - Ranked by 10-Year Percent Change

Hi Quantopian Community!!

I took the top 20 stocks according to the ''Barcharts Stocks - Ranked by 10-Year Percent Change''

To remember:

You will have to apply a system that will add/remove stocks each year so you will remain with the top 20 stocks. (Currently not applied)

Please feel free to critique this system - I would like to know if you have any other ideas on how such a system can be run or modified.

Thank you in advance for any assistance.

Regards
Alex

Clone Algorithm
58
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: 541ff36245849d08a1d66f09
There was a runtime error.
7 responses

Hi Alex,

This algorithm is the very definition of look-ahead bias, which in words is defined as:

Bias created by the use of information or data in a study or
simulation that would not have been known or available during the
period being analyzed. This will usually lead to inaccurate results in
the study or simulation.

Unless you have a way of time travelling, you just can't use information from 10 years in the future to pick a basket of stocks. What would be interesting is to pick the top stocks as of 2002 and see what the return on them is going into the future. I did a quick and dirty take, using the "top stocks of 2002" and following them to the present. Somewhat surprisingly, at first blush it seems to have promise. You could try "rebalancing" based on the top stocks each year (after the year closes) and seeing if these results hold true in general or if 2002 was somehow unique. Also, I think the algo needs to handle stocks that go out of business.

Clone Algorithm
7
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: 5421e5513b2cdf08e18c0418
There was a runtime error.

Oops, wasn't re-balancing because once a security stopped trading the order just stayed unfilled preventing any other orders from happening. Fixed that plus as securities drop out target percentages are now adjusted.

Clone Algorithm
32
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: 5421f267cc3cb908e81e6031
There was a runtime error.

Hi Alan thanks for the info and fix!! This looks quite promising to me! I am still new to coding, you have just saved me a tremendous amount of time. Then what do you think about this strategy? Do you think it will be viable? Something that will be better for the longer term investor? If you are looking to run this for 30 years plus? I have been trading a similar strategy(I take the close of the year end of FEB as this is most of the companies Financial year end's here in SA then I remove the stocks that have fallen and add the new top ten entries) (can only afford to buy the top 10 right now) but on the top movers from the JSE (South African Exchange) for the past 2 years, but I have recently been wondering if I am on the right track. I am a student and I am busy getting enough data so I can Include it in my Thesis. I wanted to use a real life example rather than just a fictitious one, that is why I started investing with real money - I have a back-test on some data I received from a trader here but the accuracy of the data bothers me so I basically wanted to add about 3 years worth of real data.

I dont want to be to forward but my very poor attempts to change the algo have all failed... Is there anybody that could somehow add a function to this last algo that can take the data from (Barchart or anyone else) and take the top 20 best performing stocks each year from 2002 until now re-balancing each year with the new top 20?? I am in the process of learning more about programming but it may take me a good few months... lol

look ahead bias is one, but in such strategies, make sure you handle properly the following:
- survivorship bias: tendency to exclude failed or delisted companies during a simulation (because they are not part of your dataset, or because you based you analysis on stocks currently in SP-500 for example)
- invest only if enough liquidity

@Alexander is this leverage? how to remove.. the leverage part... thanks...

@Alan how to make this into symbols...? context=symbols does not work.... thanks...

13 Error SyntaxError: invalid syntax

context.stocks = symbols('SWHC':0.05,
'FIZZ':0.05, 'AMZN':0.05, 'HPY':0.05, 'ATVI':0.05, 'DYAX':0.05, 'STMP':0.05, 'NFLX':0.05, 'SMED':0.05, 'COKE':0.05, 'ABMD':0.05, 'OLED':0.05, 'NTES':0.05, 'NEO':0.05, 'CTRP':0.05, 'HRL':0.05, 'SLP':0.05, 'AYI':0.05, 'TYL':0.05,

)