Class: Fsxtrader::Trade

Inherits:
Object
  • Object
show all
Defined in:
lib/fsxtrader/trade.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(key, trade_str) ⇒ Trade

Returns a new instance of Trade.



5
6
7
8
9
10
11
12
# File 'lib/fsxtrader/trade.rb', line 5

def initialize(key, trade_str)
  # Expected params: "RDN >= 17.25 cover 110000"
  #            or  : "IBM <= 85 sell 50000"
  @key = key
  @trade_str = trade_str
  @symbol, @condition, @limit_price, @action, @shares = *trade_str.split
  @shares = @shares.gsub(',', '') # strip commas
end

Instance Attribute Details

#actionObject

Returns the value of attribute action.



3
4
5
# File 'lib/fsxtrader/trade.rb', line 3

def action
  @action
end

#conditionObject

Returns the value of attribute condition.



3
4
5
# File 'lib/fsxtrader/trade.rb', line 3

def condition
  @condition
end

#keyObject

Returns the value of attribute key.



3
4
5
# File 'lib/fsxtrader/trade.rb', line 3

def key
  @key
end

#limit_priceObject

Returns the value of attribute limit_price.



3
4
5
# File 'lib/fsxtrader/trade.rb', line 3

def limit_price
  @limit_price
end

#sharesObject

Returns the value of attribute shares.



3
4
5
# File 'lib/fsxtrader/trade.rb', line 3

def shares
  @shares
end

#symbolObject

Returns the value of attribute symbol.



3
4
5
# File 'lib/fsxtrader/trade.rb', line 3

def symbol
  @symbol
end

#trade_strObject

Returns the value of attribute trade_str.



4
5
6
# File 'lib/fsxtrader/trade.rb', line 4

def trade_str
  @trade_str
end

Instance Method Details

#to_sObject



13
14
15
# File 'lib/fsxtrader/trade.rb', line 13

def to_s
  "#{action} #{shares} of #{symbol} when it is #{condition} #{limit_price}"
end