Sha256: 0ed65c11c925815e54c87274f4f273f08cc9e322a0edc3f8494e30514cea6782

Contents?: true

Size: 1.84 KB

Versions: 1

Compression:

Stored size: 1.84 KB

Contents

module OandaAPI
  module Resource
    # Transaction value object.
    # See the Oanda Developer Guide for information about {http://developer.oanda.com/rest-live/transaction-history/ Transactions}.
    class Transaction < ResourceBase
      attr_accessor :account_balance,
                    :account_id,
                    :amount,
                    :expiry,
                    :id,
                    :instrument,
                    :interest,
                    :lower_bound,
                    :margin_rate,
                    :order_id,
                    :pl,
                    :price,
                    :rate,
                    :reason,
                    :side,
                    :stop_loss_price,
                    :stop_loss_price,
                    :take_profit_price,
                    :time,
                    :trade_id,
                    :trade_opened,
                    :trade_reduced,
                    :trailing_stop_loss_distance,
                    :type,
                    :units,
                    :upper_bound

      def initialize(attributes = {})
        self.trade_opened  = {}
        self.trade_reduced = {}
        super
      end

      def expiry=(v)
        @expiry = Time.parse v.to_s
      end

      def time=(v)
        @time = Time.parse v.to_s
      end

      def trade_opened=(v)
        @trade_opened = TradeOpened.new v
      end

      def trade_reduced=(v)
        @trade_reduced = TradeReduced.new v
      end

      # See http://developer.oanda.com/rest-live/transaction-history/ for attribute details.
      class TradeOpened < ResourceBase
        attr_accessor :id, :units
      end

      # See http://developer.oanda.com/rest-live/transaction-history/ for attribute details.
      class TradeReduced < ResourceBase
        attr_accessor :id, :interest, :pl, :units
      end
    end
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
oanda_api-0.9.6 lib/oanda_api/resource/transaction.rb