The cl-kraken Reference Manual

This is the cl-kraken Reference Manual, version 0.0.3, generated automatically by Declt version 4.0 beta 2 "William Riker" on Mon Jul 15 04:02:53 2024 GMT+0.

Table of Contents


1 Introduction


2 Systems

The main system appears first, followed by any subsystem dependency.


2.1 cl-kraken

A Common Lisp API client for the Kraken exchange

Author

Jon Atack <>

Home Page

https://github.com/jonatack/cl-kraken

License

MIT

Version

0.0.3

Dependency

cl-kraken/src/main (system).

Source

cl-kraken.asd.


2.2 cl-kraken/src/main

Author

Jon Atack <>

Home Page

https://github.com/jonatack/cl-kraken

License

MIT

Dependency

cl-kraken/src/http (system).

Source

cl-kraken.asd.


2.3 cl-kraken/src/http

Author

Jon Atack <>

Home Page

https://github.com/jonatack/cl-kraken

License

MIT

Dependencies
Source

cl-kraken.asd.


2.4 cl-kraken/src/globals

Author

Jon Atack <>

Home Page

https://github.com/jonatack/cl-kraken

License

MIT

Source

cl-kraken.asd.


2.5 cl-kraken/src/cryptography

Author

Jon Atack <>

Home Page

https://github.com/jonatack/cl-kraken

License

MIT

Dependencies
  • ironclad (system).
  • cl-base64 (system).
  • quri (system).
Source

cl-kraken.asd.


2.6 cl-kraken/src/time

Author

Jon Atack <>

Home Page

https://github.com/jonatack/cl-kraken

License

MIT

Source

cl-kraken.asd.


3 Files

Files are sorted by type and then listed depth-first from the systems components trees.


3.1 Lisp


3.1.1 cl-kraken/cl-kraken.asd

Source

cl-kraken.asd.

Parent Component

cl-kraken (system).

ASDF Systems

3.1.2 cl-kraken/src/main/file-type.lisp

Source

cl-kraken.asd.

Parent Component

cl-kraken/src/main (system).

Packages

cl-kraken.

Public Interface

3.1.3 cl-kraken/src/http/file-type.lisp

Source

cl-kraken.asd.

Parent Component

cl-kraken/src/http (system).

Packages

cl-kraken/src/http.

Public Interface

request (function).

Internals

3.1.4 cl-kraken/src/globals/file-type.lisp

Source

cl-kraken.asd.

Parent Component

cl-kraken/src/globals (system).

Packages

cl-kraken/src/globals.

Internals

3.1.5 cl-kraken/src/cryptography/file-type.lisp

Source

cl-kraken.asd.

Parent Component

cl-kraken/src/cryptography (system).

Packages

cl-kraken/src/cryptography.

Public Interface

signature (function).

Internals

3.1.6 cl-kraken/src/time/file-type.lisp

Source

cl-kraken.asd.

Parent Component

cl-kraken/src/time (system).

Packages

cl-kraken/src/time.

Public Interface
Internals

4 Packages

Packages are listed by definition order.


4.1 cl-kraken/src/time

CL-Kraken time utilities.

Source

file-type.lisp.

Use List

common-lisp.

Public Interface
Internals

4.2 cl-kraken/src/cryptography

Cryptographic functions for authenticating private POST requests.

Source

file-type.lisp.

Use List

common-lisp.

Public Interface

signature (function).

Internals

4.3 cl-kraken/src/http

HTTP request functions.

Source

file-type.lisp.

Use List

common-lisp.

Public Interface

request (function).

Internals

4.4 cl-kraken

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.

Source

file-type.lisp.

Nickname

cl-kraken/src/main

Use List

common-lisp.

Public Interface

4.5 cl-kraken/src/globals

CL-Kraken global parameters, variables and constants.

Source

file-type.lisp.

Use List

common-lisp.

Internals

5 Definitions

Definitions are sorted by export status, category, package, and then by lexicographic order.


5.1 Public Interface


5.1.1 Ordinary functions

Function: asset-pairs (&key pair raw verbose)

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’.

Package

cl-kraken.

Source

file-type.lisp.

