Permalink
Browse files

Remove useless code/comments.

  • Loading branch information...
1 parent cc17fb5 commit 83a6f40b7875ceec2d0c53e9db5c3a333a231f3c Matt White committed Jun 23, 2010
View
@@ -18,11 +18,6 @@ def average_directional_indexes(period, data)
@adxs = calculate_adx(plus_di, minus_di, period)
end
-# dates = dates_for_period(from_date, days)
-# (0...(dates.size)).each do |index|
-# @average_directional_index[dates[index]] =
-# end
-
def calculate_adx(plus_di, minus_di, period)
#ADX = 100 times the exponential moving average of the Absolute value of (+DI − -DI) divided by (+DI + -DI)
index = 0
@@ -3,10 +3,6 @@ def sum
self.inject(0) {|accum, c| accum + c.to_f }
end
-# def product
-# self.inject {|accum, c| accum * c.to_f}
-# end
-
def average(last = self.size)
raise "Invalid parameter" if last < 0 or last > self.size
a = self.slice((self.size - last)..(self.size - 1))
@@ -20,12 +16,6 @@ def self.truncate_to_shortest!(*arrays)
arrays.each { |array| array.slice!(0...(array.size - shortest_size)) }
end
-# def geometric_mean(last = self.size)
-# raise "Invalid parameter" if last < 0 or last > self.size
-# a = self.slice((self.size - last)..(self.size - 1))
-# a.product.to_f ** (1.0 / a.size.to_f)
-# end
-
# def average_growth
# total = 0.0
# self.inject { |p, c|
View
@@ -32,10 +32,6 @@ def get_ema_points(period, data)
emas = [get_default_simple_average(data, EMA_Seed_Days)]
data.slice(EMA_Seed_Days..-1).each { |current| emas << calculate_ema(emas.last, current, period) }
emas
-# dates = sorted_date_price_keys
-# from_date_index = sorted_date_price_keys.index(from_date)
-# emas = calculate_emas_for_dates(dates.slice((from_date_index - HistoricalData::Extra_Days + EMA_Seed_Days)..-1), get_ema_default(from_date_index), ema_period)
-# emas.delete_if { |k,v| k < from_date }
end
# Gets the first EMA_Seed_Days of numbers from data and returns a simple average.
@@ -99,41 +95,4 @@ def true_range(today, yesterday)
(today[Low] - yesterday[Close]).abs
].max
end
-
-# # Determine date of the trading day that is 'days' before date, where date is a Date object.
-# def date_for_trading_day_before(date, days)
-# dates = sorted_date_price_keys
-# index = dates.index(date.strftime)
-# raise "Not enough historical data for period" if(index - days) < 0
-# dates[index - days]
-# end
-
-# # Returns dates in YYYY-MM-DD format for a specified period.
-# def dates_for_period(start_date, days)
-# dates = sorted_date_price_keys
-# dates.slice(dates.index(start_date), days)
-# end
-
-# # Gets all the dates for previous_days before and including date.
-# def dates_for_previous_period(date, previous_days)
-# index = sorted_date_price_keys.index(nearest_future_date(date))
-# raise "Not enough historical data for period" if(index - previous_days) < 0
-# sorted_date_price_keys.slice(index - previous_days + 1, previous_days)
-# end
-
-# # Since @date_prices is a hash but we sometimes need to iterate over it in order, this method gets the keys in sorted order and caches them for teh speedz.
-# def sorted_date_price_keys
-# @sorted_dpks ||= @date_prices.keys.sort
-# end
-
-# # Takes the data from the subclass and truncates it to date.
-# def truncate_data(data)
-# data.delete_if { |k,v| k < date }
-# end
-
-# # Gets the nearest future date (be it today or in the future) to date.
-# def nearest_future_date(date)
-# date = Date.parse(date)
-# 0.upto(5) { |i| return (date+i).to_s if sorted_date_price_keys.include?((date+i).to_s) }
-# end
end
View
@@ -27,11 +27,6 @@ def get_macd_and_divergence_points(fast_ema_points, slow_ema_points, signal)
# Returns an array with the differences between the first_points and second_points
def get_differences(first_points, second_points)
Array.truncate_to_shortest!(first_points, second_points)
-# if first_points.size > second_points.size
-# first_points.slice!(0...(first_points.size - second_points.size))
-# elsif second_points.size > first_points.size
-# second_points.slice!(0...(second_points.size - first_points.size))
-# end
differences = []
first_points.each_with_index { |fp, index| differences << fp - second_points[index] }
differences
View
@@ -3,15 +3,15 @@
class TestAdx < Test::Unit::TestCase
def setup
- @ticker = "TESTING"
- @days = 30
- @period = 14
- @start_date = Date.today - @days - 10
- @end_date = Date.today - 10
+# @ticker = "TESTING"
+# @days = 30
+# @period = 14
+# @start_date = Date.today - @days - 10
+# @end_date = Date.today - 10
end
def test_adx_should_return_consistent_adxs_to_given_precision
- adxs = ADX.new(@ticker, @period, get_historical_data).adxs
+# adxs = ADX.new(@ticker, @period, get_historical_data).adxs
# assert((["%.6f" % adxs[-1], "%.6f" % adxs[-6]] - ["3.195750"]).empty?)
end
end
View
@@ -4,54 +4,10 @@
class TestSignalTools < Test::Unit::TestCase
def setup
-# @ticker = "TESTING"
-# @origin_date = Date.parse('2000-01-01')
-# @start_date = Date.parse('2000-07-01')
-# days = (@start_date - @origin_date).to_i
-# setup_historical_data(@ticker, days, @start_date.strftime)
end
def test_cache_symbol
symbol = SignalTools.cache_symbol('wtf', 'omg', 'lol', '1337')
assert_equal(:wtf_omg_lol_1337, symbol)
end
-
-# def test_stochastic_should_return_valid_and_correct_slow_and_fast_stochastic_points
-# stochastic = SignalTools.stochastic(@ticker, @start_date.strftime)
-# assert_equal("%.6f" % stochastic.slow_stochastic[0][-@accuracy_period_start], "%.6f" % stochastic.slow_stochastic[0][-1])
-# assert_equal("%.6f" % stochastic.slow_stochastic[0][-@accuracy_period_start-1], "%.6f" % stochastic.slow_stochastic[0][-2])
-# assert_equal("%.6f" % stochastic.slow_stochastic[0][-@accuracy_period_start-2], "%.6f" % stochastic.slow_stochastic[0][-3])
-# assert_equal("%.6f" % stochastic.fast_stochastic[0][-@accuracy_period_start], "%.6f" % stochastic.fast_stochastic[0][-1])
-# assert_equal("%.6f" % stochastic.fast_stochastic[0][-@accuracy_period_start-1], "%.6f" % stochastic.fast_stochastic[0][-2])
-# assert_equal("%.6f" % stochastic.fast_stochastic[0][-@accuracy_period_start-2], "%.6f" % stochastic.fast_stochastic[0][-3])
-# end
-
-# def test_average_true_range_should_return_valid_and_correct_average_true_ranges
-# atr = SignalTools.average_true_range(@ticker, @start_date.strftime)
-# assert_equal("%.4f" % atr.average_true_range[@start_date.strftime], "%.4f" % atr.average_true_range[(@start_date+9).strftime])
-# assert_equal("%.4f" % atr.average_true_range[(@start_date+1).strftime], "%.4f" % atr.average_true_range[(@start_date+10).strftime])
-# assert_equal("%.4f" % atr.average_true_range[(@start_date+2).strftime], "%.4f" % atr.average_true_range[(@start_date+11).strftime])
-# end
-
-# def test_average_directional_index_should_return_valid_and_correct_average_directional_points
-# adx = SignalTools.average_directional_index(@ticker, @start_date.strftime)
-# assert_equal("%.4f" % adx.average_directional_index[@start_date.strftime], "%.4f" % adx.average_directional_index[(@start_date+9).strftime])
-# assert_equal("%.4f" % adx.average_directional_index[(@start_date+1).strftime], "%.4f" % adx.average_directional_index[(@start_date+10).strftime])
-# assert_equal("%.4f" % adx.average_directional_index[(@start_date+2).strftime], "%.4f" % adx.average_directional_index[(@start_date+11).strftime])
-# end
-
-# private
-
-# def setup_historical_data(ticker, days, start_date)
-# historical_data = {}
-# hd = HistoricalData.new(ticker, start_date)
-# hd.high_prices = [9.3, 8.1, 7.6] * (days + HistoricalData::Extra_Days)
-# hd.low_prices = [1.2, 2.4, 3.8] * (days + HistoricalData::Extra_Days)
-# hd.close_prices = [4.5, 5.7, 6.9] * (days + HistoricalData::Extra_Days)
-# hd.date_prices = {}
-# today = Date.parse('2000-01-01')
-# (0...(hd.high_prices.size)).each { |i| hd.date_prices[(today + i).strftime] = [ hd.high_prices[i], hd.low_prices[i], hd.close_prices[i] ] }
-# historical_data[SignalTools.cache_symbol([ticker, start_date])] = hd
-# SignalTools.instance_variable_set('@historical_data_cache', historical_data)
-# end
end

0 comments on commit 83a6f40

Please sign in to comment.