Jump to content

Module:Stock tickers/NYSE

Permanently protected module
From Wikipedia, the free encyclopedia
This is an old revision of this page, as edited by Svgalbertian (talk | contribs) at 03:15, 3 August 2014 (do not support preferred shares without period, otherwise you have cases like PRE (PartnerRe Ltd.) that you have to work around). The present address (URL) is a permanent link to this revision, which may differ significantly from the current revision.

local getArgs = require('Module:Arguments').getArgs
local p = {}

function p.GetURL(frame)
	local args = getArgs(frame)
	return p._GetURL(args)
end
 
function p._GetURL(args)
	local ticker = args[1]
	
	-- Get corrected ticker
	ticker = p.FormatTickerURL(ticker)
	
	-- NYSE offical URL
	url = 'http://www.nyse.com/quote/XNYS:' .. ticker
	
	return url
end
 
function p.FormatTickerURL(ticker)
	
	-- Convert to upper case
	ticker = string.upper(ticker)
	
	-- NYSE.com formats for preferred shares
	-- Example: Input: PRE.PRD, Output: https://www.nyse.com/quote/XNYS:PREpD
	ticker = string.gsub(ticker, "%.PR", "p")
	
	return ticker
end

return p