Function: assets (&key asset raw verbose)

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)

Package

cl-kraken.

Source

file-type.lisp.

Function: balance (&key raw verbose)
Package

cl-kraken.

Source

file-type.lisp.

Function: depth (pair &key count raw verbose)

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>’.

Package

cl-kraken.

Source

file-type.lisp.

Function: generate-kraken-nonce ()

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.

Package

cl-kraken/src/time.

Source

file-type.lisp.

Function: ohlc (pair &key since interval raw verbose)

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.

Package

cl-kraken.

Source

file-type.lisp.

Function: request (method &key params post raw verbose)

General HTTP GET/POST request and JSON parsing function.

Package

cl-kraken/src/http.

Source

file-type.lisp.

Function: server-time (&key raw verbose)

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

Package

cl-kraken.

Source

file-type.lisp.

Function: signature (path nonce data secret)

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.

Package

cl-kraken/src/cryptography.

Source

file-type.lisp.

Function: spread (pair &key since raw verbose)

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.

Package

cl-kraken.

Source

file-type.lisp.

Function: ticker (pair &key raw verbose)

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)

Package

cl-kraken.

Source

file-type.lisp.

Function: trade-balance (&key raw verbose)
Package

cl-kraken.

Source

file-type.lisp.

Function: trade-volume (&key pair fee-info raw verbose)

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’.

Package

cl-kraken.

Source

file-type.lisp.

Function: trades (pair &key since raw verbose)

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.

Package

cl-kraken.

Source

file-type.lisp.

Function: unix-time-in-microseconds ()

Unix Time in usec using SBCL’s SB-EXT:GET-TIME-OF-DAY.

Package

cl-kraken/src/time.

Source

file-type.lisp.


5.2 Internals


5.2.1 Special variables

Special Variable: *api-key*

This is an empty account for testing. Replace this value with your API key.

Package

cl-kraken/src/globals.

Source

file-type.lisp.

Special Variable: *api-secret*

This is an empty account for testing. Replace this vaule with your API secret.

Package

cl-kraken/src/globals.

Source

file-type.lisp.

Special Variable: +api-host+
Package

cl-kraken/src/globals.

Source

file-type.lisp.

Special Variable: +api-private-path+
Package

cl-kraken/src/globals.

Source

file-type.lisp.

Special Variable: +api-public-path+
Package

cl-kraken/src/globals.

Source

file-type.lisp.

Special Variable: +api-scheme+
Package

cl-kraken/src/globals.

Source

file-type.lisp.

Special Variable: +api-version+
Package

cl-kraken/src/globals.

Source

file-type.lisp.

Special Variable: +one-million+
Package

cl-kraken/src/time.

Source

file-type.lisp.

Special Variable: +one-thousand+
Package

cl-kraken/src/time.

Source

file-type.lisp.

Special Variable: +version+
Package

cl-kraken/src/globals.

Source

file-type.lisp.


5.2.2 Ordinary functions

Function: get-public (method &key params verbose scheme host)

HTTP GET request for public API queries.

Package

cl-kraken/src/http.

Source

file-type.lisp.

Function: hash-sha256 (message)

Evaluates to an SHA256 digest of the message. Input and output in octets.

Package

cl-kraken/src/cryptography.

Source

file-type.lisp.

Function: hmac-sha512 (message secret)

Evaluates to an HMAC SHA512 signature. Inputs and output in octets.

Package

cl-kraken/src/cryptography.

Source

file-type.lisp.

Function: message (path nonce data)

(PATH + SHA256(NONCE + POST DATA)) in octets.

Package

cl-kraken/src/cryptography.

Source

file-type.lisp.

Function: post-http-headers (path nonce data key secret)

Kraken POST HTTP headers must contain the API key and signature.

Package

cl-kraken/src/http.

Source

file-type.lisp.

Function: post-private (method &key params verbose scheme host key secret)

HTTP POST request for private authenticated API queries.

Package

cl-kraken/src/http.

Source

file-type.lisp.


Appendix A Indexes


A.1 Concepts


A.2 Functions

Jump to:   A   B   D   F   G   H   M   O   P   R   S   T   U  
Index Entry  Section

