Class: BTCT::CampBxAPI

Inherits:
Object
  • Object
show all
Defined in:
lib/btct/campbx.rb

Instance Method Summary collapse

Instance Method Details

#nameObject



7
8
9
# File 'lib/btct/campbx.rb', line 7

def name
  "CampBX"
end

#tickerObject



18
19
20
21
22
23
24
25
26
27
28
# File 'lib/btct/campbx.rb', line 18

def ticker
  ticker = JSON.parse open("https://campbx.com/api/xticker.php").read
  Ticker.new(
    :last     => ticker["Last Trade"].to_f,
    :volume   => 0.0,
    :high     => 0.0,
    :low      => 0.0,
    :time     => DateTime.now.new_offset(0),
    :exchange => name
  )
end

#topObject



11
12
13
14
15
16
# File 'lib/btct/campbx.rb', line 11

def top
  ob = JSON.parse open("https://campbx.com/api/xdepth.php").read
  bid = ob["Bids"].sort { |x, y| x[0].to_f <=> y [0].to_f }.last
  ask = ob["Asks"].sort { |x, y| x[0].to_f <=> y [0].to_f }.first
  return Quote.new(bid[0], bid[1], name), Quote.new(ask[0], ask[1], name)
end