Please thoroughly vet everything in the code for yourself before using this gem to buy, sell, or move any of your assets.
PLEASE submit an issue or pull request if you notice any bugs, security holes, or potential improvements. Any help is appreciated!
This gem is a wrapper for the Kraken Digital Asset Trading Platform API. Official documentation from Kraken can be found here.
The current version (0.5.0) can be used to query public/private data and make trades. Private data queries and trading functionality require use of your Kraken account API keys.
Kraken Ruby was built by Alex Leishman and other awesome contributors.
- More comprehensive test suite for methods requiring authentication (using VCR perhaps)
- More comprehensive documentation
Add this line to your application's Gemfile:
gem 'kraken_ruby'
And then execute:
$ bundle
Or install it yourself as:
$ gem install kraken_ruby
Create a Kraken client:
API_KEY = '3bH+M/nLp......'
API_SECRET = 'wQG+7Lr9b.....'
kraken = Kraken::Client.new(API_KEY, API_SECRET)
time = kraken.server_time
time.unixtime #=> 1393056191
This functionality is provided by Kraken to to aid in approximating the skew time between the server and client.
time = kraken.server_time
time.unixtime #=> 1393056191
time.rfc1123 #=> "Sat, 22 Feb 2014 08:28:04 GMT"
Returns the assets that can be traded on the exchange. This method can be passed info
, aclass
(asset class), and asset
options. An example below is given for each:
kraken.assets
pairs = kraken.asset_pairs
ticker_data = kraken.ticker('XLTCXXDG, ZUSDXXVN')
Get market depth information for given asset pairs
depth_data = kraken.order_book('LTCXRP')
Get recent trades
trades = kraken.trades('LTCXRP')
Get spread data for a given asset pair
spread = kraken.spread('LTCXRP')
Get account balance for each asset Note: Rates used for the floating valuation is the midpoint of the best bid and ask prices
balance = kraken.balance
Get account trade balance
trade_balance = kraken.trade_balance
open_orders = kraken.open_orders
closed_orders = kraken.closed_orders
See all orders
orders = kraken.query_orders
Get array of all trades
trades = kraken.trade_history
Input: Comma delimited list of transaction (tx) ids
trades = kraken.query_trades(tx_ids)
Input: Comma delimited list of transaction (tx) ids
positions = kraken.open_positions(tx_ids)
ledgers = kraken.ledgers_info
Input: Comma delimited list of ledger ids
ledgers = kraken.query_ledgers(ledger_ids)
Input: Comma delimited list of asset pairs
asset_pairs = 'XLTCXXDG, ZEURXXDG'
volume = kraken.query_ledgers(asset_pairs)
There are 4 required parameters for buying an order. The example below illustrates the most basic order. Please see the Kraken documentation for the parameters required for more advanced order types.
# buying 0.01 XBT (bitcoin) for XRP (ripple) at market price
opts = {
pair: 'XBTXRP',
type: 'buy',
ordertype: 'market',
volume: 0.01
}
kraken.add_order(opts)
kraken.cancel_order("UKIYSP-9VN27-AJWWYC")
- Fork it
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create new Pull Request