A
asset-pairs: Public ordinary functions
assets: Public ordinary functions

B
balance: Public ordinary functions

D
depth: Public ordinary functions

F
Function, asset-pairs: Public ordinary functions
Function, assets: Public ordinary functions
Function, balance: Public ordinary functions
Function, depth: Public ordinary functions
Function, generate-kraken-nonce: Public ordinary functions
Function, get-public: Private ordinary functions
Function, hash-sha256: Private ordinary functions
Function, hmac-sha512: Private ordinary functions
Function, message: Private ordinary functions
Function, ohlc: Public ordinary functions
Function, post-http-headers: Private ordinary functions
Function, post-private: Private ordinary functions
Function, request: Public ordinary functions
Function, server-time: Public ordinary functions
Function, signature: Public ordinary functions
Function, spread: Public ordinary functions
Function, ticker: Public ordinary functions
Function, trade-balance: Public ordinary functions
Function, trade-volume: Public ordinary functions
Function, trades: Public ordinary functions
Function, unix-time-in-microseconds: Public ordinary functions

G
generate-kraken-nonce: Public ordinary functions
get-public: Private ordinary functions

H
hash-sha256: Private ordinary functions
hmac-sha512: Private ordinary functions

M
message: Private ordinary functions

O
ohlc: Public ordinary functions

P
post-http-headers: Private ordinary functions
post-private: Private ordinary functions

R
request: Public ordinary functions

S
server-time: Public ordinary functions
signature: Public ordinary functions
spread: Public ordinary functions

T
ticker: Public ordinary functions
trade-balance: Public ordinary functions
trade-volume: Public ordinary functions
trades: Public ordinary functions

U
unix-time-in-microseconds: Public ordinary functions


A.4 Data types

Jump to:   C   F   P   S  
Index Entry  Section

C
cl-kraken: The cl-kraken system
cl-kraken: The cl-kraken package
cl-kraken.asd: The cl-kraken/cl-kraken․asd file
cl-kraken/src/cryptography: The cl-kraken/src/cryptography system
cl-kraken/src/cryptography: The cl-kraken/src/cryptography package
cl-kraken/src/globals: The cl-kraken/src/globals system
cl-kraken/src/globals: The cl-kraken/src/globals package
cl-kraken/src/http: The cl-kraken/src/http system
cl-kraken/src/http: The cl-kraken/src/http package
cl-kraken/src/main: The cl-kraken/src/main system
cl-kraken/src/time: The cl-kraken/src/time system
cl-kraken/src/time: The cl-kraken/src/time package

F
File, cl-kraken.asd: The cl-kraken/cl-kraken․asd file
File, file-type.lisp: The cl-kraken/src/main/file-type․lisp file
File, file-type.lisp: The cl-kraken/src/http/file-type․lisp file
File, file-type.lisp: The cl-kraken/src/globals/file-type․lisp file
File, file-type.lisp: The cl-kraken/src/cryptography/file-type․lisp file
File, file-type.lisp: The cl-kraken/src/time/file-type․lisp file
file-type.lisp: The cl-kraken/src/main/file-type․lisp file
file-type.lisp: The cl-kraken/src/http/file-type․lisp file
file-type.lisp: The cl-kraken/src/globals/file-type․lisp file
file-type.lisp: The cl-kraken/src/cryptography/file-type․lisp file
file-type.lisp: The cl-kraken/src/time/file-type․lisp file

P
Package, cl-kraken: The cl-kraken package
Package, cl-kraken/src/cryptography: The cl-kraken/src/cryptography package
Package, cl-kraken/src/globals: The cl-kraken/src/globals package
Package, cl-kraken/src/http: The cl-kraken/src/http package
Package, cl-kraken/src/time: The cl-kraken/src/time package

S
System, cl-kraken: The cl-kraken system
System, cl-kraken/src/cryptography: The cl-kraken/src/cryptography system
System, cl-kraken/src/globals: The cl-kraken/src/globals system
System, cl-kraken/src/http: The cl-kraken/src/http system
System, cl-kraken/src/main: The cl-kraken/src/main system
System, cl-kraken/src/time: The cl-kraken/src/time system