Sha256: 70d5effefaa8abe1297a239ef8cc9ab3e487cec2317675fb66cfafc7d1714de9

Contents?: true

Size: 933 Bytes

Versions: 30

Compression:

Stored size: 933 Bytes

Contents

module RbtcArbitrage
  module Client
    attr_accessor :options
    attr_writer :balance

    def initialize config={}
      @options = config
      @options = {}
      set_key config, :volume, 0.01
      set_key config, :cutoff, 2
      set_key config, :logger, Logger.new(STDOUT)
      set_key config, :verbose, true
      set_key config, :live, false
      self
    end

    def validate_keys *args
      args.each do |key|
        key = key.to_s.upcase
        if ENV[key].blank?
          raise ArgumentError, "Exiting because missing required ENV variable $#{key}."
        end
      end
    end

    def buy
      trade :buy
    end

    def sell
      trade :sell
    end

    def address
      ENV["#{exchange.to_s.upcase}_ADDRESS"]
    end

    def logger
      @options[:logger]
    end

    private

    def set_key config, key, default
      @options[key] = config.has_key?(key) ? config[key] : default
    end
  end
end

Version data entries

30 entries across 30 versions & 2 rubygems

Version Path
rbtc_arbitrage-2.4.4 lib/rbtc_arbitrage/client.rb
rbtc_arbitrage-2.4.3 lib/rbtc_arbitrage/client.rb
rbtc_arbitrage-2.4.2 lib/rbtc_arbitrage/client.rb
rbtc_arbitrage-2.4.1 lib/rbtc_arbitrage/client.rb
rbtc_arbitrage-2.4.0 lib/rbtc_arbitrage/client.rb
rbtc_arbitrage-2.3.0 lib/rbtc_arbitrage/client.rb
rbtc_arbitrage-2.2.1 lib/rbtc_arbitrage/client.rb
rbtc_arbitrage-2.2.0 lib/rbtc_arbitrage/client.rb
rbtc_arbitrage-2.1.2 lib/rbtc_arbitrage/client.rb
rbtc_arbitrage-2.1.1 lib/rbtc_arbitrage/client.rb
rbtc_arbitrage_simple-2.1.1 lib/rbtc_arbitrage/client.rb
rbtc_arbitrage_simple-2.1.0 lib/rbtc_arbitrage/client.rb
rbtc_arbitrage-2.1.0 lib/rbtc_arbitrage/client.rb
rbtc_arbitrage-2.0.2 lib/rbtc_arbitrage/client.rb
rbtc_arbitrage_simple-2.0.1 lib/rbtc_arbitrage/client.rb
rbtc_arbitrage-2.0.1 lib/rbtc_arbitrage/client.rb
rbtc_arbitrage-2.0.0 lib/rbtc_arbitrage/client.rb
rbtc_arbitrage-1.4.6 lib/rbtc_arbitrage/client.rb
rbtc_arbitrage-1.4.5 lib/rbtc_arbitrage/client.rb
rbtc_arbitrage_simple-1.4.4 lib/rbtc_arbitrage/client.rb