Stock data is pulled every ten seconds from the Yahoo Finance API. The work is distributed among a variable number of threads.
Lua expressions are also evaluated every ten seconds. Data is pushed onto the Lua stack in nested tables. When stock data is refreshed, the Lua expression is evaluated. The result is shown to the right of each stock. So long as the syntax is correct and the necessary data is present, expressions can comprise any valid script.
setResult( (data[__size - 1].close - data[0].open) / data[__size - 1].close * 100 )
function mma(i)
if i == 0 then
return (1 / __size) * data[i].close
else
nextIterationResult = mma(i-1)
return nextIterationResult + (1 / __size) * (data[i].close - nextIterationResult)
end
end
setResult(mma(__size - 1))
Graphs are redrawn on every QWidget::paintEvent. The line and candlestick data is sourced from the stock queries.