Class: MtGox::Client

Inherits:
Object
  • Object
show all
Includes:
Connection, Request
Defined in:
lib/mtgox/client.rb

Direct Known Subclasses

Me

Instance Method Summary collapse

Methods included from Request

#get, #post

Instance Method Details

#depth([currency = :usd,]{}) ⇒ Depth

Fetch depth

Examples:


MtGox.depth
MtGox.depth(:full => true)
MtGox.depth(:usd, :full => true)

Returns with keys :asks and :asks, which contain arrays as described in #asks and MtGox::Clients#bids.

Parameters:

  • o (Hash)

    options

Returns:

  • (Depth)

    with keys :asks and :asks, which contain arrays as described in #asks and MtGox::Clients#bids

Requires Authentication:

  • false



31
32
33
34
35
36
37
38
# File 'lib/mtgox/client.rb', line 31

def depth(*args) 
  (currency,), o = args.extract_options
  currency ||= :usd
  currency = currency_name(currency)
  depth = o[:full] ? "fulldepth" : "depth"
  data = get("/api/1/#{currency}/public/#{depth}?raw")
  Depth.new data
end

#ticker(currency = :usd) ⇒ MtGox::Ticker

Fetch the latest ticker data

Examples:

MtGox.ticker

Returns:

Requires Authentication:

  • false



12
13
14
15
16
# File 'lib/mtgox/client.rb', line 12

def ticker(currency=:usd)
  currency = currency_name(currency)
  data = get("/api/1/#{currency}/public/ticker?raw")
  Ticker.new(data)
end

#trades(*args) ⇒ Array<MtGox::Trade>

Fetch recent trades

Examples:

MtGox.trades
MtGox.trades :since => 0
MtGox.trades :usd, :since => 0

Returns:

  • (Array<MtGox::Trade>)

    an array of trades, sorted in chronological order

Requires Authentication:

  • false



49
50
51
52
53
54
55
56
# File 'lib/mtgox/client.rb', line 49

def trades(*args)
  (currency,), query = args.extract_options
  currency ||= :usd
  currency = currency_name(currency)
  get("/api/1/#{currency}/public/trades?raw", query).map { |data|
    Trade.new(data)
  }
end