Skip to content

Instantly share code, notes, and snippets.

@kanzitelli
Created November 11, 2017 03:31
Show Gist options
  • Save kanzitelli/4944ae9cd7b9f83228d871eceede9607 to your computer and use it in GitHub Desktop.
Save kanzitelli/4944ae9cd7b9f83228d871eceede9607 to your computer and use it in GitHub Desktop.
# 1. Apple - AAPL
AAPL_p_01_01_2016 = 4000
number_of_shares_start = math.floor(AAPL_p_01_01_2016 / close_prices_2016.AAPL[0])
AAPL_p_12_31_2016 = number_of_shares_start * close_prices_2016.AAPL[-1]
relative_return = (AAPL_p_12_31_2016 - AAPL_p_01_01_2016) / AAPL_p_01_01_2016 * 100
print "1. Relative return for Apple = %.2f%%" % relative_return
# 2. Amazon - AMZN
AMZN_p_01_01_2016 = 3000
number_of_shares_start = math.floor(AMZN_p_01_01_2016 / close_prices_2016.AMZN[0])
AMZN_p_12_31_2016 = number_of_shares_start * close_prices_2016.AMZN[-1]
relative_return = (AMZN_p_12_31_2016 - AMZN_p_01_01_2016) / AMZN_p_01_01_2016 * 100
print "2. Relative return for Amazon = %.2f%%" % relative_return
# 3. Google - GOOGL
GOOGL_p_01_01_2016 = 3000
number_of_shares_start = math.floor(GOOGL_p_01_01_2016 / close_prices_2016.GOOGL[0])
GOOGL_p_12_31_2016 = number_of_shares_start * close_prices_2016.GOOGL[-1]
relative_return = (GOOGL_p_12_31_2016 - GOOGL_p_01_01_2016) / GOOGL_p_01_01_2016 * 100
print "3. Relative return for Google = %.2f%%" % relative_return
total_income = AAPL_p_12_31_2016 + AMZN_p_12_31_2016 + GOOGL_p_12_31_2016
print "Our capital on the beginning of 2016 - $10.000. Our income for the end of 2016 = %.2f" % total_income
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment