Strategy that pulls bottom (x) stocks with lowest price to sales ratio?
Author: shardis89
Creation Date: 2/7/2011 11:12 PM
profile picture

shardis89

#1
I am new to wealth builder and have not learned to code and the rule based does not facilitate what I am wanting. Is there someone who can provide some code that will pull the bottom (x) number of stock with the lowest price/sales ratio. This would sure be helpful to me.

Regards,

Stephen
profile picture

Eugene

#2
Not sure what Wealth Builder is but in Wealth-Lab, this kind of strategies is accomplished through the process known as rotation. Check out the Symbol Rotation folder, open the "RSI Rotation" strategy, and then modify it according to what this FAQ says:

I need other rotation rule other than the built-in RSI.

Here's an example but note: price_to_sales_ratio must be replaced with the actual fundamental item representing this ratio, if it's available in Fidelity's fundamental data:
CODE:
Please log in to see this code.

Check out the Fundamental Data list (hit Ctrl-U) to find it. (I don't work with WLP and don't remember is it available or not. WLD users with the YCharts fundamental provider would need the item called "[yc] ps_ratio" to use price/sales ratio in their strategies).
profile picture

Cone

#3
Fidelity fundamental ratios are derived from the fundamental items that are available. Price to sales would be accomplished like this:

CODE:
Please log in to see this code.


You can also use the Strategy Builder to drag and drop fundamental ratios. Their derivation will look a little different because it uses a Rules class. If you prefer that method, more info in the WealthScript Language Guide > WealthLab.Rules Classes > FundamentalsRatio
profile picture

shardis89

#4
I appreciate your help. I almost got it to work but kept compiling an error saying it should be a double. Tried coding in a double where int exist and kept getting errors. Too much work, so sure makes me apprciate what you all do.
profile picture

Eugene

#5
If you paste the problematic code snippet here we could try to fix it.
profile picture

Eugene

#6
Also please indicate which Wealth-Lab version and build you are using.
profile picture

shardis89

#7
Wealth Lab Pro 6.1; error states" Error CS0536 @ (11,15) 'WealthLab.Strategies.RSIRotation' does not implement interface member 'System.Collections.Generic.IComparer<WealthLab.Strategies.RSIRotation>.Compare<WealthLabStrategiesRSIRotation,Wealth
profile picture

Eugene

#8
Some other modification was made to the rotation strategy's code. Share the code here so we could check what went wrong.
profile picture

shardis89

#9

CODE:
Please log in to see this code.
profile picture

shardis89

#10
Question I have is once this works will this strategy pull all stocks with the bottom x price/sales ratio or the stocks in my selected dataset?
profile picture

Eugene

#11
There's quite a bit of changes that make no sense like defining the "bar" as double, turning the code into garbage. Let's start over with the "RSI Rotation" strategy.

Replace this:
CODE:
Please log in to see this code.

with what Cone suggested:
CODE:
Please log in to see this code.


Please keep from adding any other breaking changes e.g. public double Compare, thank you.
QUOTE:
Question I have is once this works will this strategy pull all stocks with the bottom x price/sales ratio or the stocks in my selected dataset?

Yes.
profile picture

shardis89

#12
OK, Here is what I get.

error CS0029 @ (68,20): Cannot implicitly convert type 'WealthLab.DataSeries' to 'double'

Here is code
CODE:
Please log in to see this code.
profile picture

Eugene

#13
I'm sorry, Cone's last code line should read as:
CODE:
Please log in to see this code.
This website uses cookies to improve your experience. We'll assume you're ok with that, but you can opt-out if you wish (Read more).