class Jiji::Model::Trading::Order
注文 ※各フィールドについて、詳しくは <a href=“公式リファレンスdeveloper.oanda.com/rest-live-v20/order-df/”>公式リファレンス> を参照ください。
Attributes
client_extensions[RW]
gtd_time[RW]
internal_id[R]
注文の内部識別用ID
last_modified[RW]
最終更新時刻
pair_name[R]
通貨ペア 例) :EURUSD
position_fill[RW]
price[RW]
執行価格
price_bound[RW]
sell_or_buy[R]
売りor買い ( :sell or :buy )
stop_loss_on_fill[RW]
take_profit_on_fill[RW]
time_in_force[RW]
trade_client_extensions[RW]
trailing_stop_loss_on_fill[RW]
trigger_condition[RW]
type[R]
注文種別
units[RW]
注文数
Public Instance Methods
cancel()
click to toggle source
注文をキャンセルします。
# File src/jiji/model/trading/order.rb, line 72 def cancel illegal_state unless @broker @broker.cancel_order(self) end
collect_properties(keys = instance_variables.map { |n| n[1..-1].to_sym })
click to toggle source
# File src/jiji/model/trading/order.rb, line 136 def collect_properties(keys = instance_variables.map { |n| n[1..-1].to_sym }) keys.each_with_object({}) do |name, obj| next if name == :broker v = instance_variable_get("@#{name}") unless v.nil? if name == :price || name == :price_bound || name == :initial_price v = v.to_s end if name == :take_profit_on_fill || name == :stop_loss_on_fill || name == :trailing_stop_loss_on_fill v = v.clone v[:price] = v[:price].to_s if v[:price] end end obj[name] = v end end
collect_properties_for_modify()
click to toggle source
# File src/jiji/model/trading/order.rb, line 156 def collect_properties_for_modify instance_variables.map { |n| n[1..-1].to_sym }.each_with_object({}) do |name, obj| next if name == :broker v = instance_variable_get("@#{name}") obj[name] = v.is_a?(Hash) ? v.dup : v end end
from_h(hash)
click to toggle source
# File src/jiji/model/trading/order.rb, line 118 def from_h(hash) hash.each do |k, v| k = k.to_sym unless v.nil? if k == :price || k == :price_bound || k == :initial_price v = BigDecimal(v, 10) end if k == :take_profit_on_fill || k == :stop_loss_on_fill || k == :trailing_stop_loss_on_fill v = v.clone.symbolize_keys v[:price] = BigDecimal(v[:price], 10) if v[:price] end end key = '@' + k.to_s instance_variable_set(key, v) if instance_variable_defined?(key) end end
modify()
click to toggle source
注文の変更を反映します。
# File src/jiji/model/trading/order.rb, line 66 def modify illegal_state unless @broker @broker.modify_order(self) end