pub struct Kraken_API { /* private fields */ }
Expand description

A handle on the connection to the Kraken exchange.

This can be used multiple times, so should only be instantiated once, preferably using the connect function; due to the nature of the exchange and the REST API it does not make sense to make multiple requests in parallel, and so there should be no need for more than one of these objects to be instantiated.

This object has a method implemented on it for every end-point in the Kraken API, which will make the call to the exchange as appropriate and marshall the returned data through the method’s return object, described below.

Optional arguments

Many of the Kraken functions (end-points) can take optional extra arguments. These are set into the Kraken_API object prior to making a function call, and then those arguments which have been set and are pertinent to that function will be passed along. The documentation for the individual functions below indicates the options pertinent to that function.

The set of optional arguments persist between function calls: this may work in your favour or against you depending on your work flow. In any case, use the methods Kraken_API::set_opt, Kraken_API::clear_opt and Kraken_API::clear_all_options to manipulate the current option set.

Errors

Errors which occur at our end, such as failure to contact the Kraken exchange, or to perform our own processing, are signalled by returns of Result::Err(String) in which the string is a human-readable explanation of the problem.

Errors which occur at the Kraken exchange, such as failure to authenticate the user, are signalled by an ‘error’ entry in the JSON string returned as a Result::Ok(String).

A successful return of data from the exchange will be seen with a ‘result’ section in the JSON string returned as Result::Ok(String).

Implementations

Give a value to the optional argument, which may be passed to the Kraken end-point if the end-point accepts this option.

Clear an option; this will not be sent to any end-points which would accept such an optional argument.

The options set in a Kraken_API object are persistent across back-end calls; it may be prudent to call this method to make sure the set of options is in a well-known state, before making settings for the next back-end call.

Retrieve all cash balances.

Here is the Kraken documentation.

Get a summary of standing with an asset.

Here is the Kraken documentation.

This function understands the API_Option::ASSET optional argument.

Get detailed information about currently open orders.

The Kraken documentation is here.

The end-point is responsive to the API_Option::TRADES and API_Option::USERREF optional arguments.

Get a detailed list of closed orders, paged to up to 50 at a time.

Here is the Kraken documentation.

This function accepts API_Option::TRADES, API_Option::USERREF, API_Option::START, API_Option::END, API_Option::OFS, and API_Option::CLOSE_TIME optional arguments.

Get a list of order details.

This function is variously known in the Kraken documentation as ‘Query Orders Info’, ‘GetOrdersInfo’ and ‘QueryOrders’.

We see that ‘txid’ can be a comma-separated list of transaction identifiers, and that options API_Option::TRADES and API_Option::USERREF can optionally be set in the ‘self’ Kraken_API object prior to this call.

Get a detailed list of past trades, paged to up to 50 at a time.

The upstream documentation is here.

The function accepts API_Option::TYPE, API_Option::TRADES, API_Option::START, API_Option::END, and API_Option::OFS optional arguments.

Get information about specific trades.

This function is known in the Kraken documentation as ‘getTradesInfo’, ‘QueryTrades’ and ‘Query Trades Info’.

We see that ‘txid’ can be a comma-separated list of transaction IDs, and the function accepts the API_Option::TRADES option, a string holding either “true” or “false”.

This function is for getting information about open margin positions.

The end-point documentation is at Kraken, where it is known as ‘getOpenPositions’.

The method is sensitive to the optional arguments API_Option::TXID, API_Option::DO_CALCS and API_Option::CONSOLIDATION.

Retrieve information about ledger entries.

This end-point is known variously as “GetLedgersInfo”, “getLedgers” and “Ledgers” in the Kraken documentation.

The function is sensitive to the API_Option::ACLASS, API_Option::ASSET, API_Option::TYPE, API_Option::START, API_Option::END and API_Option::OFS optional arguments.

Retrieve information about specific ledger entries.

Here is the Kraken documentation.

This is sensitive to the API_Option::TRADES and API_Option::ID optional arguments.

Get trade volue.

Documented at Kraken.

The pair argument is the trading pair, e.g., “XETCXETH”, for which data are required.

The function also accepts the API_Option::FEE_INFO optional argument, to indicate that fee information should be included in the returned result set.

Request export of trades or ledgers.

The upstream documentation is here.

Also uses the API_Option::FORMAT, API_Option::FIELDS, API_Option::START_TIME and API_Option::END_TIME optional arguments.

Get status of requested data exports.

The Kraken documentation is here.

Retrieve a processed data export.

The end-point documentation is here.

Delete an exported data report.

Here is the upstream documentation.

NOTE that type MUST be one of the strings “delete” or “cancel”, or a panic may occur.

Edit an order on the exchange’s order book.

The upstream documentation is here.

The following optional arguments are considered by this end-point: API_Option::USERREF, API_Option::PRICE, API_Option::PRICE_2, API_Option::OFLAGS, API_Option::VOLUME, API_Option::DEADLINE, API_Option::CANCEL_RESPONSE, and API_Option::VALIDATE.

Cancel an open order.

The documentation for this end-point is at Kraken. Note that ‘txid’ can actually be a ‘userref’, in which case all open orders for that user are cancelled.

Cancel all orders open on this account.

The documentation for this end-point is at Kraken.

Dead man’s switch will cancel all orders after a time if not reset.

The upstream documentation is here.

Get the server’s time. Documented upstream here.

Get the current exchange system status.

Documented upstream here.

Get information about the assets that are available at this time at this exchange.

The upstream documentation is here.

The function is responsive to the API_Option::ACLASS and API_Option::ASSET optional arguments.

Get tradable asset pairs.

Documented at Kraken.

The optional arguments API_Option::INFO and API_Option::PAIR will be used if set.

Get ticker information.

The upstream documentation is here.

Get OLHC (open, low, high, close) data.

The end-point is documented upstream here.

The method respects the optional arguments API_Option::INTERVAL and API_Option::SINCE.

Get live order book data.

Upstream documentation is at Kraken.

This end-point uses the optional argument API_Option::COUNT to limit the depth of data into the order book.

Get recent trades made at the exchange.

Documented upstream.

Allows the optional argument API_Option::SINCE.

Get recent spreads.

Documented upstream here.

Respects the optional argument API_Option::SINCE.

Trait Implementations

Returns the “default value” for a type. Read more

Auto Trait Implementations

Blanket Implementations

Gets the TypeId of self. Read more

Immutably borrows from an owned value. Read more

Mutably borrows from an owned value. Read more

Returns the argument unchanged.

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

The type returned in the event of a conversion error.

Performs the conversion.

The type returned in the event of a conversion error.

Performs the conversion.