Question: in Python, Construct two new variable: monthly returns of TSX and BTC. Hint: Monthly percentage returns are defined as the price appreciation with respect to
in Python, Construct two new variable: monthly returns of TSX and BTC.
Hint: Monthly percentage returns are defined as the price appreciation with respect to the last months prices: Rt = PtPt1 . You can calculate the returns following the equation or use Pt1 the percentage change function of Pandas: .pct_change(). Alternatively, you can work with the log return of each month is calculated with respect to the previous months values using the log of prices, i.e. Rt = ln(Pt) ln(Pt1)
Attached is the data:
Date S&P/TSX Composite index Bitcoin CAD (BTC-CAD) 0 2013-09-01 12787.200195 117.849998 1 2013-10-01 13361.299805 225.979996 2 2013-11-01 13395.400391 1058.920044 3 2013-12-01 13621.599609 945.049988 4 2014-01-01 13694.900391 930.020020 5 2014-02-01 14209.599609 590.000000 6 2014-03-01 14335.299805 592.000000 7 2014-04-01 14651.900391 520.900024 8 2014-05-01 14604.200195 636.080017 9 2014-06-01 15146.000000 658.039978 10 2014-07-01 15330.700195 672.650024 11 2014-08-01 15625.700195 598.799988 12 2014-09-01 14960.500000 479.000000 13 2014-10-01 14613.299805 359.970001 14 2014-11-01 14744.700195 391.649994 15 2014-12-01 14632.400391 397.089996 16 2015-01-01 14673.500000 305.630005 17 2015-02-01 15234.299805 289.750000 18 2015-03-01 14902.400391 329.989990 19 2015-04-01 15224.500000 339.690002 20 2015-05-01 15014.099609 323.100006 21 2015-06-01 14553.299805 331.179993 22 2015-07-01 14468.700195 368.510010 23 2015-08-01 13859.099609 303.540009 24 2015-09-01 13307.000000 316.500000 25 2015-10-01 13529.200195 413.549988 26 2015-11-01 13469.799805 501.500000 27 2015-12-01 13010.000000 594.630005 28 2016-01-01 12822.099609 519.219971 29 2016-02-01 12860.400391 591.489990 30 2016-03-01 13494.400391 540.900024 31 2016-04-01 13951.500000 570.989990 32 2016-05-01 14065.799805 695.270020 33 2016-06-01 14064.500000 860.000000 34 2016-07-01 14582.700195 950.119995 35 2016-08-01 14598.000000 749.000000 36 2016-09-01 14725.900391 803.119995 37 2016-10-01 14787.299805 937.000000 38 2016-11-01 15082.900391 998.880005 39 2016-12-01 15287.599609 1319.060059 40 2017-01-01 15386.000000 1277.000000 41 2017-02-01 15399.200195 1597.989990 42 2017-03-01 15547.799805 1453.910034 43 2017-04-01 15586.099609 1868.619995 44 2017-05-01 15349.900391 3279.899902 45 2017-06-01 15182.200195 3332.580078 46 2017-07-01 15143.900391 3798.340088 47 2017-08-01 15211.900391 6022.910156 48 2017-09-01 15634.900391 5408.850098 49 2017-10-01 16025.599609 8436.200195 50 2017-11-01 16067.500000 13234.879883 51 2017-12-01 16209.099609 18323.539063 52 2018-01-01 15951.700195 12297.200195 53 2018-02-01 15442.700195 12742.830078 54 2018-03-01 15367.299805 9204.240234 55 2018-04-01 15607.900391 12103.549805 56 2018-05-01 16061.500000 9831.129883 57 2018-06-01 16277.700195 8461.830078 58 2018-07-01 16434.000000 10416.559570 59 2018-08-01 16323.700195 8886.969727
Step by Step Solution
There are 3 Steps involved in it
Get step-by-step solutions from verified subject matter experts
