-
Notifications
You must be signed in to change notification settings - Fork 11
/
sample.jl
101 lines (81 loc) · 2.07 KB
/
sample.jl
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
include("src/TALib.jl")
using TALib
using TALib: TA_MAType_SMA
using DataFrames
print("Initialize: ")
retCode = Initialize()
println(retCode)
for f in [GetVersionString, GetVersionMajor, GetVersionMinor, GetVersionBuild, GetVersionDate, GetVersionTime]
print(string(f) * ": ")
println(f())
end
s_xml = FunctionDescriptionXML()
#println(s_xml)
println("Input")
inReal = [0, pi/2, pi, 3pi/2, 0, pi/2, pi, 3pi/2]
println(inReal)
println("COS")
outReal = COS(inReal)
println(outReal)
println("ACOS")
outReal = ACOS(outReal)
println(outReal)
println("SIN")
outReal = SIN(inReal)
println(outReal)
println("ASIN")
outReal = ASIN(outReal)
println(outReal)
println("TAN")
outReal = TAN(inReal)
println(outReal)
println("ATAN")
outReal = ATAN(outReal)
println(outReal)
filename = "test/ford_2012.csv"
println("Read '$filename'")
dfOHLCV = readtable(filename)
dfOHLCV[:Date] = Date(dfOHLCV[:Date])
println(dfOHLCV)
opn = Array(dfOHLCV[:Open])
hig = Array(dfOHLCV[:High])
low = Array(dfOHLCV[:Low])
cls = Array(dfOHLCV[:Close])
price = Array(dfOHLCV[:Close])
vol = Array(dfOHLCV[:Volume])
println(price)
println("MA")
#indic = MA(price)
indic = MA(price, time_period=30, ma_type=TA_MAType_SMA)
println(indic)
println(MA(dfOHLCV, price=:Close))
using PyPlot
#plot(dfOHLCV[:Date], dfOHLCV[:Close])
plot(dfOHLCV[:Date], dfOHLCV[:Close], dfOHLCV[:Date], indic)
#=
plot(dfOHLCV[:Date], dfOHLCV[:Open],
dfOHLCV[:Date], dfOHLCV[:High],
dfOHLCV[:Date], dfOHLCV[:Low],
dfOHLCV[:Date], dfOHLCV[:Close],
)
=#
println("BBANDS")
println(price)
#indic = BBANDS(price)
#indic = BBANDS(price, time_period=30, deviations_up=2.0, deviations_down=2.0, ma_type=TA_MAType_SMA)
#println(indic)
indic = BBANDS(dfOHLCV, price=:Close)
println(indic)
#=
plot(dfOHLCV[:Date], dfOHLCV[:Close],
dfOHLCV[:Date], indic[:UpperBand],
dfOHLCV[:Date], indic[:MiddleBand],
dfOHLCV[:Date], indic[:LowerBand],
)
=#
pause(10)
#angles = readdlm("test/angles.csv")
#angles = reshape(angles, length(angles)) # convert Array{Float64,2} to Array{Float64,1}
print("Shutdown: ")
retCode = Shutdown()
println(retCode)