Next: Introduction, Previous: (dir), Up: (dir) [Contents][Index]
This is the cl-kraken Reference Manual, version 0.0.3, generated automatically by Declt version 3.0 "Montgomery Scott" on Sun May 15 03:54:14 2022 GMT+0.
• Introduction | What cl-kraken is all about | |
• Systems | The systems documentation | |
• Files | The files documentation | |
• Packages | The packages documentation | |
• Definitions | The symbols documentation | |
• Indexes | Concepts, functions, variables and data types |
CL-KRAKEN is an API wrapper for the Kraken cryptocurrency exchange written in Common Lisp. For the moment, CL-KRAKEN enables all of the public market data API in the Kraken REST API documentation and some of the private user data API. See the API section below for details.
Currently a side project for learning Common Lisp: language, portability, packages, unit testing, interfacing with outside libraries and the real world, and so on. Suggestions and pull requests welcome!
Developed with SBCL (in general the latest version) and tested with:
Allowed failures on Travis are due to CI build issues and not portability ones.
CL-KRAKEN imports a small number of functions from the following Common Lisp libraries: DEXADOR, JSOWN, QURI, LOCAL-TIME, IRONCLAD, CL-BASE64, and for ECL, CFFI.
(ql:quickload :cl-kraken)
(in-package :cl-kraken)
All API calls accept the following optional boolean keyword parameters:
RAW (T or default NIL) to return the JSON response as a raw string instead of parsed and converted to a list data structure.
VERBOSE (T or default NIL) to output the HTTP request headers for verifying and debugging.
;;; ASSET PAIRS
;;; Get data on one or more (or all) asset pairs tradeable on Kraken.
;;; Pairs are passed as an optional case-insensitive, comma-delimited string.
(asset-pairs &key pair raw verbose)
;;;
(asset-pairs)
(asset-pairs :pair "XBTUSD")
(asset-pairs :pair "xbteur,ethusd" :verbose t)
(asset-pairs :pair "XBTUSD, xbteur, ETHJPY, ethgbp" :raw t :verbose t)
;;; ASSETS
;;; Get data on one or more (or all) assets available on Kraken.
;;; Assets are passed as an optional case-insensitive, comma-delimited string.
(assets &key asset raw verbose)
;;;
(assets)
(assets :asset "xbt")
(assets :asset "xbt,usd,eur,dash,xmr" :raw t)
(assets :asset "xbt, USD, eur, JPY, eth, ZEC, ltc" :verbose t)
;;; DEPTH (Order Book)
;;; Get order book price data for an asset pair.
;;; PAIR is a required case-insensitive string representing a single asset pair
;;; for which to query depth.
;;; COUNT is an optional integer of maximum asks and bids to receive.
(depth pair &key count raw verbose)
;;;
(depth "xbteur")
(depth "ADAXBT" :count 1 :raw t)
(depth "LtcUsd" :count 10 :verbose t)
;;; OHLC
;;; Get OHLC (Open, High, Low, Close) price data for an asset pair.
;;; PAIR is a required, case-insensitive string representing a single asset pair
;;; for which to query OHLC data.
;;; INTERVAL is an optional integer time interval in minutes defaulting to 1.
;;; Permitted values are 1, 5, 15, 30, 60, 240, 1440, 10080, 21600.
;;; SINCE is an optional integer Unix Time id to specify from when to return
;;; new committed OHLC data, corresponding to previous OHLC `last' values.
(ohlc pair &key since (interval 1) raw verbose)
;;;
(ohlc "xbteur")
(ohlc "ZECEUR" :since 1548265854 :raw t)
(ohlc "EthUsd" :interval 15 :since 1548265854 :verbose t)
;;; SERVER TIME
;;; Get Kraken server time. Useful to approximate skew time between server and client.
(server-time &key raw verbose)
;;;
(server-time)
(server-time :raw t :verbose t)
;;; SPREAD
;;; Get spread price data for an asset pair.
;;; PAIR is a required, case-insensitive string representing a single asset pair.
;;; SINCE is an optional integer Unix Time id from when to return spread data,
;;; corresponding to previous spread `last' values.
(spread pair &key since raw verbose)
;;;
(spread "XBTEUR")
(spread "zecjpy" :since 1551009182)
(spread "EthUsd" :since 1551009182 :raw t :verbose t)
;;; TICKER
;;; Get ticker data for one or more asset pairs.
;;; Pairs are passed as a required case-insensitive, comma-delimited string.
(ticker pair &key raw verbose)
;;;
(ticker "XBTUSD")
(ticker "xbtusd,etcxbt,XBTEUR")
(ticker "xbtusd, etcxbt, XBTEUR, XBTGBP" :raw t :verbose t)
;;; TRADES
;;; Get recent trades for an asset pair.
;;; PAIR is a required, case-insensitive string representing a single asset pair.
;;; SINCE is an optional integer timestamp id from when to return trades data,
;;; corresponding to previous trades `last' values.
(trades pair &key since raw verbose)
;;;
(trades "xbtusd")
(trades "ETHGBP" :since 1551123951304758112)
(trades "ltcUSD" :since 1551123951304758112 :raw t :verbose t)
;;; TRADE-VOLUME
;;; Get account trade volume.
;;; PAIR is an optional, comma-delimited, case-insensitive asset pair string;
;;; if not provided, defaults to all pairs.
;;; FEE-INFO is an optional boolean whether or not to include fee info in the
;;; result. Note: Currently appears to be not implemented by Kraken, since
;;; the fee info is always returned.
(trade-volume &key pair fee-info raw verbose)
;;;
(trade-volume)
(trade-volume :pair "xbtusd, xbteur")
(trade-volume :pair "ltcGBP" :fee-info t :raw t :verbose t)
To run the test suite, the ROVE test library needs to be loaded.
(ql:quickload :rove)
Then run the tests using one of the following:
(asdf:test-system :cl-kraken) ; Detailed test output.
(rove:run :cl-kraken/tests :style :spec) ; Detailed test output.
(rove:run :cl-kraken/tests :style :dot) ; One dot per test output (in Rove master).
(rove:run :cl-kraken/tests :style :none) ; Minimal test output.
To run the tests of one test file only, append the file name without the extension:
(rove:run :cl-kraken/tests/cryptography) ; Run tests in tests/cryptography.lisp only.
Copyright (c) 2019-2020 Jon Atack (jon@atack.com)
Next: Files, Previous: Introduction, Up: Top [Contents][Index]
The main system appears first, followed by any subsystem dependency.
• The cl-kraken system | ||
• The cl-kraken/src/main system | ||
• The cl-kraken/src/http system | ||
• The cl-kraken/src/globals system | ||
• The cl-kraken/src/cryptography system | ||
• The cl-kraken/src/time system |
Next: The cl-kraken/src/main system, Previous: Systems, Up: Systems [Contents][Index]
Jon Atack <jon@atack.com>
MIT
A Common Lisp API client for the Kraken exchange
0.0.3
cl-kraken/src/main (system)
cl-kraken.asd (file)
Next: The cl-kraken/src/http system, Previous: The cl-kraken system, Up: Systems [Contents][Index]
Jon Atack <jon@atack.com>
MIT
cl-kraken/src/http (system)
cl-kraken.asd (file)
file-type.lisp (file)
Next: The cl-kraken/src/globals system, Previous: The cl-kraken/src/main system, Up: Systems [Contents][Index]
Jon Atack <jon@atack.com>
MIT
cl-kraken.asd (file)
file-type.lisp (file)
Next: The cl-kraken/src/cryptography system, Previous: The cl-kraken/src/http system, Up: Systems [Contents][Index]
Jon Atack <jon@atack.com>
MIT
cl-kraken.asd (file)
file-type.lisp (file)
Next: The cl-kraken/src/time system, Previous: The cl-kraken/src/globals system, Up: Systems [Contents][Index]
Jon Atack <jon@atack.com>
MIT
cl-kraken.asd (file)
file-type.lisp (file)
Previous: The cl-kraken/src/cryptography system, Up: Systems [Contents][Index]
Jon Atack <jon@atack.com>
MIT
cl-kraken.asd (file)
file-type.lisp (file)
Files are sorted by type and then listed depth-first from the systems components trees.
• Lisp files |
Next: The cl-kraken/src/main/file-type․lisp file, Previous: Lisp files, Up: Lisp files [Contents][Index]
cl-kraken.asd
Next: The cl-kraken/src/http/file-type․lisp file, Previous: The cl-kraken․asd file, Up: Lisp files [Contents][Index]
cl-kraken/src/main (system)
src/main.lisp
Next: The cl-kraken/src/globals/file-type․lisp file, Previous: The cl-kraken/src/main/file-type․lisp file, Up: Lisp files [Contents][Index]
cl-kraken/src/http (system)
src/http.lisp
request (function)
Next: The cl-kraken/src/cryptography/file-type․lisp file, Previous: The cl-kraken/src/http/file-type․lisp file, Up: Lisp files [Contents][Index]
cl-kraken/src/globals (system)
src/globals.lisp
Next: The cl-kraken/src/time/file-type․lisp file, Previous: The cl-kraken/src/globals/file-type․lisp file, Up: Lisp files [Contents][Index]
cl-kraken/src/cryptography (system)
src/cryptography.lisp
signature (function)
Previous: The cl-kraken/src/cryptography/file-type․lisp file, Up: Lisp files [Contents][Index]
cl-kraken/src/time (system)
src/time.lisp
Next: Definitions, Previous: Files, Up: Top [Contents][Index]
Packages are listed by definition order.
• The cl-kraken package | ||
• The cl-kraken/src/http package | ||
• The cl-kraken/src/globals package | ||
• The cl-kraken/src/cryptography package | ||
• The cl-kraken/src/time package |
Next: The cl-kraken/src/http package, Previous: Packages, Up: Packages [Contents][Index]
CL-Kraken is Common Lisp client for the Kraken cryptocurrency exchange. Copyright (c) 2019-2020 Jon Atack <jon@atack.com>. See LICENSE for details. The Kraken API is documented here: https://www.kraken.com/help/api.
file-type.lisp (file)
cl-kraken/src/main
common-lisp
Next: The cl-kraken/src/globals package, Previous: The cl-kraken package, Up: Packages [Contents][Index]
HTTP request functions.
file-type.lisp (file)
common-lisp
request (function)
Next: The cl-kraken/src/cryptography package, Previous: The cl-kraken/src/http package, Up: Packages [Contents][Index]
CL-Kraken global parameters, variables and constants.
file-type.lisp (file)
common-lisp
Next: The cl-kraken/src/time package, Previous: The cl-kraken/src/globals package, Up: Packages [Contents][Index]
Cryptographic functions for authenticating private POST requests.
file-type.lisp (file)
common-lisp
signature (function)
Previous: The cl-kraken/src/cryptography package, Up: Packages [Contents][Index]
CL-Kraken time utilities.
file-type.lisp (file)
common-lisp
Definitions are sorted by export status, category, package, and then by lexicographic order.
• Exported definitions | ||
• Internal definitions |
Next: Internal definitions, Previous: Definitions, Up: Definitions [Contents][Index]
• Exported functions |
Previous: Exported definitions, Up: Exported definitions [Contents][Index]
Get tradeable asset pairs.
URL: https://api.kraken.com/0/public/AssetPairs
Input:
‘pair’ = optional, comma-delimited, case-insensitive asset pair string;
if not provided, defaults to all pairs.
Kraken returns a hash with keys ‘error’ and ‘result’.
‘result’ is a hash of pair keys, each with a values hash containing:
‘altname’ = alternate pair name
‘aclass_base’ = asset class of base component
‘base’ = asset id of base component
‘aclass_quote’ = asset class of quote component
‘quote’ = asset id of quote component
‘lot’ = volume lot size
‘pair_decimals’ = scaling decimal places for pair
‘lot_decimals’ = scaling decimal places for volume
‘lot_multiplier’ = multiply lot volume by this to get currency volume
‘leverage_buy’ = array of leverage amounts available when buying
‘leverage_sell’ = array of leverage amounts available when selling
‘fees’ = fee schedule array in [volume, percent fee] tuples
‘fees_maker’ = maker fee schedule array in [volume, percent fee]
tuples (if on maker/taker)
‘fee_volume_currency’ = volume discount currency
‘margin_call’ = margin call level
‘margin_stop’ = stop-out/liquidation margin level
If an asset pair is on a maker/taker fee schedule, the taker side is given in
‘fees’ and maker side in ‘fees_maker’.
For asset pairs not on maker/taker, the rates will only be given in ‘fees’.
file-type.lisp (file)
Get asset info.
URL: https://api.kraken.com/0/public/Assets
Input:
‘asset’ = optional, comma-delimited, case-insensitive asset list string;
if not provided, defaults to all assets.
Kraken returns a hash with keys ‘error’ and ‘result’.
‘result’ is a hash of asset name keys, each with a values hash containing:
‘altname’ = alternate name, like EUR, USD, XBT
‘aclass’ = asset class, currently always set to ’currency’
‘decimals’ = decimal places for record keeping
‘display_decimals’ = decimal places for display (usually fewer)
file-type.lisp (file)
file-type.lisp (file)
Get order book public price data for an asset pair.
URL: https://api.kraken.com/0/public/Depth
Input:
PAIR = required single asset pair for which to query order book
COUNT = optional integer of maximum asks and bids to receive
Kraken returns a hash with keys ‘error’ and ‘result’.
‘result’ is an array containing a pair name and the keys ‘asks’ and ‘bids’
each followed by an array of ‘price’, ‘volume’, and ‘timestamp>’.
file-type.lisp (file)
Kraken requires the nonce to be an always-increasing unsigned integer between 51 and 64 bits in length. For this, we use UNIX-TIME-IN-MICROSECONDS below, expressed as a string. This is analogous to the nonce implementations in the various other Kraken API libraries in C, C++, Go, Python, and Ruby.
file-type.lisp (file)
Get OHLC (Open, High, Low, Close) public price data for an asset pair.
URL: https://api.kraken.com/0/public/OHLC
Input:
PAIR = required single asset pair for which to query OHLC data
INTERVAL = optional integer time interval in minutes defaulting to 1,
permitted values are 1, 5, 15, 30, 60, 240, 1440, 10080, 21600;
Kraken returns an Invalid Arguments error for other values
SINCE = optional integer Unix Time id from when to return new committed
OHLC data, corresponding to previous OHLC ‘last’ values.
Kraken returns a hash with keys ‘error’ and ‘result’.
‘result’ is an array containing a pair name and a ‘last’ Unix Time id.
- The pair name contains an array of arrays, each containing values for
‘time’, ‘open’, ‘high’, ‘low’, ‘close’, ‘VWAP’, ‘volume’ and ‘count’.
- ‘last’ is a Unix Time id for the current not-yet-committed frame.
Useful as value for SINCE when querying for new committed OHLC data.
file-type.lisp (file)
General HTTP GET/POST request and JSON parsing function.
file-type.lisp (file)
Get server time. Useful to approximate skew time between server and client.
URL: https://api.kraken.com/0/public/Time
Kraken returns a hash with keys ‘error’ and ‘result’.
‘result’ is an array of hashes with keys:
‘unixtime’ = unix timestamp
‘rfc1123’ = RFC 1123 time format
file-type.lisp (file)
Signature generated from the HMAC SHA512 of a message and key:
message = (PATH + SHA256(NONCE + POST DATA)) in octets
key = base64-decoded SECRET in octets
Before returning, the signature is converted from octets to a base64 string.
file-type.lisp (file)
Get recent spread data for an asset pair.
URL: https://api.kraken.com/0/public/Spread
Input:
PAIR = required single asset pair for which to query spread data
SINCE = optional integer Unix Time id from when to return spread data,
corresponding to previous spread ‘last’ values.
Note: SINCE is inclusive, so any returned data with the same time as
a previous set should overwrite all of the previous set’s entries.
Kraken returns a hash with keys ‘error’ and ‘result’.
‘result’ is an array containing a pair name and a ‘last’ Unix Time id.
- The pair name contains an array of arrays for ‘time’, ‘bid’, and ‘ask’.
- ‘last’ is a Unix Time id to use for SINCE when querying new spread.
file-type.lisp (file)
Get ticker data for asset pairs.
URL: https://api.kraken.com/0/public/Ticker
Input:
‘pair’ = required comma-delimited list of one or more asset pairs.
Kraken returns a hash with keys ‘error’ and ‘result’.
‘result’ is a hash of pair keys, each with a values hash of ticker data:
a = ask array (price, whole lot volume, lot volume)
b = bid array (price, whole lot volume, lot volume)
c = last trade closed array (price, lot volume)
v = volume array (today, last 24 hours)
p = volume weighted avg price array (today, last 24 hours)
t = number of trades array (today, last 24 hours)
l = low array (today, last 24 hours)
h = high array (today, last 24 hours)
o = opening price (today, at 00:00:00 UTC)
file-type.lisp (file)
file-type.lisp (file)
Get trade volume.
URL: https://api.kraken.com/0/private/TradeVolume
Input:
PAIR = optional, comma-delimited, case-insensitive asset pair string;
if not provided, defaults to all pairs.
FEE-INFO = optional boolean whether or not to include fee info in results.
Note: Currently appears to be not implemented by Kraken, since
the fee info is always returned.
Kraken returns a hash with keys ‘error’ and ‘result’.
‘result’ is a hash of pair keys, each with a values hash containing:
‘currency’ = volume currency
‘volume’ = current discount volume
‘fees’ = array of asset pairs with *taker* fee tier data
‘fee’ = current fee in percent
‘minfee’ = minimum fee for pair (if not fixed fee)
‘maxfee’ = maximum fee for pair (if not fixed fee)
‘nextfee’ = next tier’s fee for pair
(if not fixed fee, nil if at lowest fee tier)
‘nextvolume’ = volume level of next tier
(if not fixed fee, nil if at lowest fee tier)
‘tiervolume’ = volume level of current tier
(if not fixed fee, nil if at lowest fee tier)
‘fees_maker’ = array of asset pairs with *maker* fee tier data for any
pairs on a maker/taker fee schedule
‘fee’ = current fee in percent
‘minfee’ = minimum fee for pair (if not fixed fee)
‘maxfee’ = maximum fee for pair (if not fixed fee)
‘nextfee’ = next tier’s fee for pair
(if not fixed fee, nil if at lowest fee tier)
‘nextvolume’ = volume level of next tier
(if not fixed fee, nil if at lowest fee tier)
‘tiervolume’ = volume level of current tier
(if not fixed fee, nil if at lowest fee tier)
If an asset pair is on a maker/taker fee schedule, the taker side is given in
‘fees’ and maker side in ‘fees_maker’.
For asset pairs not on maker/taker, the rates will only be given in ‘fees’.
file-type.lisp (file)
Get recent trades public price data for an asset pair.
URL: https://api.kraken.com/0/public/Trades
Input:
PAIR = required single asset pair for which to query trades data
SINCE = optional integer timestamp id from when to return new trades data,
corresponding to previous trades ‘last’ values.
Kraken returns a hash with keys ‘error’ and ‘result’.
‘result’ is an array containing a pair name and a ‘last’ Unix Time id.
- The pair name is followed by an array of maximum 1000 trades containing
‘price’, ‘volume’, ‘time’, ‘buy/sell’, ‘market/limit’, ‘miscellaneous’.
- ‘last’ is a timestamp id to use for SINCE when querying new trades.
file-type.lisp (file)
Unix Time in usec using SBCL’s SB-EXT:GET-TIME-OF-DAY.
file-type.lisp (file)
Previous: Exported definitions, Up: Definitions [Contents][Index]
• Internal special variables | ||
• Internal functions |
Next: Internal functions, Previous: Internal definitions, Up: Internal definitions [Contents][Index]
This is an empty account for testing. Replace this value with your API key.
file-type.lisp (file)
This is an empty account for testing. Replace this vaule with your API secret.
file-type.lisp (file)
file-type.lisp (file)
file-type.lisp (file)
file-type.lisp (file)
file-type.lisp (file)
file-type.lisp (file)
file-type.lisp (file)
file-type.lisp (file)
file-type.lisp (file)
Previous: Internal special variables, Up: Internal definitions [Contents][Index]
HTTP GET request for public API queries.
file-type.lisp (file)
Evaluates to an SHA256 digest of the message. Input and output in octets.
file-type.lisp (file)
Evaluates to an HMAC SHA512 signature. Inputs and output in octets.
file-type.lisp (file)
(PATH + SHA256(NONCE + POST DATA)) in octets.
file-type.lisp (file)
Kraken POST HTTP headers must contain the API key and signature.
file-type.lisp (file)
HTTP POST request for private authenticated API queries.
file-type.lisp (file)
Previous: Definitions, Up: Top [Contents][Index]
• Concept index | ||
• Function index | ||
• Variable index | ||
• Data type index |
Next: Function index, Previous: Indexes, Up: Indexes [Contents][Index]
Jump to: | C F L |
---|
Jump to: | C F L |
---|
Next: Variable index, Previous: Concept index, Up: Indexes [Contents][Index]
Jump to: | A B D F G H M O P R S T U |
---|
Jump to: | A B D F G H M O P R S T U |
---|
Next: Data type index, Previous: Function index, Up: Indexes [Contents][Index]
Jump to: | *
+
S |
---|
Jump to: | *
+
S |
---|
Previous: Variable index, Up: Indexes [Contents][Index]
Jump to: | C P S |
---|
Jump to: | C P S |
---|