Skip to content

Instantly share code, notes, and snippets.

@morganp
Last active August 29, 2015 14:07
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save morganp/5bb3b2591c9623d393cf to your computer and use it in GitHub Desktop.
Save morganp/5bb3b2591c9623d393cf to your computer and use it in GitHub Desktop.
Stocks and share calculator fetches current DLG price
#!/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