Вот что я пытаюсь сделать вычислить:
Код: Выделить всё
r_[t,i] = Y_[t,i] - Y_[t,i-1]
Я использую первое соотношение здесь, где r означает доход, а Y цены акций
Код: Выделить всё
t = 10 # daily intervals
i = 30 # number of days
s = 1
# (Here I've just created some fake numbers, intending to simulate some stock prices)
Y = abs(np.random.random((10,30)) + 1)
# initializing my return array
return = np.array([])
# (I also tried to initialize it as a Matrix before..) :
return = np.zeros((10,30))
# here is my for loop to store each daily return at its position on the "return" Array. I wanted an Array but got just "() size"
for t in range(0,9):
for i in range(1,29):
return = np.array( Y.item((t,i)) - Y.item((t,i-1)) )
Код: Выделить всё
return = [first difference, second difference, third difference...]
Подробнее здесь: https://stackoverflow.com/questions/577 ... ementation