how to calculate daily return for group of stocks in a dataframe & put output in different column

Hello,

I have a list of some say 8 stocks in a dataframe from a sample universe of 4000 stocks. The stocks are listed by their RIC. I want to calculate the daily return & derive that output in a different column. the data frame sample will look like below: RICS on left side & prices on right side. How can Eikon API have a time series function code to get that output.? Can someone help & guide how to calculate the returns in pandas. Help is much appreciated. Tks R

1725629374083.png

Tagged:

Answers

  • @rupa Thanks for your question so you should create another column and calculate the difference between the two columns - something like:

    closePriceDF1['Daily Change'] = closePriceDF1['2024-08-22'] - closePriceDF1['2024-08-21']

    that should calculate the difference. You can also calculate a % change by altering the formula slightly. I. hope this can help.


  • hello, thanks Jason.

    i was able to change formula to get %.

    i have a query on that .....As the stocks are in different currencies, what code can be used in a function:

    1. to get the currency
    2. convert all those in to home currency?


    thanks in advance


    RS