Ranking System
I appreciate your help in properly using the QuantShare %u201Cend to end%u201D with a Ranking system.
My objective is the %u201Ccode%u201D the system as follows, as I created a simple rule to test
Start with list of 10 stocks.
Rule1 %u2013 buy the stock with the highest % change in the last X days (x=variable to optimize).
- Rocp(close,x) // where X is to be tested
Create Ranking System with the above Rule1, such that 10 equally distributed buckets are created, and
the top bucket contains the stock with the highest value rate of change.
Create Trading System using the Ranking System, with the following execution procedures:
- Buy 1 stock in top bucket.
- Hold the 1 stock as long as it is either the top 1 or 2 buckets.
- Sell the stock, at the close, of the day where it is no longer in the top 1 or 2 buckets.
- Buy the top ranked stock, filling the open slot.
- Shorting rules reverse the above, shorting the stock in the lowest bucket, etc.
Create report output, showing the:
- Daily bucket ranking values of each stock (not just those traded - to validated system ranking procedures)
- Net long and short equity $ values of the trading system each day.
I after executed some of the simpler steps (like creating the ranking rule), but I am not able to properly translate it into a trading system test.
Additionally, I can figure out how to validate the ranking rules are being implemented as intended.
After that is working, I can share back my results to help other get the idea.
Next, I will want to test using masked rules around the optimization and neural nets, etc.
When applied to a trading strategy, the ranking system allows you to prioritize stocks so that the strategy knows which stocks to buy/short first. It also allows you to buy/short only stocks with a ranking score that is higher than a specific threshold. Currently you cannot use the ranking system in the sell/cover rules. However, we created in the next version (will be released in the current week), a new function called "composite".
- Buy 1 stock in top bucket.
comp(Roc(close,x), "percentile") > 90
- Hold the 1 stock as long as it is either the top 1 or 2 buckets.
Sell when: comp(Roc(close,x), "percentile") < 80
- Buy the top ranked stock, filling the open slot.
Set the "number of positions" to one and use simply the ranking system you have created
Or you can replace the first composite function and set the following buy rule:
comp(Roc(close,x), "rank") == 1 // Buys only the first stock
To short only the first stock, you can use the following formula:
comp(-Roc(close,x), "rank") == 1
- Report output:
To get the bucket ranking values of each stock for a particular date, you can use the screener:
For example, choose a date, and add two columns:
AddColumn("Rank", comp(Roc(close,10), "rank"))
AddColumn("Roc", Roc(close,10))
Trading financial instruments, including foreign exchange on margin, carries a high level of risk and is not suitable for all investors. The high degree of leverage can work against you as well as for you. Before deciding to invest in financial instruments or foreign exchange you should carefully consider your investment objectives, level of experience, and risk appetite. The possibility exists that you could sustain a loss of some or all of your initial investment and therefore you should not invest money that you cannot afford to lose. You should be aware of all the risks associated with trading and seek advice from an independent financial advisor if you have any doubts.