Class: ApiWrapper
- Inherits:
-
Object
show all
- Defined in:
- lib/bitex_bot/models/api_wrappers/api_wrapper.rb
Overview
This class represents the general behaviour for trading platform wrappers.
Defined Under Namespace
Classes: Balance, BalanceSummary, Order, OrderBook, OrderSummary, Transaction, UserTransaction
Constant Summary
collapse
- MIN_AMOUNT =
5
Class Method Summary
collapse
Class Method Details
.amount_and_quantity(_order_id, _transactions) ⇒ Array<Decimal, Decimal>
132
133
134
|
# File 'lib/bitex_bot/models/api_wrappers/api_wrapper.rb', line 132
def self.amount_and_quantity(_order_id, _transactions)
raise 'self subclass responsibility'
end
|
78
79
80
|
# File 'lib/bitex_bot/models/api_wrappers/api_wrapper.rb', line 78
def self.balance
raise 'self subclass responsibility'
end
|
.cancel ⇒ nil
83
84
85
|
# File 'lib/bitex_bot/models/api_wrappers/api_wrapper.rb', line 83
def self.cancel
raise 'self subclass responsibility'
end
|
.enough_order_size?(quantity, price) ⇒ Boolean
136
137
138
|
# File 'lib/bitex_bot/models/api_wrappers/api_wrapper.rb', line 136
def self.enough_order_size?(quantity, price)
(quantity * price) > MIN_AMOUNT
end
|
.find_lost(_type, _price, _quantity) ⇒ Object
Hook Method - arguments could not be used in their entirety by the subclasses
124
125
126
|
# File 'lib/bitex_bot/models/api_wrappers/api_wrapper.rb', line 124
def self.find_lost(_type, _price, _quantity)
raise 'self subclass responsibility'
end
|
.order_book(_retries = 20) ⇒ OrderBook
73
74
75
|
# File 'lib/bitex_bot/models/api_wrappers/api_wrapper.rb', line 73
def self.order_book(_retries = 20)
raise 'self subclass responsibility'
end
|
.orders ⇒ Array<Order>
88
89
90
|
# File 'lib/bitex_bot/models/api_wrappers/api_wrapper.rb', line 88
def self.orders
raise 'self subclass responsibility'
end
|
.place_order(type, price, quantity) ⇒ Object
100
101
102
103
104
105
106
107
108
109
110
111
112
113
|
# File 'lib/bitex_bot/models/api_wrappers/api_wrapper.rb', line 100
def self.place_order(type, price, quantity)
order = send_order(type, price, quantity)
return order unless order.nil? || order.id.nil?
BitexBot::Robot.log(:debug, "Captured error when placing order on #{self.class.name}")
20.times do
BitexBot::Robot.sleep_for(10)
order = find_lost(type, price, quantity)
return order if order.present?
end
raise OrderNotFound, "Closing: #{type} order not found for #{quantity} BTC @ $#{price}. #{order}"
end
|
.send_order(_type, _price, _quantity) ⇒ Object
Hook Method - arguments could not be used in their entirety by the subclasses
116
117
118
|
# File 'lib/bitex_bot/models/api_wrappers/api_wrapper.rb', line 116
def self.send_order(_type, _price, _quantity)
raise 'self subclass responsibility'
end
|
.setup(_settings) ⇒ Void
63
64
65
|
# File 'lib/bitex_bot/models/api_wrappers/api_wrapper.rb', line 63
def self.setup(_settings)
raise 'self subclass responsibility'
end
|
.transactions ⇒ Array<Transaction>
68
69
70
|
# File 'lib/bitex_bot/models/api_wrappers/api_wrapper.rb', line 68
def self.transactions
raise 'self subclass responsibility'
end
|
93
94
95
|
# File 'lib/bitex_bot/models/api_wrappers/api_wrapper.rb', line 93
def self.user_transacitions
raise 'self subclass responsibility'
end
|