Kraken Spot Trade Connector
Features
crypto-krakenConnector KeyNotes
Nonce Window
A nonce window allows API requests with a nonce slightly lower than the previously used value without returning an EAPI:Invalid nonce error.
The connector's nonce is time-based, in milliseconds.
The API key's Nonce Window must be set to 0.
Warning: A non-zero Nonce Window can lead to order duplication
Why am I getting Invalid Nonce Errors?
Rate limits
Rate limits are not enforced internally by the connector.
According to spec:
We have safeguards in place to protect against abuse/DoS attacks as well as order book manipulation caused by the rapid placing and canceling of orders.
Every user of our API has a "call counter" which starts at 0.
Ledger/trade history calls increase the counter by 2.
Place/cancel order calls do not affect the counter.
All other API calls increase the counter by 1.
The user's counter is reduced every couple of seconds, and if the counter exceeds the user's maximum API access is suspended for 15 minutes. Tier 2 users have a maximum of 15 and their count gets reduced by 1 every 3 seconds. Tier 3 and 4 users have a maximum of 20; the count is reduced by 1 every 2 seconds for tier 3 users, and is reduced by 1 every 1 second for tier 4 users.
Although placing and cancelling orders does not increase the counter, there are separate limits in place to prevent order book manipulation. Only placing orders you intend to fill and keeping the rate down to 1 per second is generally enough to not hit this limit.
https://support.kraken.com/hc/en-us/articles/206548367-What-is-the-API-call-rate-limit-
Minimum order sizes
https://support.kraken.com/hc/en-us/articles/205893708-What-is-the-minimum-order-size-
Margin trading
Ways to set leverage (last takes highest priority):
defaultLeverageconnector settingkrakenLeverageinstrument attribute6001custom attribute.
All values are strings and will be transmitted as is.
Info about leverage and margin:
https://support.kraken.com/hc/en-us/sections/200559303-Trading-Leverage-and-Margin
https://support.kraken.com/hc/en-us/articles/209238787-Margin-borrow-limits
https://support.kraken.com/hc/en-us/articles/227876608-Which-currency-pairs-can-I-trade-on-margin-
Cancel all orders after
cancelAllOrdersAfter provides a "Dead Man's Switch" mechanism to protect the client from network malfunction, extreme latency or unexpected matching engine downtime. The client can send a request with a timeout (in seconds), that will start a countdown timer which will cancel all client orders when the timer expires. https://docs.kraken.com/websockets/#message-cancelAllOrdersAfter
Config block sample:
cancelAllOrdersAfter {
period = 30s
timeout = 60s
}
Self Match Prevention Instruction
When selfMatchPreventionInstruction setting is not defined or defined as DEFAULT, the exchange applies CANCEL_TAKING (cancel_newest) by default.
Symbology
Note: If symbols are specified with currency code prefixes, the exchange may return them without those prefixes, causing instrument lookup failures and unmatched orders.
Currency pairs in BASE/QUOTE format, e.g. XBT/USD, LTC/USD.
For the full list of available currency pairs, see the exchange GUI or query the REST API:
https://api.kraken.com/0/public/AssetPairs
https://api.kraken.com/0/public/Assets
Configuration
Connector settings
| Parameter | Default Value | Description |
|---|---|---|
userReferenceId | 2066148683 | 32-bit signed number used for identification outgoing orders. |
defaultLeverage | Leverage allows you to place trades larger than what you have in your collateral balances. | |
webSocketRequestTimeout | 3m | After this time interval websocket request will be considered as lost. Decrease it carefully, can happen that order will be lost and discarded when it have not been created on exchange yet. |
uncertainErrors | ["EService:Unavailable", "EGeneral:Internal error", "EService:Busy"] | List of uncertain errors. When one of them happened on submission, order will be marked as lost (else rejected). |
deadline | 10s | Timestamp after which matching engine should reject new order request, in presence of latency or order queueing. min 5 seconds, max 90 seconds. Defaults to 90 seconds if not specified. |
cancelAllOrdersAfter | not enabled | Has two settings: period, timeout. This feature can work like Cancel-On-Disconnect behavior. https://docs.kraken.com/websockets/#message-cancelAllOrdersAfter |
selfMatchPreventionInstruction | DEFAULT | Optional setting for Self-Trade Prevention function. Supported values: DEFAULT, CANCEL_RESTING, CANCEL_TAKING, CANCEL_BOTH. |
pingPeriod | 60s | Ping requests period. |
Supported order attributes
| Key | Description |
|---|---|
| 6001 | Leverage allows you to place trades larger than what you have in your collateral balances. |
| 18 | '6' value used for post only orders submission |
Config sample
include classpath("crypto-connectors.conf")
connectors {
KRAKEN: ${template.connector.crypto.kraken} {
settings {
restUrl = "https://api.kraken.com"
websocketUrl = "wss://ws-auth.kraken.com"
apiKeys: [
{
apiKey = "API_KEY"
apiSecret = "API_SECRET"
}
]
# each connector instance should have unique integer value for the same account
userReferenceId = 2066148683
}
}
}