Difference between revisions of "Module:Stock tickers/LSE"
Jump to navigation
Jump to search
blackwiki>Svgalbertian (create module that supports isin or four way key) |
blackwiki>Svgalbertian |
||
| Line 12: | Line 12: | ||
local fourway = args.fourway | local fourway = args.fourway | ||
local otherinput = args[2] | local otherinput = args[2] | ||
| + | |||
| + | if not ticker then | ||
| + | url = "http://www.londonstockexchange.com/" | ||
| + | return url | ||
| + | end | ||
-- If the isin wasn't explicitly passed check if it was the second variable | -- If the isin wasn't explicitly passed check if it was the second variable | ||
Revision as of 21:59, 17 January 2016
Implements {{London Stock Exchange}}
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]
local isin = args.isin
local fourway = args.fourway
local otherinput = args[2]
if not ticker then
url = "http://www.londonstockexchange.com/"
return url
end
-- If the isin wasn't explicitly passed check if it was the second variable
if not isin and otherinput.len == 12 then
isin = otherinput
end
-- If the four way key wasn't explicitly passed check if it was the second variable
if not fourway and otherinput.len > 12 then
fourway = otherinput
end
-- If you have the four way key then you know the isin
if fourway and not isin then
isin.sub(fourway, 0, 12)
end
-- If you have the four way key you can link direclty to the security
if fourway then
url = 'http://www.londonstockexchange.com/exchange/prices-and-markets/stocks/summary/company-summary/' .. fourway .. ".html"
-- If you have the isin you can improve the search results
elseif isin then
url = 'http://www.londonstockexchange.com/exchange/searchengine/search.html?q=' .. isin
-- Fallback to a simple ticker search
else
url = 'http://www.londonstockexchange.com/exchange/searchengine/search.html?q=' .. ticker
end
return url
end
return p