Sha256: 2efc5e82e9a5ed11046ebf9e802617d73542aab55ce3fba0db2ebddcad0c9deb

Contents?: true

Size: 731 Bytes

Versions: 18

Compression:

Stored size: 731 Bytes

Contents

# lib/sqa/strategry/common.rb

# This module needs to be extend'ed within
# a strategy class so that these common class
# methods are available in every trading strategy.

class SQA::Strategy
	module Common
		def trade_against(vector)
			return :hold unless respond_to? :trade

			recommendation = trade(vector)

			if :sell == recommendation
				:buy
			elsif :buy == recommendation
				:sell
			else
				:hold
			end
		end

		def desc
			doc_filename 	= self.name.split('::').last.downcase + ".md"
			doc_path 			= Pathname.new(__dir__) + doc_filename

			debug_me{[ :doc_path ]}

			if doc_path.exist?
				doc = doc_path.read
			else
				doc = "A description of #{self.name} is not available"
			end

			puts doc
		end
	end
end

Version data entries

18 entries across 18 versions & 1 rubygems

Version Path
sqa-0.0.22 lib/sqa/strategy/common.rb
sqa-0.0.21 lib/sqa/strategy/common.rb
sqa-0.0.20 lib/sqa/strategy/common.rb
sqa-0.0.19 lib/sqa/strategy/common.rb
sqa-0.0.18 lib/sqa/strategy/common.rb
sqa-0.0.17 lib/sqa/strategy/common.rb
sqa-0.0.15 lib/sqa/strategy/common.rb
sqa-0.0.14 lib/sqa/strategy/common.rb
sqa-0.0.13 lib/sqa/strategy/common.rb
sqa-0.0.12 lib/sqa/strategy/common.rb
sqa-0.0.11 lib/sqa/strategy/common.rb
sqa-0.0.10 lib/sqa/strategy/common.rb
sqa-0.0.9 lib/sqa/strategy/common.rb
sqa-0.0.8 lib/sqa/strategy/common.rb
sqa-0.0.7 lib/sqa/strategy/common.rb
sqa-0.0.6 lib/sqa/strategy/common.rb
sqa-0.0.5 lib/sqa/strategy/common.rb
sqa-0.0.4 lib/sqa/strategy/common.rb