Module: Bitstamp
- Defined in:
- lib/bitstamp.rb,
lib/bitstamp/net.rb,
lib/bitstamp/model.rb,
lib/bitstamp/helper.rb,
lib/bitstamp/orders.rb,
lib/bitstamp/ticker.rb,
lib/bitstamp/collection.rb,
lib/bitstamp/transactions.rb
Defined Under Namespace
Modules: Helper, Net
Classes: Collection, MissingConfigExeception, Model, Order, Orders, Ticker, Transactions, UserTransaction, UserTransactions
Constant Summary
collapse
- @@currency =
:usd
Class Method Summary
collapse
Class Method Details
.balance(currency_pair = "btcusd") ⇒ Object
50
51
52
53
54
|
# File 'lib/bitstamp.rb', line 50
def self.balance(currency_pair = "btcusd")
self.sanity_check!
path = currency_pair ? "/v2/balance/#{currency_pair}" : "/v2/balance"
JSON.parse Bitstamp::Net.post(path).to_str
end
|
.bitcoin_deposit_address ⇒ Object
73
74
75
76
77
|
# File 'lib/bitstamp.rb', line 73
def self.bitcoin_deposit_address
self.sanity_check!
return Bitstamp::Net.post('/bitcoin_deposit_address').to_str
end
|
96
97
98
|
# File 'lib/bitstamp.rb', line 96
def self.configured?
self.key && self.secret && self.client_id
end
|
.create_withdrawal(options = {}) ⇒ Object
56
57
58
59
|
# File 'lib/bitstamp.rb', line 56
def self.create_withdrawal(options = {})
self.sanity_check!
Bitstamp::Withdrawals.new.create(options)
end
|
.order_book(currency_pair = "btcusd") ⇒ Object
88
89
90
|
# File 'lib/bitstamp.rb', line 88
def self.order_book(currency_pair = "btcusd")
return JSON.parse Bitstamp::Net.get("/v2/order_book/#{currency_pair}").to_str
end
|
.orders ⇒ Object
34
35
36
37
38
|
# File 'lib/bitstamp.rb', line 34
def self.orders
self.sanity_check!
@@orders ||= Bitstamp::Orders.new
end
|
.sanity_check! ⇒ Object
100
101
102
103
104
|
# File 'lib/bitstamp.rb', line 100
def self.sanity_check!
unless configured?
raise MissingConfigExeception.new("Bitstamp Gem not properly configured")
end
end
|
.setup {|_self| ... } ⇒ Object
92
93
94
|
# File 'lib/bitstamp.rb', line 92
def self.setup
yield self
end
|
.ticker(currency_pair = "btcusd") ⇒ Object
84
85
86
|
# File 'lib/bitstamp.rb', line 84
def self.ticker(currency_pair = "btcusd")
return Bitstamp::Ticker.from_api(currency_pair)
end
|
.transactions(currency_pair = "btcusd") ⇒ Object
46
47
48
|
# File 'lib/bitstamp.rb', line 46
def self.transactions(currency_pair = "btcusd")
return Bitstamp::Transactions.from_api(currency_pair)
end
|
.unconfirmed_user_deposits ⇒ Object
79
80
81
82
|
# File 'lib/bitstamp.rb', line 79
def self.unconfirmed_user_deposits
self.sanity_check!
return JSON.parse Bitstamp::Net::post("/unconfirmed_btc").to_str
end
|
.user_transactions ⇒ Object
40
41
42
43
44
|
# File 'lib/bitstamp.rb', line 40
def self.user_transactions
self.sanity_check!
@@transactions ||= Bitstamp::UserTransactions.new
end
|
.withdraw_bitcoins(options = {}) ⇒ Object
61
62
63
64
65
66
67
68
69
70
71
72
|
# File 'lib/bitstamp.rb', line 61
def self.withdraw_bitcoins(options = {})
self.sanity_check!
if options[:amount].nil? || options[:address].nil?
raise MissingConfigExeception.new("Required parameters not supplied, :amount, :address")
end
response_body = Bitstamp::Net.post('/bitcoin_withdrawal',options).to_str
if response_body != 'true'
return JSON.parse response_body
else
return response_body
end
end
|