Closed femtotrader closed 7 years ago
WIP
using XMLDict
using DataStructures: OrderedDict
using TALib: FunctionDescriptionXML, d_typ_to_c
function get_dict_of_ta_func()
s_xml = FunctionDescriptionXML()
d_xml = xml_dict(s_xml)["FinancialFunctions"]["FinancialFunction"]
d = OrderedDict{Symbol,Any}()
for func_info in d_xml
funcname = func_info["Abbreviation"]
delete!(func_info, "Abbreviation")
l = [] # length of RequiredInputArguments, OptionalInputArguments, OutputArguments
for key in ["RequiredInputArgument", "OptionalInputArgument", "OutputArgument"]
if haskey(func_info, key * "s")
if typeof(func_info[key * "s"][key]) <: Associative # if it's a dict like
func_info[key * "s"] = [func_info[key * "s"][key]] # list of only ONE element
else
func_info[key * "s"] = func_info[key * "s"][key]
end
else
func_info[key * "s"] = []
end
for arg in func_info[key * "s"]
if !haskey(d_typ_to_c, arg["Type"])
error("$(arg["Type"]) is not a supported type")
end
end
push!(l, length(func_info[key * "s"]))
end
#func_info["Length"] = l
d[Symbol(funcname)] = func_info
end
d
end
function main()
d = get_dict_of_ta_func()
println(d)
end
main()
We might use XMLDict to convert XML to Julia dict (instead of XMLconvert.jl) https://github.com/samoconnor/XMLDict.jl because we can get easily OrderedDict of TA Lib function for code generation