Class: MercadoBitcoin::Console
- Inherits:
-
Object
- Object
- MercadoBitcoin::Console
- Defined in:
- lib/mercado_bitcoin/console.rb
Instance Attribute Summary collapse
-
#options ⇒ Object
Returns the value of attribute options.
Instance Method Summary collapse
- #cancel_order(*args) ⇒ Object
- #exec(command, opts) ⇒ Object
- #get_account_info(*args) ⇒ Object
- #get_order(*args) ⇒ Object
- #get_withdrawal(*args) ⇒ Object
-
#initialize(key:, code:, coin_pair:, **opts) ⇒ Console
constructor
Laizy way to check parameters :).
- #list_orderbook(*args) ⇒ Object
- #list_orders(*args) ⇒ Object
- #list_system_messages(*args) ⇒ Object
- #place_buy_order(*args) ⇒ Object
- #place_sell_order(*args) ⇒ Object
Constructor Details
#initialize(key:, code:, coin_pair:, **opts) ⇒ Console
Laizy way to check parameters :)
5 6 7 8 9 10 |
# File 'lib/mercado_bitcoin/console.rb', line 5 def initialize(key:, code:, coin_pair:, **opts) @options = opts || {} @options[:key] = key @options[:code] = code @options[:coin_pair] = coin_pair end |
Instance Attribute Details
#options ⇒ Object
Returns the value of attribute options.
2 3 4 |
# File 'lib/mercado_bitcoin/console.rb', line 2 def @options end |
Instance Method Details
#cancel_order(*args) ⇒ Object
71 72 73 74 75 76 77 78 79 80 81 |
# File 'lib/mercado_bitcoin/console.rb', line 71 def cancel_order(*args) raise ArgumentError.new("faltando ORDER_ID") if args.count < 1 ret = args.map do |id| trade_api.cancel_order(coin_pair: [:coin_pair], order_id: id) end if ret.size > 1 ret else ret[0] end end |
#exec(command, opts) ⇒ Object
12 13 14 |
# File 'lib/mercado_bitcoin/console.rb', line 12 def exec(command, opts) print send(command, *opts) end |
#get_account_info(*args) ⇒ Object
20 21 22 |
# File 'lib/mercado_bitcoin/console.rb', line 20 def get_account_info(*args) trade_api.get_account_info end |
#get_order(*args) ⇒ Object
24 25 26 27 28 29 30 31 32 33 34 |
# File 'lib/mercado_bitcoin/console.rb', line 24 def get_order(*args) raise ArgumentError.new("faltando ORDER_ID") if args.count < 1 ret = args.map do |id| trade_api.get_order(order_id: id) end if ret.size > 1 ret else ret[0] end end |
#get_withdrawal(*args) ⇒ Object
83 84 85 86 87 88 89 90 91 92 93 |
# File 'lib/mercado_bitcoin/console.rb', line 83 def get_withdrawal(*args) raise ArgumentError.new("faltando withdrawal_id") if args.count < 1 ret = args.map do |id| trade_api.get_withdrawal(coin_pair: params[:coin_pair], withdrawal_id: id) end if ret.size > 1 ret else ret[0] end end |
#list_orderbook(*args) ⇒ Object
48 49 50 51 52 53 |
# File 'lib/mercado_bitcoin/console.rb', line 48 def list_orderbook(*args) trade_api.list_orderbook( coin_pair: [:coin_pair], full: [:full] ) end |
#list_orders(*args) ⇒ Object
36 37 38 39 40 41 42 43 44 45 46 |
# File 'lib/mercado_bitcoin/console.rb', line 36 def list_orders(*args) trade_api.list_orders( coin_pair: [:coin_pair], order_type: [:order_type], status_list: [:status_list], has_fills: [:has_fills], from_id: [:from_id], to_id: [:to_id], from_timestamp: [:from_timestamp], to_timestamp: [:to_timestamp]) end |
#list_system_messages(*args) ⇒ Object
16 17 18 |
# File 'lib/mercado_bitcoin/console.rb', line 16 def (*args) trade_api. end |
#place_buy_order(*args) ⇒ Object
55 56 57 58 59 60 61 |
# File 'lib/mercado_bitcoin/console.rb', line 55 def place_buy_order(*args) trade_api.place_buy_order( coin_pair: [:coin_pair], quantity: [:quantity], limit_price: [:limit_price] ) end |
#place_sell_order(*args) ⇒ Object
63 64 65 66 67 68 69 |
# File 'lib/mercado_bitcoin/console.rb', line 63 def place_sell_order(*args) trade_api.place_sell_order( coin_pair: [:coin_pair], quantity: [:quantity], limit_price: [:limit_price] ) end |