Class: FdxV660Api::OrderType2

Inherits:
Object
  • Object
show all
Defined in:
lib/fdx_v660_api/models/order_type2.rb

Overview

Type of order. One of BUY, SELL, BUYTOCOVER, BUYTOOPEN, SELLTOCOVER, SELLTOOPEN, SELLSHORT, SELLCLOSE

Constant Summary collapse

ORDER_TYPE2 =
[
  # TODO: Write general description for BUY
  BUY = 'BUY'.freeze,

  # TODO: Write general description for BUYTOCOVER
  BUYTOCOVER = 'BUYTOCOVER'.freeze,

  # TODO: Write general description for BUYTOOPEN
  BUYTOOPEN = 'BUYTOOPEN'.freeze,

  # TODO: Write general description for SELL
  SELL = 'SELL'.freeze,

  # TODO: Write general description for SELLCLOSE
  SELLCLOSE = 'SELLCLOSE'.freeze,

  # TODO: Write general description for SELLSHORT
  SELLSHORT = 'SELLSHORT'.freeze,

  # TODO: Write general description for SELLTOCOVER
  SELLTOCOVER = 'SELLTOCOVER'.freeze,

  # TODO: Write general description for SELLTOOPEN
  SELLTOOPEN = 'SELLTOOPEN'.freeze
].freeze

Class Method Summary collapse

Class Method Details

.from_value(value, default_value = BUY) ⇒ Object



42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
# File 'lib/fdx_v660_api/models/order_type2.rb', line 42

def self.from_value(value, default_value = BUY)
  return default_value if value.nil?

  str = value.to_s.strip

  case str.downcase
  when 'buy' then BUY
  when 'buytocover' then BUYTOCOVER
  when 'buytoopen' then BUYTOOPEN
  when 'sell' then SELL
  when 'sellclose' then SELLCLOSE
  when 'sellshort' then SELLSHORT
  when 'selltocover' then SELLTOCOVER
  when 'selltoopen' then SELLTOOPEN
  else
    default_value
  end
end

.validate(value) ⇒ Object



36
37
38
39
40
# File 'lib/fdx_v660_api/models/order_type2.rb', line 36

def self.validate(value)
  return false if value.nil?

  true
end