quant 0.0.2 → 0.0.3
Sign up to get free protection for your applications and to get access to all the features.
- data/CHANGELOG +4 -0
- data/lib/enumerable.rb +2 -0
- data/lib/quant/version.rb +1 -1
- data/lib/util.rb +23 -0
- data/test/common_requires.rb +6 -0
- data/test/samples/ohlc.rb +43 -0
- data/test/samples/ttr.rb +43 -0
- data/test/test_donchian_channel.rb +29 -0
- data/test/test_sma.rb +13 -0
- metadata +13 -4
- data/test/test_quant.rb +0 -125
data/CHANGELOG
CHANGED
data/lib/enumerable.rb
CHANGED
data/lib/quant/version.rb
CHANGED
data/lib/util.rb
ADDED
@@ -0,0 +1,23 @@
|
|
1
|
+
module Util
|
2
|
+
|
3
|
+
def self.compare_2_arrays_of_floats(a, b)
|
4
|
+
delete_nans_and_truncate_floats_to_strings(a) == delete_nans_and_truncate_floats_to_strings(b)
|
5
|
+
end
|
6
|
+
|
7
|
+
def self.truncate_float_to_string(f)
|
8
|
+
"%.10f" % f
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.delete_nans_and_truncate_floats_to_strings(a)
|
12
|
+
a.delete_if{ |e| e.nan? }.map{ |e| truncate_float_to_string(e) }
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.ohlc(opens, highs, lows, closes)
|
16
|
+
o = []
|
17
|
+
opens.each_with_index do |e, i|
|
18
|
+
o << [opens[i], highs[i], lows[i], closes[i]]
|
19
|
+
end
|
20
|
+
o
|
21
|
+
end
|
22
|
+
|
23
|
+
end
|
@@ -0,0 +1,43 @@
|
|
1
|
+
module Samples
|
2
|
+
|
3
|
+
module Ohlc
|
4
|
+
|
5
|
+
# 50 EURUSD OHLC, from 2010-06-01 to 2010-08-10
|
6
|
+
|
7
|
+
def self.eurusd_50_opens
|
8
|
+
[1.2306, 1.2207, 1.2244, 1.2159, 1.1944, 1.1916, 1.1962, 1.1983, 1.2105, 1.2119, 1.2211, 1.2323, 1.2299, 1.2377, 1.2429, 1.2313, 1.2308, 1.2325, 1.2377, 1.2278, 1.2186, 1.2232, 1.2514, 1.2553, 1.2535, 1.2623, 1.2629, 1.2691, 1.264, 1.2585, 1.2725, 1.2739, 1.2934, 1.2896, 1.2946, 1.2889, 1.2752, 1.2883, 1.2894, 1.2985, 1.2999, 1.2985, 1.3078, 1.3059, 1.3173, 1.3224, 1.3153, 1.3182, 1.329, 1.3223]
|
9
|
+
end
|
10
|
+
|
11
|
+
def self.eurusd_50_highs
|
12
|
+
[1.235, 1.227, 1.2324, 1.2213, 1.1988, 1.2006, 1.207, 1.2139, 1.2149, 1.2296, 1.2347, 1.235, 1.2408, 1.2414, 1.2464, 1.2351, 1.2384, 1.2392, 1.2395, 1.2287, 1.23, 1.2537, 1.2608, 1.256, 1.2659, 1.2661, 1.2709, 1.272, 1.2645, 1.2736, 1.2774, 1.2952, 1.3004, 1.2989, 1.3026, 1.291, 1.2927, 1.2962, 1.3003, 1.3043, 1.3039, 1.3104, 1.309, 1.3192, 1.3259, 1.3237, 1.3233, 1.3331, 1.3305, 1.3228]
|
13
|
+
end
|
14
|
+
|
15
|
+
def self.eurusd_50_lows
|
16
|
+
[1.211, 1.2174, 1.2151, 1.1954, 1.1875, 1.1901, 1.1923, 1.1955, 1.2044, 1.2114, 1.2167, 1.2254, 1.224, 1.2351, 1.2302, 1.2249, 1.226, 1.2253, 1.2264, 1.215, 1.2165, 1.2192, 1.248, 1.2507, 1.2478, 1.2551, 1.262, 1.2608, 1.255, 1.2522, 1.2681, 1.2708, 1.2888, 1.2869, 1.2838, 1.273, 1.2736, 1.2792, 1.2874, 1.2951, 1.2965, 1.2976, 1.2979, 1.3052, 1.3145, 1.313, 1.3117, 1.3156, 1.3215, 1.3073]
|
17
|
+
end
|
18
|
+
|
19
|
+
def self.eurusd_50_closes
|
20
|
+
[1.2207, 1.2244, 1.2159, 1.1964, 1.1915, 1.1962, 1.1983, 1.2105, 1.2092, 1.2211, 1.2322, 1.2299, 1.2377, 1.237, 1.2312, 1.2267, 1.2325, 1.2383, 1.2278, 1.2185, 1.2231, 1.2515, 1.2548, 1.2535, 1.2624, 1.263, 1.269, 1.2637, 1.2585, 1.2725, 1.274, 1.2934, 1.2924, 1.2947, 1.2889, 1.2753, 1.2883, 1.2913, 1.2984, 1.2999, 1.2985, 1.3079, 1.3028, 1.3174, 1.3224, 1.3153, 1.3182, 1.329, 1.3222, 1.3175]
|
21
|
+
end
|
22
|
+
|
23
|
+
# 150 USDJPY closes, from 2011-11-08 to 2010-06-04
|
24
|
+
|
25
|
+
def self.usdjpy_150_opens
|
26
|
+
[78.06, 77.71, 77.72, 77.63, 77.18, 77.08, 77.01, 77.0, 76.97, 76.87, 76.89, 76.95, 77.26, 77.11, 77.44, 78.06, 77.92, 77.56, 77.7, 78.08, 77.81, 77.7, 77.63, 77.6, 77.61, 77.92, 77.94, 78.06, 77.87, 77.74, 78.0, 77.8, 78.01, 78.14, 78.06, 77.98, 77.85, 77.91, 77.61, 76.94, 76.88, 76.71, 76.72, 77.09, 76.79, 76.83, 76.81, 76.86, 76.75, 76.88, 76.78, 76.81, 76.76, 77.08, 76.94, 76.95, 77.63, 77.69, 77.43, 76.74, 76.35, 76.28, 76.16, 76.16, 76.53, 76.56, 76.77, 77.02, 77.63, 77.63, 77.55, 78.39, 78.37, 78.87, 79.72, 79.6, 79.71, 80.28, 79.95, 81.58, 80.46, 80.49, 81.27, 81.11, 81.83, 81.49, 80.67, 81.14, 81.51, 82.42, 82.3, 82.95, 83.73, 83.6, 83.48, 83.36, 83.66, 83.4, 82.59, 82.42, 82.86, 83.17, 82.87, 82.38, 82.95, 82.07, 82.79, 82.4, 82.35, 81.53, 81.52, 80.71, 80.85, 80.85, 80.9, 80.41, 80.86, 81.26, 81.58, 81.56, 81.15, 81.31, 81.3, 80.97, 80.29, 79.8, 80.07, 80.11, 80.17, 79.77, 79.87, 79.86, 79.62, 79.88, 79.94, 79.84, 80.21, 80.31, 79.3, 79.2, 79.27, 79.96, 79.43, 79.56, 79.64, 79.46, 79.51, 79.09, 78.35, 78.06]
|
27
|
+
end
|
28
|
+
|
29
|
+
def self.usdjpy_150_highs
|
30
|
+
[78.06, 77.86, 77.85, 77.66, 77.22, 77.46, 77.12, 77.07, 77.01, 76.97, 77.3, 77.56, 77.31, 77.77, 78.21, 78.26, 78.13, 77.78, 78.05, 78.08, 77.83, 77.76, 77.77, 77.76, 77.97, 77.99, 78.13, 78.06, 77.94, 78.14, 78.03, 78.08, 78.18, 78.2, 78.08, 78.0, 78.01, 77.93, 77.72, 76.99, 76.94, 76.81, 77.22, 77.31, 76.98, 76.88, 77.01, 76.96, 76.98, 76.92, 76.85, 76.85, 77.29, 77.28, 77.06, 77.83, 78.26, 77.78, 77.46, 76.75, 76.39, 76.33, 76.22, 76.71, 76.78, 76.94, 77.16, 77.7, 77.78, 77.76, 78.51, 78.64, 78.94, 79.48, 79.86, 79.82, 80.38, 80.33, 80.98, 81.6, 80.76, 81.28, 81.36, 81.85, 81.84, 81.56, 81.2, 81.71, 82.62, 82.49, 83.06, 83.8, 84.15, 83.6, 83.54, 83.81, 84.07, 83.41, 82.92, 82.98, 83.36, 83.17, 82.94, 82.85, 83.28, 82.97, 82.91, 82.45, 82.53, 81.64, 81.84, 81.1, 81.11, 81.17, 80.92, 80.9, 81.54, 81.71, 81.75, 81.64, 81.37, 81.67, 81.4, 81.42, 80.36, 80.28, 80.59, 80.53, 80.36, 79.97, 80.05, 79.92, 79.99, 79.97, 80.16, 80.31, 80.53, 80.37, 79.44, 79.42, 80.12, 80.05, 79.61, 79.8, 79.65, 79.61, 79.54, 79.11, 78.65, 78.39]
|
31
|
+
end
|
32
|
+
|
33
|
+
def self.usdjpy_150_lows
|
34
|
+
[77.58, 77.52, 77.48, 77.03, 76.79, 76.89, 76.83, 76.89, 76.55, 76.74, 76.81, 76.9, 76.99, 77.1, 77.44, 77.6, 77.27, 77.46, 77.69, 77.67, 77.62, 77.6, 77.11, 77.47, 77.56, 77.62, 77.9, 78.06, 77.59, 77.74, 77.69, 77.67, 77.98, 77.98, 77.9, 77.77, 77.54, 77.57, 76.88, 76.85, 76.6, 76.59, 76.64, 76.95, 76.75, 76.75, 76.81, 76.65, 76.64, 76.68, 76.53, 76.63, 76.68, 76.89, 76.84, 76.94, 77.54, 77.27, 76.63, 76.19, 76.14, 76.0, 76.02, 76.12, 76.47, 76.49, 76.69, 77.01, 77.5, 77.37, 77.34, 78.16, 78.34, 78.77, 79.34, 79.53, 79.71, 79.83, 79.91, 80.11, 80.0, 80.23, 80.82, 81.07, 81.13, 80.57, 80.56, 81.07, 81.45, 82.09, 81.95, 82.87, 83.17, 83.6, 83.0, 83.3, 83.27, 83.4, 81.97, 82.41, 82.62, 82.59, 81.9, 81.81, 81.86, 81.53, 82.07, 81.81, 81.3, 81.18, 80.61, 80.56, 80.71, 80.82, 80.9, 80.31, 80.86, 81.15, 81.47, 80.95, 80.83, 81.06, 80.64, 80.33, 79.71, 79.62, 80.03, 80.08, 79.8, 79.62, 79.69, 79.41, 79.58, 79.71, 79.66, 79.79, 80.17, 79.11, 78.99, 79.08, 79.25, 79.19, 79.32, 79.48, 79.31, 79.35, 78.84, 78.19, 77.64, 77.96]
|
35
|
+
end
|
36
|
+
|
37
|
+
def self.usdjpy_150_closes
|
38
|
+
[77.71, 77.72, 77.62, 77.09, 77.08, 77.01, 77.0, 76.97, 76.89, 76.9, 76.95, 77.26, 77.11, 77.72, 78.06, 77.92, 77.56, 77.7, 77.96, 77.81, 77.7, 77.63, 77.6, 77.5, 77.93, 77.94, 78.06, 78.06, 77.78, 78.0, 77.8, 78.01, 78.13, 78.04, 77.98, 77.85, 77.91, 77.62, 76.94, 76.89, 76.7, 76.73, 77.09, 76.97, 76.83, 76.81, 76.86, 76.76, 76.93, 76.78, 76.81, 76.77, 77.08, 76.95, 76.96, 77.64, 77.69, 77.43, 76.66, 76.36, 76.28, 76.16, 76.16, 76.53, 76.55, 76.78, 77.02, 77.63, 77.6, 77.56, 78.39, 78.37, 78.86, 79.47, 79.6, 79.72, 80.28, 79.95, 80.98, 80.46, 80.49, 81.27, 81.11, 81.78, 81.49, 80.68, 81.15, 81.52, 82.39, 82.3, 82.95, 83.73, 83.6, 83.6, 83.36, 83.66, 83.4, 83.4, 82.32, 82.85, 83.17, 82.87, 82.38, 82.77, 82.06, 82.8, 82.4, 82.35, 81.51, 81.52, 80.72, 80.84, 80.85, 81.0, 80.91, 80.86, 81.26, 81.58, 81.54, 81.15, 81.3, 81.3, 80.97, 80.35, 79.8, 80.07, 80.11, 80.17, 79.82, 79.87, 79.86, 79.62, 79.87, 79.9, 79.84, 80.21, 80.31, 79.29, 79.05, 79.27, 79.96, 79.43, 79.56, 79.64, 79.45, 79.51, 79.09, 78.35, 78.12, 78.32]
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
data/test/samples/ttr.rb
ADDED
@@ -0,0 +1,43 @@
|
|
1
|
+
module Samples
|
2
|
+
|
3
|
+
module Ttr
|
4
|
+
|
5
|
+
# SMA
|
6
|
+
|
7
|
+
def self.eurusd_50_ttr_sma10
|
8
|
+
# SMA 10 of eurusd_50_closes generated with the TTR R package
|
9
|
+
[not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, 1.2084199999999998, 1.2095699999999998, 1.2101199999999999, 1.2123, 1.2163599999999999, 1.22033, 1.22338, 1.2268, 1.22958, 1.2314399999999999, 1.23118, 1.23027, 1.23243, 1.23414, 1.23579, 1.23891, 1.24254, 1.24619, 1.24873, 1.2517999999999998, 1.2571999999999999, 1.26229, 1.26648, 1.2702399999999998, 1.27436, 1.27701, 1.2782399999999998, 1.28017, 1.28293, 1.2869199999999998, 1.28966, 1.2921099999999999, 1.2935599999999998, 1.2946, 1.29687, 1.30022, 1.30422, 1.30721, 1.31098, 1.3133599999999999, 1.3151199999999998]
|
10
|
+
end
|
11
|
+
|
12
|
+
def self.usdjpy_150_ttr_sma25
|
13
|
+
# SMA 25 of usdjpy_150_closes generated with the TTR R package
|
14
|
+
[not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, 77.456, 77.46520000000001, 77.4788, 77.49640000000001, 77.524, 77.5608, 77.59240000000001, 77.6328, 77.6792, 77.7252, 77.7684, 77.8044, 77.8304, 77.85079999999999, 77.8196, 77.7728, 77.724, 77.6908, 77.66640000000001, 77.6268, 77.58760000000001, 77.552, 77.52120000000001, 77.4876, 77.46480000000001, 77.4188, 77.37360000000001, 77.322, 77.28280000000001, 77.2496, 77.208, 77.20160000000001, 77.1888, 77.1608, 77.10560000000001, 77.0408, 76.97800000000001, 76.908, 76.8496, 76.8332, 76.8196, 76.8228, 76.8344, 76.85600000000001, 76.88119999999999, 76.9104, 76.9736, 77.034, 77.118, 77.2196, 77.33239999999999, 77.4488, 77.5892, 77.70400000000001, 77.8652, 78.0052, 78.1192, 78.2624, 78.4096, 78.6144, 78.8196, 78.99560000000001, 79.1952, 79.4096, 79.644, 79.87400000000001, 80.1208, 80.3892, 80.628, 80.868, 81.1, 81.3108, 81.512, 81.6936, 81.80760000000001, 81.9376, 82.0756, 82.1792, 82.2764, 82.348, 82.412, 82.5044, 82.54960000000001, 82.5992, 82.58840000000001, 82.5896, 82.59120000000001, 82.57880000000002, 82.552, 82.4964, 82.4408, 82.35719999999999, 82.2584, 82.1776, 82.0952, 82.0068, 81.9124, 81.8284, 81.7312, 81.6524, 81.5304, 81.4064, 81.296, 81.2076, 81.0896, 81.002, 80.8844, 80.7732, 80.674, 80.6096, 80.5424, 80.522, 80.5008, 80.4384, 80.3604, 80.29480000000001, 80.25880000000001, 80.18560000000001, 80.10480000000001, 80.0288, 79.9608, 79.8892, 79.8008, 79.696, 79.6068, 79.5476]
|
15
|
+
end
|
16
|
+
|
17
|
+
# Donchian Channel
|
18
|
+
|
19
|
+
def self.eurusd_50_ttr_donchian_channel_20_highs
|
20
|
+
[not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, 1.2464, 1.2464, 1.2537, 1.2608, 1.2608, 1.2659, 1.2661, 1.2709, 1.272, 1.272, 1.2736, 1.2774, 1.2952, 1.3004, 1.3004, 1.3026, 1.3026, 1.3026, 1.3026, 1.3026, 1.3043, 1.3043, 1.3104, 1.3104, 1.3192, 1.3259, 1.3259, 1.3259, 1.3331, 1.3331, 1.3331]
|
21
|
+
end
|
22
|
+
|
23
|
+
def self.eurusd_50_ttr_donchian_channel_20_lows
|
24
|
+
[not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, 1.1875, 1.1875, 1.1875, 1.1875, 1.1875, 1.1901, 1.1923, 1.1955, 1.2044, 1.2114, 1.215, 1.215, 1.215, 1.215, 1.215, 1.215, 1.215, 1.215, 1.215, 1.215, 1.2165, 1.2192, 1.2478, 1.2478, 1.2478, 1.2522, 1.2522, 1.2522, 1.2522, 1.2522, 1.2681]
|
25
|
+
end
|
26
|
+
|
27
|
+
def self.usdjpy_150_ttr_donchian_channel_55_highs
|
28
|
+
[not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, 78.26, 78.26, 78.26, 78.26, 78.26, 78.26, 78.26, 78.26, 78.26, 78.26, 78.26, 78.26, 78.26, 78.26, 78.26, 78.26, 78.51, 78.64, 78.94, 79.48, 79.86, 79.86, 80.38, 80.38, 80.98, 81.6, 81.6, 81.6, 81.6, 81.85, 81.85, 81.85, 81.85, 81.85, 82.62, 82.62, 83.06, 83.8, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.07, 84.07, 84.07]
|
29
|
+
end
|
30
|
+
|
31
|
+
def self.usdjpy_150_ttr_donchian_channel_55_lows
|
32
|
+
[not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, 76.53, 76.53, 76.53, 76.53, 76.53, 76.19, 76.14, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.02, 76.12, 76.47, 76.49, 76.69, 77.01, 77.34, 77.34, 77.34, 78.16, 78.34, 78.77, 79.34, 79.53, 79.62, 79.41, 79.41, 79.41, 79.41, 79.41, 79.41, 79.11, 78.99, 78.99, 78.99, 78.99, 78.99, 78.99, 78.99, 78.99, 78.84, 78.19, 77.64, 77.64]
|
33
|
+
end
|
34
|
+
|
35
|
+
private
|
36
|
+
|
37
|
+
def self.not_a_number
|
38
|
+
0 / 0.0
|
39
|
+
end
|
40
|
+
|
41
|
+
end
|
42
|
+
|
43
|
+
end
|
@@ -0,0 +1,29 @@
|
|
1
|
+
require 'common_requires'
|
2
|
+
|
3
|
+
class TestDonchianChannel < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
def test_eurusd_50_donchian_channel_20_highs
|
6
|
+
c = Util.ohlc(Samples::Ohlc.eurusd_50_opens, Samples::Ohlc.eurusd_50_highs, Samples::Ohlc.eurusd_50_lows, Samples::Ohlc.eurusd_50_closes)
|
7
|
+
dc20_highs = Quant.donchian_channel(c, 20).inject([]) { |a, e| a << e[0] }
|
8
|
+
assert Util.compare_2_arrays_of_floats dc20_highs , Samples::Ttr.eurusd_50_ttr_donchian_channel_20_highs
|
9
|
+
end
|
10
|
+
|
11
|
+
def test_eurusd_50_donchian_channel_20_lows
|
12
|
+
c = Util.ohlc(Samples::Ohlc.eurusd_50_opens, Samples::Ohlc.eurusd_50_highs, Samples::Ohlc.eurusd_50_lows, Samples::Ohlc.eurusd_50_closes)
|
13
|
+
dc20_lows = Quant.donchian_channel(c, 20).inject([]) { |a, e| a << e[1] }
|
14
|
+
assert Util.compare_2_arrays_of_floats dc20_lows , Samples::Ttr.eurusd_50_ttr_donchian_channel_20_lows
|
15
|
+
end
|
16
|
+
|
17
|
+
def test_usdjpy_150_donchian_channel_55_highs
|
18
|
+
c = Util.ohlc(Samples::Ohlc.usdjpy_150_opens, Samples::Ohlc.usdjpy_150_highs, Samples::Ohlc.usdjpy_150_lows, Samples::Ohlc.usdjpy_150_closes)
|
19
|
+
dc55_highs = Quant.donchian_channel(c, 55).inject([]) { |a, e| a << e[0] }
|
20
|
+
assert Util.compare_2_arrays_of_floats dc55_highs , Samples::Ttr.usdjpy_150_ttr_donchian_channel_55_highs
|
21
|
+
end
|
22
|
+
|
23
|
+
def test_usdjpy_150_donchian_channel_55_lows
|
24
|
+
c = Util.ohlc(Samples::Ohlc.usdjpy_150_opens, Samples::Ohlc.usdjpy_150_highs, Samples::Ohlc.usdjpy_150_lows, Samples::Ohlc.usdjpy_150_closes)
|
25
|
+
dc55_lows = Quant.donchian_channel(c, 55).inject([]) { |a, e| a << e[1] }
|
26
|
+
assert Util.compare_2_arrays_of_floats dc55_lows , Samples::Ttr.usdjpy_150_ttr_donchian_channel_55_lows
|
27
|
+
end
|
28
|
+
|
29
|
+
end
|
data/test/test_sma.rb
ADDED
@@ -0,0 +1,13 @@
|
|
1
|
+
require 'common_requires'
|
2
|
+
|
3
|
+
class TestSma < MiniTest::Unit::TestCase
|
4
|
+
|
5
|
+
def test_eurusd_50_sma10
|
6
|
+
assert Util.compare_2_arrays_of_floats Quant.sma(Samples::Ohlc.eurusd_50_closes, 10), Samples::Ttr.eurusd_50_ttr_sma10
|
7
|
+
end
|
8
|
+
|
9
|
+
def test_usdjpy_150_sma25
|
10
|
+
assert Util.compare_2_arrays_of_floats Quant.sma(Samples::Ohlc.usdjpy_150_closes, 25), Samples::Ttr.usdjpy_150_ttr_sma25
|
11
|
+
end
|
12
|
+
|
13
|
+
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: quant
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 0.0.
|
4
|
+
version: 0.0.3
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -9,7 +9,7 @@ authors:
|
|
9
9
|
autorequire:
|
10
10
|
bindir: bin
|
11
11
|
cert_chain: []
|
12
|
-
date: 2012-06-
|
12
|
+
date: 2012-06-19 00:00:00.000000000 Z
|
13
13
|
dependencies: []
|
14
14
|
description: Quantitative Trading
|
15
15
|
email:
|
@@ -27,8 +27,13 @@ files:
|
|
27
27
|
- lib/enumerable.rb
|
28
28
|
- lib/quant.rb
|
29
29
|
- lib/quant/version.rb
|
30
|
+
- lib/util.rb
|
30
31
|
- quant.gemspec
|
31
|
-
- test/
|
32
|
+
- test/common_requires.rb
|
33
|
+
- test/samples/ohlc.rb
|
34
|
+
- test/samples/ttr.rb
|
35
|
+
- test/test_donchian_channel.rb
|
36
|
+
- test/test_sma.rb
|
32
37
|
homepage: ''
|
33
38
|
licenses: []
|
34
39
|
post_install_message:
|
@@ -54,4 +59,8 @@ signing_key:
|
|
54
59
|
specification_version: 3
|
55
60
|
summary: Quantitative Trading
|
56
61
|
test_files:
|
57
|
-
- test/
|
62
|
+
- test/common_requires.rb
|
63
|
+
- test/samples/ohlc.rb
|
64
|
+
- test/samples/ttr.rb
|
65
|
+
- test/test_donchian_channel.rb
|
66
|
+
- test/test_sma.rb
|
data/test/test_quant.rb
DELETED
@@ -1,125 +0,0 @@
|
|
1
|
-
require "minitest/autorun"
|
2
|
-
require "quant"
|
3
|
-
require "enumerable"
|
4
|
-
|
5
|
-
class TestQuant < MiniTest::Unit::TestCase
|
6
|
-
|
7
|
-
def test_eurusd_50_sma10
|
8
|
-
assert compare_2_arrays_of_floats Quant.sma(eurusd_50_closes, 10), eurusd_50_ttr_sma10
|
9
|
-
end
|
10
|
-
|
11
|
-
def test_usdjpy_150_sma25
|
12
|
-
assert compare_2_arrays_of_floats Quant.sma(usdjpy_150_closes, 25), usdjpy_150_ttr_sma25
|
13
|
-
end
|
14
|
-
|
15
|
-
def test_eurusd_50_donchian_channel_20_highs
|
16
|
-
c = ohlc(eurusd_50_opens, eurusd_50_highs, eurusd_50_lows, eurusd_50_closes)
|
17
|
-
dc20_highs = Quant.donchian_channel(c, 20).inject([]) { |a, e| a << e[0] }
|
18
|
-
assert compare_2_arrays_of_floats dc20_highs , eurusd_50_ttr_donchian_channel_20_highs
|
19
|
-
end
|
20
|
-
|
21
|
-
def test_eurusd_50_donchian_channel_20_lows
|
22
|
-
c = ohlc(eurusd_50_opens, eurusd_50_highs, eurusd_50_lows, eurusd_50_closes)
|
23
|
-
dc20_lows = Quant.donchian_channel(c, 20).inject([]) { |a, e| a << e[1] }
|
24
|
-
assert compare_2_arrays_of_floats dc20_lows , eurusd_50_ttr_donchian_channel_20_lows
|
25
|
-
end
|
26
|
-
|
27
|
-
def test_usdjpy_150_donchian_channel_55_highs
|
28
|
-
c = ohlc(usdjpy_150_opens, usdjpy_150_highs, usdjpy_150_lows, usdjpy_150_closes)
|
29
|
-
dc55_highs = Quant.donchian_channel(c, 55).inject([]) { |a, e| a << e[0] }
|
30
|
-
assert compare_2_arrays_of_floats dc55_highs , usdjpy_150_ttr_donchian_channel_55_highs
|
31
|
-
end
|
32
|
-
|
33
|
-
def test_usdjpy_150_donchian_channel_55_lows
|
34
|
-
c = ohlc(usdjpy_150_opens, usdjpy_150_highs, usdjpy_150_lows, usdjpy_150_closes)
|
35
|
-
dc55_lows = Quant.donchian_channel(c, 55).inject([]) { |a, e| a << e[1] }
|
36
|
-
assert compare_2_arrays_of_floats dc55_lows , usdjpy_150_ttr_donchian_channel_55_lows
|
37
|
-
end
|
38
|
-
|
39
|
-
private
|
40
|
-
|
41
|
-
def eurusd_50_opens
|
42
|
-
[1.2306, 1.2207, 1.2244, 1.2159, 1.1944, 1.1916, 1.1962, 1.1983, 1.2105, 1.2119, 1.2211, 1.2323, 1.2299, 1.2377, 1.2429, 1.2313, 1.2308, 1.2325, 1.2377, 1.2278, 1.2186, 1.2232, 1.2514, 1.2553, 1.2535, 1.2623, 1.2629, 1.2691, 1.264, 1.2585, 1.2725, 1.2739, 1.2934, 1.2896, 1.2946, 1.2889, 1.2752, 1.2883, 1.2894, 1.2985, 1.2999, 1.2985, 1.3078, 1.3059, 1.3173, 1.3224, 1.3153, 1.3182, 1.329, 1.3223]
|
43
|
-
end
|
44
|
-
|
45
|
-
def eurusd_50_highs
|
46
|
-
[1.235, 1.227, 1.2324, 1.2213, 1.1988, 1.2006, 1.207, 1.2139, 1.2149, 1.2296, 1.2347, 1.235, 1.2408, 1.2414, 1.2464, 1.2351, 1.2384, 1.2392, 1.2395, 1.2287, 1.23, 1.2537, 1.2608, 1.256, 1.2659, 1.2661, 1.2709, 1.272, 1.2645, 1.2736, 1.2774, 1.2952, 1.3004, 1.2989, 1.3026, 1.291, 1.2927, 1.2962, 1.3003, 1.3043, 1.3039, 1.3104, 1.309, 1.3192, 1.3259, 1.3237, 1.3233, 1.3331, 1.3305, 1.3228]
|
47
|
-
end
|
48
|
-
|
49
|
-
def eurusd_50_lows
|
50
|
-
[1.211, 1.2174, 1.2151, 1.1954, 1.1875, 1.1901, 1.1923, 1.1955, 1.2044, 1.2114, 1.2167, 1.2254, 1.224, 1.2351, 1.2302, 1.2249, 1.226, 1.2253, 1.2264, 1.215, 1.2165, 1.2192, 1.248, 1.2507, 1.2478, 1.2551, 1.262, 1.2608, 1.255, 1.2522, 1.2681, 1.2708, 1.2888, 1.2869, 1.2838, 1.273, 1.2736, 1.2792, 1.2874, 1.2951, 1.2965, 1.2976, 1.2979, 1.3052, 1.3145, 1.313, 1.3117, 1.3156, 1.3215, 1.3073]
|
51
|
-
end
|
52
|
-
|
53
|
-
def eurusd_50_closes
|
54
|
-
# 50 EURUSD closes, from 2010-06-01 to 2010-08-10
|
55
|
-
[1.2207, 1.2244, 1.2159, 1.1964, 1.1915, 1.1962, 1.1983, 1.2105, 1.2092, 1.2211, 1.2322, 1.2299, 1.2377, 1.237, 1.2312, 1.2267, 1.2325, 1.2383, 1.2278, 1.2185, 1.2231, 1.2515, 1.2548, 1.2535, 1.2624, 1.263, 1.269, 1.2637, 1.2585, 1.2725, 1.274, 1.2934, 1.2924, 1.2947, 1.2889, 1.2753, 1.2883, 1.2913, 1.2984, 1.2999, 1.2985, 1.3079, 1.3028, 1.3174, 1.3224, 1.3153, 1.3182, 1.329, 1.3222, 1.3175]
|
56
|
-
end
|
57
|
-
|
58
|
-
def eurusd_50_ttr_sma10
|
59
|
-
# SMA 10 of eurusd_50_closes generated with the TTR R package
|
60
|
-
[not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, 1.2084199999999998, 1.2095699999999998, 1.2101199999999999, 1.2123, 1.2163599999999999, 1.22033, 1.22338, 1.2268, 1.22958, 1.2314399999999999, 1.23118, 1.23027, 1.23243, 1.23414, 1.23579, 1.23891, 1.24254, 1.24619, 1.24873, 1.2517999999999998, 1.2571999999999999, 1.26229, 1.26648, 1.2702399999999998, 1.27436, 1.27701, 1.2782399999999998, 1.28017, 1.28293, 1.2869199999999998, 1.28966, 1.2921099999999999, 1.2935599999999998, 1.2946, 1.29687, 1.30022, 1.30422, 1.30721, 1.31098, 1.3133599999999999, 1.3151199999999998]
|
61
|
-
end
|
62
|
-
|
63
|
-
def eurusd_50_ttr_donchian_channel_20_highs
|
64
|
-
[not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, 1.2464, 1.2464, 1.2537, 1.2608, 1.2608, 1.2659, 1.2661, 1.2709, 1.272, 1.272, 1.2736, 1.2774, 1.2952, 1.3004, 1.3004, 1.3026, 1.3026, 1.3026, 1.3026, 1.3026, 1.3043, 1.3043, 1.3104, 1.3104, 1.3192, 1.3259, 1.3259, 1.3259, 1.3331, 1.3331, 1.3331]
|
65
|
-
end
|
66
|
-
|
67
|
-
def eurusd_50_ttr_donchian_channel_20_lows
|
68
|
-
[not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, 1.1875, 1.1875, 1.1875, 1.1875, 1.1875, 1.1901, 1.1923, 1.1955, 1.2044, 1.2114, 1.215, 1.215, 1.215, 1.215, 1.215, 1.215, 1.215, 1.215, 1.215, 1.215, 1.2165, 1.2192, 1.2478, 1.2478, 1.2478, 1.2522, 1.2522, 1.2522, 1.2522, 1.2522, 1.2681]
|
69
|
-
end
|
70
|
-
|
71
|
-
def usdjpy_150_opens
|
72
|
-
[78.06, 77.71, 77.72, 77.63, 77.18, 77.08, 77.01, 77.0, 76.97, 76.87, 76.89, 76.95, 77.26, 77.11, 77.44, 78.06, 77.92, 77.56, 77.7, 78.08, 77.81, 77.7, 77.63, 77.6, 77.61, 77.92, 77.94, 78.06, 77.87, 77.74, 78.0, 77.8, 78.01, 78.14, 78.06, 77.98, 77.85, 77.91, 77.61, 76.94, 76.88, 76.71, 76.72, 77.09, 76.79, 76.83, 76.81, 76.86, 76.75, 76.88, 76.78, 76.81, 76.76, 77.08, 76.94, 76.95, 77.63, 77.69, 77.43, 76.74, 76.35, 76.28, 76.16, 76.16, 76.53, 76.56, 76.77, 77.02, 77.63, 77.63, 77.55, 78.39, 78.37, 78.87, 79.72, 79.6, 79.71, 80.28, 79.95, 81.58, 80.46, 80.49, 81.27, 81.11, 81.83, 81.49, 80.67, 81.14, 81.51, 82.42, 82.3, 82.95, 83.73, 83.6, 83.48, 83.36, 83.66, 83.4, 82.59, 82.42, 82.86, 83.17, 82.87, 82.38, 82.95, 82.07, 82.79, 82.4, 82.35, 81.53, 81.52, 80.71, 80.85, 80.85, 80.9, 80.41, 80.86, 81.26, 81.58, 81.56, 81.15, 81.31, 81.3, 80.97, 80.29, 79.8, 80.07, 80.11, 80.17, 79.77, 79.87, 79.86, 79.62, 79.88, 79.94, 79.84, 80.21, 80.31, 79.3, 79.2, 79.27, 79.96, 79.43, 79.56, 79.64, 79.46, 79.51, 79.09, 78.35, 78.06]
|
73
|
-
end
|
74
|
-
|
75
|
-
def usdjpy_150_highs
|
76
|
-
[78.06, 77.86, 77.85, 77.66, 77.22, 77.46, 77.12, 77.07, 77.01, 76.97, 77.3, 77.56, 77.31, 77.77, 78.21, 78.26, 78.13, 77.78, 78.05, 78.08, 77.83, 77.76, 77.77, 77.76, 77.97, 77.99, 78.13, 78.06, 77.94, 78.14, 78.03, 78.08, 78.18, 78.2, 78.08, 78.0, 78.01, 77.93, 77.72, 76.99, 76.94, 76.81, 77.22, 77.31, 76.98, 76.88, 77.01, 76.96, 76.98, 76.92, 76.85, 76.85, 77.29, 77.28, 77.06, 77.83, 78.26, 77.78, 77.46, 76.75, 76.39, 76.33, 76.22, 76.71, 76.78, 76.94, 77.16, 77.7, 77.78, 77.76, 78.51, 78.64, 78.94, 79.48, 79.86, 79.82, 80.38, 80.33, 80.98, 81.6, 80.76, 81.28, 81.36, 81.85, 81.84, 81.56, 81.2, 81.71, 82.62, 82.49, 83.06, 83.8, 84.15, 83.6, 83.54, 83.81, 84.07, 83.41, 82.92, 82.98, 83.36, 83.17, 82.94, 82.85, 83.28, 82.97, 82.91, 82.45, 82.53, 81.64, 81.84, 81.1, 81.11, 81.17, 80.92, 80.9, 81.54, 81.71, 81.75, 81.64, 81.37, 81.67, 81.4, 81.42, 80.36, 80.28, 80.59, 80.53, 80.36, 79.97, 80.05, 79.92, 79.99, 79.97, 80.16, 80.31, 80.53, 80.37, 79.44, 79.42, 80.12, 80.05, 79.61, 79.8, 79.65, 79.61, 79.54, 79.11, 78.65, 78.39]
|
77
|
-
end
|
78
|
-
|
79
|
-
def usdjpy_150_lows
|
80
|
-
[77.58, 77.52, 77.48, 77.03, 76.79, 76.89, 76.83, 76.89, 76.55, 76.74, 76.81, 76.9, 76.99, 77.1, 77.44, 77.6, 77.27, 77.46, 77.69, 77.67, 77.62, 77.6, 77.11, 77.47, 77.56, 77.62, 77.9, 78.06, 77.59, 77.74, 77.69, 77.67, 77.98, 77.98, 77.9, 77.77, 77.54, 77.57, 76.88, 76.85, 76.6, 76.59, 76.64, 76.95, 76.75, 76.75, 76.81, 76.65, 76.64, 76.68, 76.53, 76.63, 76.68, 76.89, 76.84, 76.94, 77.54, 77.27, 76.63, 76.19, 76.14, 76.0, 76.02, 76.12, 76.47, 76.49, 76.69, 77.01, 77.5, 77.37, 77.34, 78.16, 78.34, 78.77, 79.34, 79.53, 79.71, 79.83, 79.91, 80.11, 80.0, 80.23, 80.82, 81.07, 81.13, 80.57, 80.56, 81.07, 81.45, 82.09, 81.95, 82.87, 83.17, 83.6, 83.0, 83.3, 83.27, 83.4, 81.97, 82.41, 82.62, 82.59, 81.9, 81.81, 81.86, 81.53, 82.07, 81.81, 81.3, 81.18, 80.61, 80.56, 80.71, 80.82, 80.9, 80.31, 80.86, 81.15, 81.47, 80.95, 80.83, 81.06, 80.64, 80.33, 79.71, 79.62, 80.03, 80.08, 79.8, 79.62, 79.69, 79.41, 79.58, 79.71, 79.66, 79.79, 80.17, 79.11, 78.99, 79.08, 79.25, 79.19, 79.32, 79.48, 79.31, 79.35, 78.84, 78.19, 77.64, 77.96]
|
81
|
-
end
|
82
|
-
|
83
|
-
def usdjpy_150_closes
|
84
|
-
# 150 USDJPY closes, from 2011-11-08 to 2010-06-04
|
85
|
-
[77.71, 77.72, 77.62, 77.09, 77.08, 77.01, 77.0, 76.97, 76.89, 76.9, 76.95, 77.26, 77.11, 77.72, 78.06, 77.92, 77.56, 77.7, 77.96, 77.81, 77.7, 77.63, 77.6, 77.5, 77.93, 77.94, 78.06, 78.06, 77.78, 78.0, 77.8, 78.01, 78.13, 78.04, 77.98, 77.85, 77.91, 77.62, 76.94, 76.89, 76.7, 76.73, 77.09, 76.97, 76.83, 76.81, 76.86, 76.76, 76.93, 76.78, 76.81, 76.77, 77.08, 76.95, 76.96, 77.64, 77.69, 77.43, 76.66, 76.36, 76.28, 76.16, 76.16, 76.53, 76.55, 76.78, 77.02, 77.63, 77.6, 77.56, 78.39, 78.37, 78.86, 79.47, 79.6, 79.72, 80.28, 79.95, 80.98, 80.46, 80.49, 81.27, 81.11, 81.78, 81.49, 80.68, 81.15, 81.52, 82.39, 82.3, 82.95, 83.73, 83.6, 83.6, 83.36, 83.66, 83.4, 83.4, 82.32, 82.85, 83.17, 82.87, 82.38, 82.77, 82.06, 82.8, 82.4, 82.35, 81.51, 81.52, 80.72, 80.84, 80.85, 81.0, 80.91, 80.86, 81.26, 81.58, 81.54, 81.15, 81.3, 81.3, 80.97, 80.35, 79.8, 80.07, 80.11, 80.17, 79.82, 79.87, 79.86, 79.62, 79.87, 79.9, 79.84, 80.21, 80.31, 79.29, 79.05, 79.27, 79.96, 79.43, 79.56, 79.64, 79.45, 79.51, 79.09, 78.35, 78.12, 78.32]
|
86
|
-
end
|
87
|
-
|
88
|
-
def usdjpy_150_ttr_donchian_channel_55_highs
|
89
|
-
[not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, 78.26, 78.26, 78.26, 78.26, 78.26, 78.26, 78.26, 78.26, 78.26, 78.26, 78.26, 78.26, 78.26, 78.26, 78.26, 78.26, 78.51, 78.64, 78.94, 79.48, 79.86, 79.86, 80.38, 80.38, 80.98, 81.6, 81.6, 81.6, 81.6, 81.85, 81.85, 81.85, 81.85, 81.85, 82.62, 82.62, 83.06, 83.8, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.15, 84.07, 84.07, 84.07]
|
90
|
-
end
|
91
|
-
|
92
|
-
def usdjpy_150_ttr_donchian_channel_55_lows
|
93
|
-
[not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, 76.53, 76.53, 76.53, 76.53, 76.53, 76.19, 76.14, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.0, 76.02, 76.12, 76.47, 76.49, 76.69, 77.01, 77.34, 77.34, 77.34, 78.16, 78.34, 78.77, 79.34, 79.53, 79.62, 79.41, 79.41, 79.41, 79.41, 79.41, 79.41, 79.11, 78.99, 78.99, 78.99, 78.99, 78.99, 78.99, 78.99, 78.99, 78.84, 78.19, 77.64, 77.64]
|
94
|
-
end
|
95
|
-
|
96
|
-
def usdjpy_150_ttr_sma25
|
97
|
-
# SMA 25 of usdjpy_150_closes generated with the TTR R package
|
98
|
-
[not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, not_a_number, 77.456, 77.46520000000001, 77.4788, 77.49640000000001, 77.524, 77.5608, 77.59240000000001, 77.6328, 77.6792, 77.7252, 77.7684, 77.8044, 77.8304, 77.85079999999999, 77.8196, 77.7728, 77.724, 77.6908, 77.66640000000001, 77.6268, 77.58760000000001, 77.552, 77.52120000000001, 77.4876, 77.46480000000001, 77.4188, 77.37360000000001, 77.322, 77.28280000000001, 77.2496, 77.208, 77.20160000000001, 77.1888, 77.1608, 77.10560000000001, 77.0408, 76.97800000000001, 76.908, 76.8496, 76.8332, 76.8196, 76.8228, 76.8344, 76.85600000000001, 76.88119999999999, 76.9104, 76.9736, 77.034, 77.118, 77.2196, 77.33239999999999, 77.4488, 77.5892, 77.70400000000001, 77.8652, 78.0052, 78.1192, 78.2624, 78.4096, 78.6144, 78.8196, 78.99560000000001, 79.1952, 79.4096, 79.644, 79.87400000000001, 80.1208, 80.3892, 80.628, 80.868, 81.1, 81.3108, 81.512, 81.6936, 81.80760000000001, 81.9376, 82.0756, 82.1792, 82.2764, 82.348, 82.412, 82.5044, 82.54960000000001, 82.5992, 82.58840000000001, 82.5896, 82.59120000000001, 82.57880000000002, 82.552, 82.4964, 82.4408, 82.35719999999999, 82.2584, 82.1776, 82.0952, 82.0068, 81.9124, 81.8284, 81.7312, 81.6524, 81.5304, 81.4064, 81.296, 81.2076, 81.0896, 81.002, 80.8844, 80.7732, 80.674, 80.6096, 80.5424, 80.522, 80.5008, 80.4384, 80.3604, 80.29480000000001, 80.25880000000001, 80.18560000000001, 80.10480000000001, 80.0288, 79.9608, 79.8892, 79.8008, 79.696, 79.6068, 79.5476]
|
99
|
-
end
|
100
|
-
|
101
|
-
def not_a_number
|
102
|
-
0/0.0
|
103
|
-
end
|
104
|
-
|
105
|
-
def compare_2_arrays_of_floats(a, b)
|
106
|
-
delete_nans_and_truncate_floats_to_strings(a) == delete_nans_and_truncate_floats_to_strings(b)
|
107
|
-
end
|
108
|
-
|
109
|
-
def truncate_float_to_string(f)
|
110
|
-
"%.10f" % f
|
111
|
-
end
|
112
|
-
|
113
|
-
def delete_nans_and_truncate_floats_to_strings(a)
|
114
|
-
a.delete_if{ |e| e.nan? }.map{ |e| truncate_float_to_string(e) }
|
115
|
-
end
|
116
|
-
|
117
|
-
def ohlc(opens, highs, lows, closes)
|
118
|
-
o = []
|
119
|
-
opens.each_with_index do |e, i|
|
120
|
-
o << [opens[i], highs[i], lows[i], closes[i]]
|
121
|
-
end
|
122
|
-
o
|
123
|
-
end
|
124
|
-
|
125
|
-
end
|