Last active
August 29, 2015 14:07
-
-
Save morganp/5bb3b2591c9623d393cf to your computer and use it in GitHub Desktop.
Stocks and share calculator fetches current DLG price
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
## Install Gem | |
# gem install stock_quote | |
require "stock_quote" | |
## Get price of DLG.DE stocks | |
stock = StockQuote::Stock.quote("DLG.DE").ask | |
commision = 0.1 # Commision Cost 10 cent a share | |
options_no = 1 # Number of shares | |
option_cost = 1.0 # Purchase cost of option | |
total_cost = option_cost + commision | |
profit = (stock - total_cost) * options_no | |
#euro to Stirling Conversion | |
profit_pounds = profit * 0.8 | |
puts "DLG.DE Value (euro) : #{profit}" | |
puts "DLG.DE Value (GBP) : #{profit_pounds}" | |
## Calculate Capital gains tax 28% on value over �11k | |
if profit_pounds > 11000 | |
profit_pounds_post_tax = (profit_pounds-11000)*0.72 + 11000 | |
else | |
profit_pounds_post_tax = profit_pounds | |
end | |
puts "Post Tax (GBP) : #{profit_pounds_post_tax}" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment