class Trader::ItbitBackend

Public Instance Methods

cancel_order(_session, _order) click to toggle source
# File lib/trade-o-matic/adapters/itbit_backend.rb, line 44
def cancel_order(_session, _order)
end
create_order(_session, _pair, _volume, _price, _type) click to toggle source
# File lib/trade-o-matic/adapters/itbit_backend.rb, line 38
def create_order(_session, _pair, _volume, _price, _type)
end
fetch_order(_session, _order) click to toggle source
# File lib/trade-o-matic/adapters/itbit_backend.rb, line 41
def fetch_order(_session, _order)
end
fill_book(_book) click to toggle source
# File lib/trade-o-matic/adapters/itbit_backend.rb, line 7
def fill_book(_book)
  # TODO: consider book pair

  _book.prepare Time.now

  ob = fetch_raw_order_book _book.pair
  ob['bids'].each { |o| _book.add_bid(o[0], o[1]) }
  ob['asks'].each { |o| _book.add_ask(o[0], o[1]) }

  tx = fetch_raw_transactions _book.pair
  tx['recentTrades'].each do |t|
    _book.add_transaction t['price'], t['amount'], Time.parse(t['timestamp'])
  end
end
get_available_markets() click to toggle source
# File lib/trade-o-matic/adapters/itbit_backend.rb, line 22
def get_available_markets
  # TODO.
end
get_balance(_session, _currency) click to toggle source
# File lib/trade-o-matic/adapters/itbit_backend.rb, line 30
def get_balance(_session, _currency)
  return Price.new(_currency, 0.0) if _currency.code == :BTC
  return Price.new(_currency, 20000.0) if _currency.code == :USD
end
get_orders(_session, _pair) click to toggle source
# File lib/trade-o-matic/adapters/itbit_backend.rb, line 35
def get_orders(_session, _pair)
end
get_session(_credentials) click to toggle source
# File lib/trade-o-matic/adapters/itbit_backend.rb, line 26
def get_session(_credentials)
  _credentials
end

Private Instance Methods

fetch_raw_order_book(_pair) click to toggle source
# File lib/trade-o-matic/adapters/itbit_backend.rb, line 49
def fetch_raw_order_book(_pair)
  JSON.parse(RestClient.get "https://api.itbit.com/v1/markets/XBTUSD/order_book")
end
fetch_raw_transactions(_pair) click to toggle source
# File lib/trade-o-matic/adapters/itbit_backend.rb, line 53
def fetch_raw_transactions(_pair)
  JSON.parse(RestClient.get "https://api.itbit.com/v1/markets/XBTUSD/trades")
end