Class: Alpaca::Trade::Api::Position

Inherits:
Object
  • Object
show all
Defined in:
lib/alpaca/trade/api/position.rb

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(json) ⇒ Position

Returns a new instance of Position.



12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
# File 'lib/alpaca/trade/api/position.rb', line 12

def initialize(json)
  @asset_id = json['asset_id']
  @symbol = json['symbol']
  @exchange = json['exchange']
  @asset_class = json['asset_class']
  @avg_entry_price = json['avg_entry_price']
  @qty = json['qty']
  @side = json['side']
  @market_value = json['market_value']
  @cost_basis = json['cost_basis']
  @unrealized_pl = json['unrealized_pl']
  @unrealized_plpc = json['unrealized_plpc']
  @unrealized_intraday_pl = json['unrealized_intraday_pl']
  @unrealized_intraday_plpc = json['unrealized_intraday_plpc']
  @current_price = json['current_price']
  @lastday_price = json['lastday_price']
  @change_today = json['change_today']
end

Instance Attribute Details

#asset_classObject (readonly)

Returns the value of attribute asset_class.



7
8
9
# File 'lib/alpaca/trade/api/position.rb', line 7

def asset_class
  @asset_class
end

#asset_idObject (readonly)

Returns the value of attribute asset_id.



7
8
9
# File 'lib/alpaca/trade/api/position.rb', line 7

def asset_id
  @asset_id
end

#avg_entry_priceObject (readonly)

Returns the value of attribute avg_entry_price.



7
8
9
# File 'lib/alpaca/trade/api/position.rb', line 7

def avg_entry_price
  @avg_entry_price
end

#change_todayObject (readonly)

Returns the value of attribute change_today.



7
8
9
# File 'lib/alpaca/trade/api/position.rb', line 7

def change_today
  @change_today
end

#cost_basisObject (readonly)

Returns the value of attribute cost_basis.



7
8
9
# File 'lib/alpaca/trade/api/position.rb', line 7

def cost_basis
  @cost_basis
end

#current_priceObject (readonly)

Returns the value of attribute current_price.



7
8
9
# File 'lib/alpaca/trade/api/position.rb', line 7

def current_price
  @current_price
end

#exchangeObject (readonly)

Returns the value of attribute exchange.



7
8
9
# File 'lib/alpaca/trade/api/position.rb', line 7

def exchange
  @exchange
end

#lastday_priceObject (readonly)

Returns the value of attribute lastday_price.



7
8
9
# File 'lib/alpaca/trade/api/position.rb', line 7

def lastday_price
  @lastday_price
end

#market_valueObject (readonly)

Returns the value of attribute market_value.



7
8
9
# File 'lib/alpaca/trade/api/position.rb', line 7

def market_value
  @market_value
end

#qtyObject (readonly)

Returns the value of attribute qty.



7
8
9
# File 'lib/alpaca/trade/api/position.rb', line 7

def qty
  @qty
end

#sideObject (readonly)

Returns the value of attribute side.



7
8
9
# File 'lib/alpaca/trade/api/position.rb', line 7

def side
  @side
end

#symbolObject (readonly)

Returns the value of attribute symbol.



7
8
9
# File 'lib/alpaca/trade/api/position.rb', line 7

def symbol
  @symbol
end

#unrealized_intraday_plObject (readonly)

Returns the value of attribute unrealized_intraday_pl.



7
8
9
# File 'lib/alpaca/trade/api/position.rb', line 7

def unrealized_intraday_pl
  @unrealized_intraday_pl
end

#unrealized_intraday_plpcObject (readonly)

Returns the value of attribute unrealized_intraday_plpc.



7
8
9
# File 'lib/alpaca/trade/api/position.rb', line 7

def unrealized_intraday_plpc
  @unrealized_intraday_plpc
end

#unrealized_plObject (readonly)

Returns the value of attribute unrealized_pl.



7
8
9
# File 'lib/alpaca/trade/api/position.rb', line 7

def unrealized_pl
  @unrealized_pl
end

#unrealized_plpcObject (readonly)

Returns the value of attribute unrealized_plpc.



7
8
9
# File 'lib/alpaca/trade/api/position.rb', line 7

def unrealized_plpc
  @unrealized_plpc
end