Skip to main content
2 of 3
edited tags
whuber
  • 333.6k
  • 63
  • 792
  • 1.3k

How to normalize price history between -1 and 1 while keeping the ratio of price differences to each other the same?

I want to normalize a series of numbers to all be between -1 and 1 but I would like to do it in a way where the relative difference between price elements stays the same, if possible.

Example list of price series
price_list = np.array([4.8, 7.2, 5.0, 8.1])

I use this equation to normalize between -1 and 1.
(2*(price_list - min(price_list)) / (max(price_list) - min(price_list)))-1
This returns
array([-1. , 0.45454545, -0.87878788, 1. ])

Let's take the ratio between the 0th and 1st non-normalized values.
4.8 / 7.2 = 0.6666666666666666
But the ratio of the 0th and 1st elements in the normalized list is -1 / 0.45454545 = -2.200000022

I would like the data normalized between -1 and 1 in a way that the ratio is also 0.6666666666666666.