For a risk management project I am trying to determine the frequency of price movement within NASDAQ 100 and S&P 500 stocks. How often do the individual components have 10%, 20%, 30%, 40%, 50% daily moves
Size:
Color:
Here's a quick sample:
CODE:
Please log in to see this code.
Size:
Color:
If you want to create a histogram or a single composite number (factor) from all the frequency counts, then you can collect all the frequencies for all the percentages at once like this:
CODE:
Please log in to see this code.
Probably computing a
single composite "factor" from the cntBins frequency vector makes the most sense depending on where you're going with this. I haven't tried this code, so be prepared to make some fine adjustments [e.g. substitute round() for (int)]. Happy coding.
Size:
Color:
To expand on the creation of a histogram, with some coding effort it could be rendered in a fancy way right on the Wealth-Lab chart by using this
design pattern. The question is where the frequency of price movement is taking us. How do we use it in a trading strategy?
Size:
Color:
Something like this:
Size:
Color:
Thanks for the nice example. In the production code, I would make the histogram postage stamp size since only it's shape is important for risk assessment.
The plot is missing the 0% bin. I'm assuming that's intentional; otherwise, the plot would run off the screen. :(
I'm not sure how to best handle that problem either.... Perhaps plotting the log10(frequency) instead would work.
My only suggestion would be to employ a non-compressed format (such as *.bmp) for the "internal image" since the GPU processor can't really decompress a *.png image on its own (The png format employs Laplacian pyramid compression). If your workstation needs more memory chips for handling a non-compressed image, buy them since memory is cheap.
CODE:
Please log in to see this code.
Size:
Color:
Thanks for your input.
QUOTE:
The plot is missing the 0% bin. I'm assuming that's intentional;
You're right, it is.
Size:
Color: