class Bitshares::Trader

Constants

WMCO
WMOL
WMSA
WMSB

Attributes

account[R]
market[R]

Public Class Methods

new(account, market) click to toggle source
# File lib/bitshares/trader.rb, line 14
def initialize(account, market)
  @account = account
  @wallet = account.wallet
  @name = account.name
  @market = market
  @base = market.base
  @quote = market.quote
end

Public Instance Methods

cancel_all() click to toggle source
# File lib/bitshares/trader.rb, line 45
def cancel_all
  cancel_orders all_order_ids
end
cancel_orders(*id_list) click to toggle source
# File lib/bitshares/trader.rb, line 39
def cancel_orders(*id_list)
  @wallet.unlock if @wallet.locked?
  confirm = CLIENT.request(WMCO, id_list)
  confirm['ledger_entries'].map { |e| e['memo'] } # returns 'cancel ASK-xxxxxxxx' first 8 chars of order id
end
order_list(limit = '-1') click to toggle source
# File lib/bitshares/trader.rb, line 35
def order_list(limit = '-1')
  CLIENT.request(WMOL, [@quote, @base, limit, @name])
end
submit_ask(quantity, price, stupid = false) click to toggle source
# File lib/bitshares/trader.rb, line 23
def submit_ask(quantity, price, stupid = false)
  @wallet.unlock if @wallet.locked?
  o = CLIENT.request(WMSA, [@name, quantity, @base, price, @quote, stupid])
  o['record_id'] # return order id
end
submit_bid(quantity, price, stupid = false) click to toggle source
# File lib/bitshares/trader.rb, line 29
def submit_bid(quantity, price, stupid = false)
  @wallet.unlock if @wallet.locked?
  o = CLIENT.request(WMSB, [@name, quantity, @base, price, @quote, stupid])
  o['record_id'] # return order id
end

Private Instance Methods

all_order_ids() click to toggle source
# File lib/bitshares/trader.rb, line 51
def all_order_ids
  order_list.map &:first
end