Class: FdxV660Api::OrderType

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

Overview

The type of the order

Constant Summary collapse

ORDER_TYPE =
[
  # 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



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

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



35
36
37
38
39
# File 'lib/fdx_v660_api/models/order_type.rb', line 35

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

  true
end