Module: IB::TrailingStop

Extended by:
OrderPrototype
Defined in:
lib/ib/order_prototypes/stop.rb

Overview

module OrderPrototype

Class Method Summary collapse

Methods included from OrderPrototype

aliases, alternative_parameters, defaults, optional, order, parameters, requirements

Class Method Details

.aliasesObject



106
107
108
109
# File 'lib/ib/order_prototypes/stop.rb', line 106

def aliases
	super.merge trail_stop_price: :price,
							aux_price: :trailing_amount
end

.alternative_parametersObject



117
118
119
120
# File 'lib/ib/order_prototypes/stop.rb', line 117

def alternative_parameters
	{ aux_price: 'Trailing distance in absolute terms, aliased as :trailing_amount',
trailing_percent: 'Trailing distance in relative terms'}
end

.defaultsObject



102
103
104
# File 'lib/ib/order_prototypes/stop.rb', line 102

def defaults
	super.merge order_type: :trailing_stop , tif: :day
end

.requirementsObject



111
112
113
114
115
# File 'lib/ib/order_prototypes/stop.rb', line 111

def requirements
	## usualy the trail_stop_price is the market-price minus(plus) the trailing_amount
	super.merge trail_stop_price: 'Price to trigger the action, aliased as :price'

end

.summaryObject



122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
# File 'lib/ib/order_prototypes/stop.rb', line 122

def summary
	<<-HERE
	A "Sell" trailing stop order sets the stop price at a fixed amount below the market 
	price with an attached "trailing" amount. As the market price rises, the stop price 
	rises by the trail amount, but if the stock price falls, the stop loss price doesn't 
	change, and a market order is submitted when the stop price is hit. This technique 
	is designed to allow an investor to specify a limit on the maximum possible loss, 
	without setting a limit on the maximum possible gain. 

	"Buy" trailing stop orders are the mirror image of sell trailing stop orders, and 
	are most appropriate for use in falling markets.

	Note that Trailing Stop orders can have the trailing amount specified as a percent, 
	or as an absolute amount which is specified in the auxPrice field. 

	HERE
end