Skip to content

Instantly share code, notes, and snippets.

@fieldAbyss
Last active August 10, 2018 07:18
Show Gist options
  • Save fieldAbyss/506f2eb9dcd9e6f0323b987ab1ee234e to your computer and use it in GitHub Desktop.
Save fieldAbyss/506f2eb9dcd9e6f0323b987ab1ee234e to your computer and use it in GitHub Desktop.
# RCI
def RCI(seq, itv):
def ord(seq, idx, itv):
p = seq[idx]
o = 1
for i in range(itv - 1):
if p < seq[i]:
o += 1
return o
def d(seq, itv):
sum = 0
for i in range(itv - 1):
sum += pow((i + 1) - ord(seq, i, itv), 2)
return sum
return (1 - 6 * d(seq, itv) / (itv * (itv ** 2 - 1))) * 100
period = 9
rci = RCI(np_close, period)
print(rci)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment