(method) Overview:
talib_table() generates an HTML table to display the various inputs and outputs of a TA Lib function.
Code:def talib_table(title, numOutput, kwargs):
def isFloat(val):
try:
v = float(val)
except:
return False
return True
fullText = ''
fullText += '<table class="talib" style="width:100%">\n'
l = 0
numArgs = 0
for arg in kwargs:
l = len(kwargs[arg])
numArgs += 1
fullText += ' <tr>\n'
fullText += ' <th colspan="%d">%s</th>\n' % (l, title)
fullText += ' </tr>\n'
fullText += ' <tr>\n'
fullText += ' <th></tj>\n'
fullText += ' <th colspan="%d">%s</th>\n' % (numArgs - numOutput - 1, 'Input')
fullText += ' <th colspan="%d">%s</th>\n' % (numOutput, 'Output')
fullText += ' </tr>\n'
fullText += ' <tr>\n'
for arg in kwargs:
fullText += ' <th>' + arg + '</th>\n'
fullText += ' </tr>\n'
i = 0
while i < l:
fullText += ' <tr>\n'
for arg in kwargs:
val = kwargs[arg][i]
if (isFloat(val)):
fullText += ' <td align="right">%.2f</td>\n' % val
else:
fullText += ' <td align="right">%s</td>\n' % val
i += 1
fullText += ' </tr>\n'
fullText += '</table>\n'
return fullText
Name | Type | Default | Information |
---|---|---|---|
title | string | Required | Title for the table |
numOutput | int | Required | The number of 'output' values passed in from kwargs |
kwargs | OrderedDict | Required | Date, input, and output data |
Type | Notes |
---|---|
string | An HTML table representation of the TA Lib input/output data |
View output of a TA Lib function.