I have a time-series list of stockA, which I call bas. I have taken the natural log of bas by using


As you you know this gives the natural log of each number in the time-series list. This is what I want to do now

OPR = Log[bas/(bas at t-1)]*100 

How can I get this?


1 Answer 1


You can do this:

bas = FinancialData["MSFT", {DatePlus[Date[], -365], Date[]}, "Value"]
(* Here bas is defined as the time-series of prices for Microsoft (ticker: MSFT) *)

Now you can compute the log-returns:

  • $\begingroup$ This was actually done in my class, the teacher stated that you simply take the list of values and then divide that list with the same list at point t-1. I do understand the log of it but I dont understand how t-1 is conducted. $\endgroup$
    Aug 21, 2013 at 11:37
  • $\begingroup$ @ALEXANDER There are many types of returns... nominal return is defined as $R_{t}=\dfrac{P_{t}-P_{t-1}}{P_{t-1}}$. However, log-returns are defined as the logarithm of the price differences (or simply the logarithm of the norminal returns). So, $LogRet_{t}=Log(R_{t})=Log(\dfrac{P_{t}-P_{t-1}}{P_{t-1}})=Log(\dfrac{P_{t}}{P_{t-1}})$ $\endgroup$
    – Rod
    Aug 21, 2013 at 11:40
  • $\begingroup$ Okey what if i ask this question. I want to divide list ss of shareprices by list ss of shareprices at time t-1. how would you do this, the teacher talked about the fact that since it is now at t-1 you would lose the value of the first row of the list. Not sure what she meant about that. $\endgroup$
    Aug 21, 2013 at 11:48
  • $\begingroup$ @Alexander That's correct! If you have a price time-series with n elements you will always get n-1 returns. You can check that by using Length[bas] and Length[Differences[Log[bas]]]. I get 250 prices and 249 returns. $\endgroup$
    – Rod
    Aug 21, 2013 at 11:50
  • $\begingroup$ Okey, sounds good. But how do you subtract one values in one list from the other list? $\endgroup$
    Aug 21, 2013 at 11:55

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.