Class: Bitshares::Trader
- Inherits:
-
Object
- Object
- Bitshares::Trader
- Defined in:
- lib/bitshares/trader.rb
Defined Under Namespace
Classes: Error
Constant Summary collapse
- WMSA =
'wallet_market_submit_ask'- WMSB =
'wallet_market_submit_bid'- WMOL =
'wallet_market_order_list'- WMCO =
'wallet_market_cancel_orders'
Instance Attribute Summary collapse
-
#account ⇒ Object
readonly
Returns the value of attribute account.
-
#market ⇒ Object
readonly
Returns the value of attribute market.
Instance Method Summary collapse
- #cancel_all ⇒ Object
- #cancel_orders(*id_list) ⇒ Object
-
#initialize(account, market) ⇒ Trader
constructor
A new instance of Trader.
- #order_list(limit = '-1') ⇒ Object
- #submit_ask(quantity, price, stupid = false) ⇒ Object
- #submit_bid(quantity, price, stupid = false) ⇒ Object
Constructor Details
#initialize(account, market) ⇒ Trader
Returns a new instance of Trader.
14 15 16 17 18 19 20 21 |
# 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 |
Instance Attribute Details
#account ⇒ Object (readonly)
Returns the value of attribute account.
12 13 14 |
# File 'lib/bitshares/trader.rb', line 12 def account @account end |
#market ⇒ Object (readonly)
Returns the value of attribute market.
12 13 14 |
# File 'lib/bitshares/trader.rb', line 12 def market @market end |
Instance Method Details
#cancel_all ⇒ Object
45 46 47 |
# File 'lib/bitshares/trader.rb', line 45 def cancel_all cancel_orders all_order_ids end |
#cancel_orders(*id_list) ⇒ Object
39 40 41 42 43 |
# 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') ⇒ Object
35 36 37 |
# 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) ⇒ Object
23 24 25 26 27 |
# 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) ⇒ Object
29 30 31 32 33 |
# 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 |