Module:Stock tickers/NYSE/sandbox
From Wikipedia, the free encyclopedia
Page Module:Documentation/styles.css has no content.
Page Module:Message box/ombox.css has no content.
| File:Edit In Sandbox Icon - Color.svg | This is the module sandbox page for Module:Stock tickers/NYSE (diff). See also the companion subpage for test cases (run). |
File:Test Template Info-Icon - Version (2).svg Module documentation[view] [edit] [history] [purge]
Script error: No such module "High-use".
- REDIRECT Template:Template rating
Template:Redirect category shell
Usage
If you supply a NYSE stock ticker to the function. It will return a URL to that stock's listing on NYSE.com.
{{#invoke:Stock tickers/NYSE|GetURL|ticker}}
Module usage
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 official URL
url = 'https://www.nyse.com/quote/XXXX:' .. ticker
return url
end
function p.FormatTickerURL(ticker)
-- Convert to upper case
ticker = string.upper(ticker)
-- NYSE.com formats for preferred shares / when issued
-- Example: Input: PRE.PRD, Output: PREpD
ticker = string.gsub(ticker, "%.PR", "p")
ticker = string.gsub(ticker, "%.WI", "w")
return ticker
end
return p