algorithmic trading - Algorithm to calculate the price volatility of a commodity -




i trying design algorithm calculate how volatile price fluctuations of commodity are.

the way work if price of commodity goes , down, should have higher score if price of commodity gradually increases , falls in price rapidly.

here example of mean:

commodity a: 1 -> 2 -> 3 -> 2 -> 1 -> 3 -> 4 -> 2 -> 1

commodity b: 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 2

commodity c: 1 -> 2 -> 3 -> 4 -> 5 -> 4 -> 3 -> 2-> 1

commodity has 'wave' pattern in price goes , falls down on regular basis.

commodity b has 'cliff' pattern in price goes gradually , falls steeply.

commodity c has 'hill' pattern in price rises gradually , falls gradually.

a should receive highest ranking, followed c, followed b. more of wave pattern price of commodity follows, higher ranking should have.

does have suggestions algorithm this?

thanks!

my approach looks this.

for algorithm, considering above example.

a: 1 -> 2 -> 3 -> 2 -> 1 -> 3 -> 4 -> 2 -> 1  b: 1 -> 2 -> 3 -> 4 -> 5 -> 6 -> 7 -> 8 -> 2  c: 1 -> 2 -> 3 -> 4 -> 5 -> 4 -> 3 -> 2-> 1 

now squash these list, squash mean taking start value , end value of increasing or decreasing sequence.

so, after squashing list this.

a: 1 -> 3 -> 1 -> 4 -> 1 b: 1 -> 8 -> 2 c: 1 -> 5 -> 1 

now once done, take difference between , i+1 element , take average , based on average, give them rank.

so difference between , i+1 element this

      2    2     3      3 a: 1 --> 3 --> 1 --> 4 --> 1          7     6 b: 1 --> 8 --> 2       4      4 c: 1 --> 5 --> 1 

now let's sum difference , take average.

a: (2+2+3+3)/4 = 2.5 b: (7+6)/2 = 6.5 c: (4+4)/2 = 4 

now can assign ranks based on average value

a < c < b 

hope helps!





wiki

Comments

Popular posts from this blog

Asterisk AGI Python Script to Dialplan does not work -

python - Read npy file directly from S3 StreamingBody -

kotlin - Out-projected type in generic interface prohibits the use of metod with generic parameter -