Frequency of price movement
Author: pceberle
Creation Date: 12/29/2019 4:24 PM
profile picture

pceberle

#1
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
profile picture

Eugene

#2
Here's a quick sample:

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

superticker

#3
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.
profile picture

Eugene

#4
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?
profile picture

Eugene

#5
Something like this:

profile picture

superticker

#6
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.
profile picture

Eugene

#7
Thanks for your input.
QUOTE:
The plot is missing the 0% bin. I'm assuming that's intentional;

You're right, it is.
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).