開始使用免費開始

投資報酬(1)

來動手做做看!先前 Lore 已經教過你關於投資報酬。現在輪到你把這些知識用起來!不過先快速複習一下。

假設你有 $100。1 月期間,你獲得 5% 的報酬。到 1 月底你會有多少?你會有起始資金的 100%,再加上額外的 5%:100% + 5% = 105%。用小數表示是 1 + .05 = 1.05。這個 1.05 就是 1 月的「報酬倍率」,把原本的 $100 乘上它,就能得到 1 月底的金額。

105 = 100 * 1.05

用變數來表示:

post_jan_cash <- starting_cash * jan_mult

快速取得倍率的方法是:

multiplier = 1 + (return / 100)

本練習屬於課程

R for Finance 入門

檢視課程

練習說明

  • 你的新起始現金、1 月報酬率與 1 月的報酬倍率已為你定義好。
  • 使用它們計算 post_jan_cash
  • 列印 post_jan_cash
  • 如果 1 月的報酬率是 10% 呢?計算新的 jan_mult_10
  • 用這個新倍率計算 post_jan_cash_10
  • 列印 post_jan_cash_10,看看不同利率的影響!

動手互動練習

試著完成這個範例程式碼,體驗一下這個練習。

# Variables for starting_cash and 5% return during January
starting_cash <- 200
jan_ret <- 5
jan_mult <- 1 + (jan_ret / 100)

# How much money do you have at the end of January?
post_jan_cash <- 

# Print post_jan_cash


# January 10% return multiplier
jan_ret_10 <- 10
jan_mult_10 <- 

# How much money do you have at the end of January now?
post_jan_cash_10 <- 

# Print post_jan_cash_10
編輯並執行程式碼