### Book Channel Snapshot Example Source: https://docs.kraken.com/api/docs/websocket-v2/book This JSON object represents a snapshot of the order book for a given symbol. It includes the current bids, asks, a checksum, and a timestamp. Use this to get the initial state of the order book. ```json { "channel": "book", "type": "snapshot", "data": [ { "symbol": "MATIC/USD", "bids": [ { "price": 0.5666, "qty": 4831.75496356 }, { "price": 0.5665, "qty": 6658.22734739 }, { "price": 0.5664, "qty": 18724.91513344 }, { "price": 0.5663, "qty": 11563.92544914 }, { "price": 0.5662, "qty": 14006.65365711 }, { "price": 0.5661, "qty": 17454.85679807 }, { "price": 0.566, "qty": 18097.1547 }, { "price": 0.5659, "qty": 33644.89175666 }, { "price": 0.5658, "qty": 148.3464 }, { "price": 0.5657, "qty": 606.70854372 } ], "asks": [ { "price": 0.5668, "qty": 4410.79769741 }, { "price": 0.5669, "qty": 4655.40412487 }, { "price": 0.567, "qty": 49844.89424998 }, { "price": 0.5671, "qty": 24306.41678 }, { "price": 0.5672, "qty": 29783.25223475 }, { "price": 0.5673, "qty": 57234.71239278 }, { "price": 0.5674, "qty": 45065.04744 }, { "price": 0.5675, "qty": 5912.76380354 }, { "price": 0.5676, "qty": 42514.92434778 }, { "price": 0.5677, "qty": 36304.0847022 } ], "checksum": 2439117997, "timestamp": "2023-10-06T17:35:55.440295Z" } ] } ``` -------------------------------- ### Deposit Update Example Source: https://docs.kraken.com/api/docs/websocket-v2/balances A JSON representation of a balance update message triggered by a deposit transaction. ```json { "channel": "balances", "type": "update", "data": [ { "ledger_id": "ADKKFF-WEA5A-CNUBHG", "ref_id": "AGBWUJRU-LAREZ-W3UFAN", "timestamp": "2023-09-22T10:23:42.925034Z", "type": "deposit", "asset": "BTC", "asset_class": "currency", "category": "deposit", "wallet_type": "spot", "wallet_id": "main", "amount": 0.01, "fee": 0.0, "balance": 0.02 } ], "sequence": 2 } ``` -------------------------------- ### Example amend_order success response Source: https://docs.kraken.com/api/docs/websocket-v2/amend_order A sample JSON response for an order successfully amended with a client order identifier. ```json { "method": "amend_order", "result": { "amend_id": "TTW6PD-RC36L-ZZSWNU", "cl_ord_id": "2c6be801-1f53-4f79-a0bb-4ea1c95dfae9" }, "success": true, "time_in": "2024-07-26T13:39:04.922699Z", "time_out": "2024-07-26T13:39:04.924912Z" } ``` -------------------------------- ### Execution Update Message Examples Source: https://docs.kraken.com/api/docs/websocket-v2/executions JSON payloads representing different states of an order execution update. ```json { "channel": "executions", "type": "update", "data": [ { "order_id": "OK4GJX-KSTLS-7DZZO5", "order_userref": 3, "symbol": "BTC/USD", "order_qty": 0.005, "cum_cost": 0.0, "time_in_force": "GTC", "exec_type": "pending_new", "side": "sell", "order_type": "limit", "limit_price_type": "static", "limit_price": 26500.0, "stop_price": 0.0, "order_status": "pending_new", "fee_usd_equiv": 0.0, "fee_ccy_pref": "fciq", "timestamp": "2023-09-22T10:33:05.709950Z" } ], "sequence": 8 } ``` ```json { "channel": "executions", "type": "update", "data": [ { "timestamp": "2023-09-22T10:33:05.709982Z", "order_status": "new", "exec_type": "new", "order_userref": 3, "order_id": "OK4GJX-KSTLS-7DZZO5" } ], "sequence": 9 } ``` ```json { "channel": "executions", "type": "update", "data": [ { "order_id": "OK4GJX-KSTLS-7DZZO5", "order_userref": 3, "exec_id": "TGBB7L-HT5LX-J3BZ4A", "exec_type": "trade", "trade_id": 62887576, "symbol": "BTC/USD", "side": "sell", "last_qty": 0.005, "last_price": 26599.9, "liquidity_ind": "t", "cost": 132.9995, "order_type": "limit", "timestamp": "2023-09-22T10:33:05.709993Z", "order_status": "partially_filled", "cum_qty": 0.005, "cum_cost": 132.9995, "avg_price": 26599.9, "fee_usd_equiv": 0.3458, "fees": [ { "asset": "USD", "qty": 0.3458 } ] } ], "sequence": 10 } ``` -------------------------------- ### Instrument Channel Snapshot Message Source: https://docs.kraken.com/api/docs/websocket-v2/instrument Example of a full snapshot message received from the instrument channel. ```json { "channel": "instrument", "type": "snapshot", "data": { "assets": [ { "id": "USD", "status": "enabled", "precision": 4, "precision_display": 2, "borrowable": true, "collateral_value": 1.0, "margin_rate": 0.015 }, { "id": "BTC", "status": "enabled", "precision": 10, "precision_display": 5, "borrowable": true, "collateral_value": 1.0, "margin_rate": 0.01 }, { "id": "XRP", "status": "enabled", "precision": 8, "precision_display": 5, "borrowable": true, "collateral_value": 0.0, "margin_rate": 0.02 } ], "pairs": [ { "symbol": "BTC/USD", "base": "BTC", "quote": "USD", "status": "online", "qty_precision": 8, "qty_increment": 1e-08, "price_precision": 1, "cost_precision": 5, "marginable": true, "has_index": true, "cost_min": 0.5, "margin_initial": 0.2, "position_limit_long": 250, "position_limit_short": 200, "tick_size": 0.1, "price_increment": 0.1, "qty_min": 0.0001 }, { "symbol": "MATIC/GBP", "base": "MATIC", "quote": "GBP", "status": "online", "qty_precision": 8, "qty_increment": 1e-08, "price_precision": 4, "cost_precision": 6, "marginable": false, "has_index": true, "cost_min": 0.43, "tick_size": 0.0001, "price_increment": 0.0001, "qty_min": 4.0 } ] } } ``` -------------------------------- ### Balances Channel Subscription Acknowledgment Source: https://docs.kraken.com/api/docs/websocket-v2/balances This is an example of a successful subscription acknowledgment for the balances channel. It confirms the subscription and indicates if a snapshot was requested. ```json { "method": "subscribe", "result": { "channel": "balances", "snapshot": true }, "success": true, "time_in": "2023-10-16T13:29:13.111530Z", "time_out": "2023-10-16T13:29:13.111775Z" } ``` -------------------------------- ### Book Channel Update Example Source: https://docs.kraken.com/api/docs/websocket-v2/book This JSON object represents an update to the order book for a given symbol. It contains changes to bids and/or asks, along with a checksum and timestamp. Use this to incrementally update your view of the order book. ```json { "channel": "book", "type": "update", "data": [ { "symbol": "MATIC/USD", "bids": [ { "price": 0.5657, "qty": 1098.3947558 } ], "asks": [], "checksum": 2114181697, "timestamp": "2023-10-06T17:35:55.440295Z" } ] } ``` -------------------------------- ### Level 3 Snapshot JSON Structure Source: https://docs.kraken.com/api/docs/websocket-v2/level3 Example of a level3 channel snapshot message containing symbol, checksum, and lists of bid and ask orders. ```json { "channel": "level3", "type": "snapshot", "data": [ { "symbol": "MATIC/USD", "checksum": 281817320, "bids": [ { "order_id": "O6ZQNQ-BXL4E-5WGINO", "limit_price": 0.5629, "order_qty": 111.56125344, "timestamp": "2023-10-06T17:35:00.279389650Z" }, { "order_id": "OEP26Y-YAFEF-OFR62B", "limit_price": 0.5625, "order_qty": 6390.19338, "timestamp": "2023-10-06T18:19:55.056070105Z" }, { "order_id": "OKNAY7-67JRK-AIZ4JO", "limit_price": 0.5625, "order_qty": 14084.5, "timestamp": "2023-10-06T18:20:55.357467423Z" } ], "asks": [ { "order_id": "OLLSXO-HDMT3-BUOKEI", "limit_price": 0.563, "order_qty": 4422.9978357, "timestamp": "2023-10-06T18:18:20.734897896Z" }, { "order_id": "O5SR5W-L7OLY-BLDEJV", "limit_price": 0.563, "order_qty": 420.0, "timestamp": "2023-10-06T18:18:20.738706230Z" }, { "order_id": "OXV6QS-2GG4Q-F4EECM", "limit_price": 0.563, "order_qty": 490.0, "timestamp": "2023-10-06T18:18:21.064657206Z" } ] } ] } ``` -------------------------------- ### edit_order Response Example Source: https://docs.kraken.com/api/docs/websocket-v2/edit_order A successful response object for an edit_order request, containing the new and original order IDs. ```json { "method": "edit_order", "req_id": 1234567890, "result": { "order_id": "ORDERX-IDXXX-XXXXX2", "original_order_id": "ORDERX-IDXXX-XXXXX1" }, "success": true, "time_in": "2022-07-15T12:56:09.876488Z", "time_out": "2022-07-15T12:56:09.923422Z" } ``` -------------------------------- ### Trade Update Example Source: https://docs.kraken.com/api/docs/websocket-v2/balances A JSON representation of two consecutive balance update messages resulting from a single trade transaction, linked by a shared ref_id. ```json { "channel": "balances", "type": "update", "data": [ { "ledger_id": "AAICKV-NMQSR-ZO5IJD", "ref_id": "AGBB7L-HT5LX-J3BB4A", "timestamp": "2023-09-22T10:33:05.710082Z", "type": "trade", "asset": "BTC", "asset_class": "currency", "category": "trade", "wallet_type": "spot", "wallet_id": "main", "amount": -0.005, "fee": 0.0, "balance": 0.005 } ], "sequence": 9 }, { "channel": "balances", "type": "update", "data": [ { "ledger_id": "A5KS77-LQRMP-SMMN4B", "ref_id": "AGBB7L-HT5LX-J3BB4A", "timestamp": "2023-09-22T10:33:05.710082Z", "type": "trade", "asset": "USD", "asset_class": "currency", "category": "trade", "wallet_type": "spot", "wallet_id": "main", "amount": 132.9995, "fee": 0.3458, "balance": 500 } ], "sequence": 10 } ``` -------------------------------- ### Unsubscribe Response Payloads Source: https://docs.kraken.com/api/docs/websocket-v2/level3 Example JSON responses confirming successful unsubscription from the level3 channel. ```json { "method": "unsubscribe", "result": { "channel": "level3", "symbol": "ALGO/USD" }, "success": true, "time_in": "2023-10-06T18:20:56.506266Z", "time_out": "2023-10-06T18:20:56.521803Z" } { "method": "unsubscribe", "result": { "channel": "level3", "symbol": "MATIC/USD" }, "success": true, "time_in": "2023-10-06T18:20:56.506266Z", "time_out": "2023-10-06T18:20:56.521859Z" } ``` -------------------------------- ### Instrument Channel Update Message Source: https://docs.kraken.com/api/docs/websocket-v2/instrument Example of an incremental update message for the instrument channel. ```json { "channel": "instrument", "type": "update", "data": { "assets": [ { "id": "BTC", "status": "enabled", "precision": 10, "precision_display": 5, ``` -------------------------------- ### Ticker Channel Unsubscribe Request and Acknowledgement Source: https://docs.kraken.com/api/docs/websocket-v2/ticker Examples of the unsubscribe request message and the corresponding acknowledgement response. ```json { "method": "unsubscribe", "params": { "channel": "ticker", "symbol": [ "ALGO/USD" ] } } ``` ```json { "method": "unsubscribe", "result": { "channel": "ticker", "event_trigger": "trades", "symbol": "ALGO/USD" }, "success": true, "time_in": "2023-09-25T09:04:31.742599Z", "time_out": "2023-09-25T09:04:31.742648Z" } ``` -------------------------------- ### Executions Channel Updates Source: https://docs.kraken.com/api/docs/websocket-v2/executions These examples show the structure of update messages received on the 'executions' channel, detailing order and trade information. ```APIDOC ## Executions Channel Updates ### Description These messages provide real-time updates on order and trade executions within the Kraken API WebSocket v2. ### Channel `executions` ### Message Structure Examples: **Initial Order Placement (Pending New):** ```json { "channel": "executions", "type": "update", "data": [ { "order_id": "OK4GJX-KSTLS-7DZZO5", "order_userref": 3, "symbol": "BTC/USD", "order_qty": 0.005, "cum_cost": 0.0, "time_in_force": "GTC", "exec_type": "pending_new", "side": "sell", "order_type": "limit", "limit_price_type": "static", "limit_price": 26500.0, "stop_price": 0.0, "order_status": "pending_new", "fee_usd_equiv": 0.0, "fee_ccy_pref": "fciq", "timestamp": "2023-09-22T10:33:05.709950Z" } ], "sequence": 8 } ``` **Order Status Update (New):** ```json { "channel": "executions", "type": "update", "data": [ { "timestamp": "2023-09-22T10:33:05.709982Z", "order_status": "new", "exec_type": "new", "order_userref": 3, "order_id": "OK4GJX-KSTLS-7DZZO5" } ], "sequence": 9 } ``` **Trade Execution:** ```json { "channel": "executions", "type": "update", "data": [ { "order_id": "OK4GJX-KSTLS-7DZZO5", "order_userref": 3, "exec_id": "TGBB7L-HT5LX-J3BZ4A", "exec_type": "trade", "trade_id": 62887576, "symbol": "BTC/USD", "side": "sell", "last_qty": 0.005, "last_price": 26599.9, "liquidity_ind": "t", "cost": 132.9995, "order_type": "limit", "timestamp": "2023-09-22T10:33:05.709993Z", "order_status": "partially_filled", "cum_qty": 0.005, "cum_cost": 132.9995, "avg_price": 26599.9, "fee_usd_equiv": 0.3458, "fees": [ { "asset": "USD", "qty": 0.3458 } ] } ], "sequence": 10 } ``` ``` -------------------------------- ### Unsubscribe Request Example Source: https://docs.kraken.com/api/docs/websocket-v2/book Send this JSON payload to unsubscribe from specific trading pairs and data depths. Ensure the 'method' is set to 'unsubscribe' and specify the 'channel' and 'symbol' in the 'params'. ```json { "method": "unsubscribe", "params": { "channel": "book", "symbol": [ "ALGO/USD", "MATIC/USD" ] } } ``` -------------------------------- ### add_order Response JSON Structure Source: https://docs.kraken.com/api/docs/websocket-v2/add_order Example of a successful add_order response payload returned by the WebSocket API. ```json { "method": "add_order", "req_id": 123456789, "result": { "order_id": "AA5JGQ-SBMRC-SCJ7J7", "order_userref": 100054 }, "success": true, "time_in": "2023-09-21T14:15:07.197274Z", "time_out": "2023-09-21T14:15:07.205301Z" } ``` -------------------------------- ### Executions Channel Subscription Acknowledgment Source: https://docs.kraken.com/api/docs/websocket-v2/executions This is an example of a successful subscription acknowledgment for the 'executions' channel. It confirms the subscription parameters and provides rate limit information. ```json { "method": "subscribe", "result": { "channel": "executions", "maxratecount": 125, "snap_orders": true, "snap_trades": true }, "success": true, "time_in": "2023-10-16T13:18:35.303171Z", "time_out": "2023-10-16T13:18:35.318297Z" } ``` -------------------------------- ### Ticker Channel Message Payloads Source: https://docs.kraken.com/api/docs/websocket-v2/ticker Examples of ticker channel messages showing snapshot and update data structures. ```json { "channel": "ticker", "type": "snapshot", "data": [ { "symbol": "ALGO/USD", "bid": 0.10025, "bid_qty": 740.0, "ask": 0.10036, "ask_qty": 1361.44813783, "last": 0.10035, "volume": 997038.98383185, "vwap": 0.10148, "low": 0.09979, "high": 0.10285, "change": -0.00017, "change_pct": -0.17, "timestamp": "2023-09-25T09:04:31.742648Z" } ] } ``` ```json { "channel": "ticker", "type": "update", "data": [ { "symbol": "ALGO/USD", "bid": 0.10025, "bid_qty": 740.0, "ask": 0.10035, "ask_qty": 740.0, "last": 0.10035, "volume": 997038.98383185, "vwap": 0.10148, "low": 0.09979, "high": 0.10285, "change": -0.00017, "change_pct": -0.17, "timestamp": "2023-09-25T09:04:31.742648Z" } ] } ``` -------------------------------- ### Unsubscribe Request Payload Source: https://docs.kraken.com/api/docs/websocket-v2/level3 Example JSON payload for sending an unsubscribe request to the level3 channel. ```json { "method": "unsubscribe", "params": { "channel": "level3", "symbol": [ "ALGO/USD", "MATIC/USD" ], "token": "G38a1tGFzqGiUCmnegBcm8d4nfP3tytiNQz6tkCBYXY" } } ``` -------------------------------- ### Level 3 Order Book Snapshot and Updates Source: https://docs.kraken.com/api/docs/websocket-v2/level3 This section describes the structure of the Level 3 order book data, including the initial snapshot and subsequent updates. It details the fields within the message body and provides an example of a snapshot. ```APIDOC ## Level 3 Order Book Data Structure ### Description Provides a real-time, granular view of the order book for a given symbol, including individual order details. ### Message Body Structure - **channel** (string) - Required. Must be `level3`. - **type** (string) - Required. Type of message, typically `snapshot` for initial data. - **data** (array) - Contains the order book data. Expected to have one object. - **book** (object) - Represents the order book for a symbol. - **symbol** (string) - The trading pair symbol (e.g., "BTC/USD"). - **bids** (array) - List of buy orders. - **order** (object) - Details of a single buy order. - **order_id** (string) - Unique identifier for the order. - **limit_price** (float) - The price limit of the order. - **order_qty** (float) - The remaining quantity of the order. - **timestamp** (string) - RFC3339 format. Time the order was inserted or amended. - **asks** (array) - List of sell orders. - **order** (object) - Details of a single sell order. - **order_id** (string) - Unique identifier for the order. - **limit_price** (float) - The price limit of the order. - **order_qty** (float) - The remaining quantity of the order. - **timestamp** (string) - RFC3339 format. Time the order was inserted or amended. - **checksum** (integer) - CRC32 checksum for the top 10 price levels. - **timestamp** (string) - RFC3339 format. Time the message was generated. ### Request Example ```json { "channel": "level3", "type": "snapshot", "data": [ { "symbol": "MATIC/USD", "checksum": 281817320, "bids": [ { "order_id": "O6ZQNQ-BXL4E-5WGINO", "limit_price": 0.5629, "order_qty": 111.56125344, "timestamp": "2023-10-06T17:35:00.279389650Z" } ], "asks": [ { "order_id": "OLLSXO-HDMT3-BUOKEI", "limit_price": 0.563, "order_qty": 4422.9978357, "timestamp": "2023-10-06T18:18:20.734897896Z" } ] } ] } ``` ### Response #### Success Response (200) - **channel** (string) - The channel name, `level3`. - **type** (string) - The message type, e.g., `snapshot` or `update`. - **data** (array) - An array containing order book data objects. - **symbol** (string) - The trading pair symbol. - **bids** (array) - An array of bid orders. - **order_id** (string) - The order identifier. - **limit_price** (float) - The price of the order. - **order_qty** (float) - The quantity of the order. - **timestamp** (string) - The timestamp of the order event. - **asks** (array) - An array of ask orders. - **order_id** (string) - The order identifier. - **limit_price** (float) - The price of the order. - **order_qty** (float) - The quantity of the order. - **timestamp** (string) - The timestamp of the order event. - **checksum** (integer) - The checksum of the order book. - **timestamp** (string) - The timestamp of the message generation. #### Response Example (Update) ```json { "channel": "level3", "type": "update", "data": [ { "symbol": "BTC/USD", "bids": [ { "order_id": "O1", "limit_price": 50000.0, "order_qty": 1.0, "timestamp": "2023-10-06T18:20:55.357467423Z" }, { "order_id": "O2", "limit_price": 49999.0, "order_qty": 2.0, "timestamp": "2023-10-06T18:20:55.357467423Z" } ], "asks": [ { "order_id": "O3", "limit_price": 50001.0, "order_qty": 1.5, "timestamp": "2023-10-06T18:20:55.357467423Z" } ], "checksum": 123456789, "timestamp": "2023-10-06T18:20:55.357467423Z" } ] } ``` ``` -------------------------------- ### Level 3 Channel Subscription Acknowledgment Source: https://docs.kraken.com/api/docs/websocket-v2/level3 This is an example of the acknowledgment response received after subscribing to the level3 channel. It confirms the subscription for each requested symbol and indicates success. ```json { "method": "subscribe", "result": { "channel": "level3", "snapshot": true, "symbol": "ALGO/USD" }, "success": true, "time_in": "2023-10-06T18:20:56.506266Z", "time_out": "2023-10-06T18:20:56.521803Z" } { "method": "subscribe", "result": { "channel": "level3", "snapshot": true, "symbol": "MATIC/USD" }, "success": true, "time_in": "2023-10-06T18:20:56.506266Z", "time_out": "2023-10-06T18:20:56.521859Z" } ``` -------------------------------- ### Unsubscribe Acknowledgement Examples Source: https://docs.kraken.com/api/docs/websocket-v2/book These JSON payloads represent the acknowledgement responses received after a successful unsubscribe request. Each response corresponds to a symbol in the original request, indicating the success status and details of the unsubscribed channel. ```json { "method": "unsubscribe", "result": { "channel": "book", "depth": 10, "snapshot": true, "symbol": "ALGO/USD" }, "success": true, "time_in": "2023-10-06T17:35:55.219022Z", "time_out": "2023-10-06T17:35:55.219067Z" } { "method": "unsubscribe", "result": { "channel": "book", "depth": 10, "snapshot": true, "symbol": "MATIC/USD" }, "success": true, "time_in": "2023-10-06T17:35:55.219022Z", "time_out": "2023-10-06T17:35:55.219067Z" } ``` -------------------------------- ### Level 3 Order Book Update Message Source: https://docs.kraken.com/api/docs/websocket-v2/level3 Example of a JSON payload for a level3 order book update, including order events for bids and asks. ```json { "channel": "level3", "type": "update", "data": [ { "checksum": 2841398499, "symbol": "MATIC/USD", "bids": [], "asks": [ { "event": "delete", "order_id": "OOIATY-6EIWY-ACVIUN", "limit_price": 0.5636, "order_qty": 302.89736033, "timestamp": "2023-10-06T18:21:00.097010033Z" }, { "event": "add", "order_id": "O2BN53-5RSB2-V3J57T", "limit_price": 0.564, "order_qty": 3500.77668626, "timestamp": "2023-10-06T18:20:27.383408052Z" }, { "event": "add", "order_id": "OWG5ZU-LHUHH-BICPEX", "limit_price": 0.564, "order_qty": 22149.62881248, "timestamp": "2023-10-06T18:20:50.842854530Z" }, { "event": "add", "order_id": "ONVDB3-2DRUF-Y6MF7D", "limit_price": 0.564, "order_qty": 42196.34088652, "timestamp": "2023-10-06T18:20:58.101850535Z" } ] } ] } ``` -------------------------------- ### Create a simple limit buy order Source: https://docs.kraken.com/api/docs/websocket-v2/add_order Demonstrates placing a basic limit buy order with a specified price, quantity, and symbol. ```json { "method": "add_order", "params": { "order_type": "limit", "side": "buy", "limit_price": 26500.4, "order_userref": 100054, "order_qty": 1.2, "symbol": "BTC/USD", "token": "G38a1tGFzqGiUCmnegBcm8d4nfP3tytiNQz6tkCBYXY" }, "req_id": 123456789 } ``` -------------------------------- ### Order Placement Parameters Source: https://docs.kraken.com/api/docs/websocket-v2/batch_add Details the fields and configuration options available when placing an order via the Kraken WebSocket API. ```APIDOC ## Order Placement Parameters ### Description Defines the parameters used to configure and submit orders, including identifiers, quantity, side, and advanced execution settings like STP and time-in-force. ### Parameters #### Request Body - **cl_ord_id** (string) - Optional - Alphanumeric client order identifier. Mutually exclusive with order_userref. - **order_userref** (integer) - Optional - Non-unique numeric identifier. Mutually exclusive with cl_ord_id. - **order_qty** (float) - Required - Order quantity in base asset. - **order_type** (string) - Required - Execution model (limit, market, iceberg, stop-loss, etc.). - **post_only** (boolean) - Conditional - Cancels order if it takes liquidity. Only for limit orders. - **reduce_only** (boolean) - Optional - Reduces existing margin position. - **side** (string) - Required - buy or sell. - **stp_type** (string) - Optional - Self Trade Prevention mode (cancel_newest, cancel_oldest, cancel_both). - **time_in_force** (string) - Optional - Duration of order (gtc, gtd, ioc). - **triggers** (object) - Conditional - Trigger price conditions for triggered order types. - **sender_sub_id** (string) - Conditional - Sub-account/trader identifier for institutional STP. ``` -------------------------------- ### Create a sell stop-loss order Source: https://docs.kraken.com/api/docs/websocket-v2/add_order Demonstrates placing a sell stop-loss order triggered by a percentage drop from the last traded price. ```json { "method": "add_order", "params": { "order_type": "stop-loss", "side": "sell", "order_qty": 100, "symbol": "MATIC/USD", "triggers": { "reference": "last", "price": -2.0, "price_type": "pct" }, "token": "G38a1tGFzqGiUCmnegBcm8d4nfP3tytiNQz6tkCBYXY" } } ``` -------------------------------- ### Create a limit order with a conditional stop-loss Source: https://docs.kraken.com/api/docs/websocket-v2/add_order Demonstrates placing a primary limit buy order with an attached conditional stop-loss-limit order. ```json { "method": "add_order", "params": { "order_type": "limit", "side": "buy", "order_qty": 1.2, "symbol": "BTC/USD", "limit_price": 28440, "conditional": { "order_type": "stop-loss-limit", "trigger_price": 28410, "limit_price": 28400 }, "token": "G38a1tGFzqGiUCmnegBcm8d4nfP3tytiNQz6tkCBYXY" } } ``` -------------------------------- ### POST /batch_add Source: https://docs.kraken.com/api/docs/websocket-v2/batch_add Submits a batch of orders to be added to the trading system. This method allows for the efficient placement of multiple orders with various configurations, including conditional orders. ```APIDOC ## POST /batch_add ### Description Submits a batch of orders to be added to the trading system. This method allows for the efficient placement of multiple orders with various configurations, including conditional orders. ### Method POST ### Endpoint /batch_add ### Parameters #### Request Body - **method** (string) - Required - Value: `batch_add` - **token** (string) - Required - Authentication token for the request. - **symbol** (string) - Required - The symbol of the currency pair (e.g., "BTC/USD"). - **orders** (array) - Required - A list of order objects to be placed. - **order** (object) - Represents a single order within the batch. - **order_type** (string) - Required - Type of the order. Possible values: [`limit`, `stop-loss`, `stop-loss-limit`, `take-profit`, `take-profit-limit`, `trailing-stop`, `trailing-stop-limit`]. - **cash_order_qty** (float) - Conditional - Required for market orders only. Order volume expressed in quote currency. - **display_qty** (float) - Conditional - Required for iceberg orders. Defines the quantity to show in the book. - **fee_preference** (string) - Fee preference: `base` or `quote`. - **limit_price** (float) - Limit price for orders that support it. - **limit_price_type** (string) - Conditional - Units for the limit price. Only available on trailing-stop orders. Possible values: [`static`, `pct`, `quote`]. Default: `quote`. - **effective_time** (string) - Scheduled start time in RFC3339 format (e.g., "2022-12-25T09:30:59Z"). - **expire_time** (string) - Conditional - Expiration time for GTD orders in RFC3339 format (e.g., "2022-12-25T09:30:59Z"). - **margin** (boolean) - Funds the order on margin. Possible values: [`false`, `true`]. Default: `false`. - **no_mpp** (boolean) - Deprecated. - **conditional** (object) - Parameters for generating secondary close orders upon primary order fill. - **order_type** (string) - Type of the secondary close order. Possible values: [`limit`, `stop-loss`, `stop-loss-limit`, `take-profit`, `take-profit-limit`, `trailing-stop`, `trailing-stop-limit`]. - **limit_price** (float) - Limit price for the secondary close order. - **limit_price_type** (string) - Conditional - Units for the limit price on secondary orders. Only available on `trailing-stop-limit` orders. Possible values: [`static`, `pct`, `quote`]. Default: `quote`. - **trigger_price** (float) - Trigger price for the secondary close order. - **trigger_price_type** (string) - Units for the trigger price. Possible values: [`static`, `pct`, `quote`]. Default: `static`. - **stop_price** (float) - Deprecated. Use `trigger_price`. - **deadline** (string) - Optional - RFC3339 formatted deadline for order matching (e.g., "2022-12-25T09:30:59.123Z"). - **validate** (boolean) - Optional - If true, the order will only be validated, not traded. Possible values: [`true`, `false`]. Default: `false`. ### Request Example ```json { "method": "batch_add", "token": "your_auth_token", "symbol": "BTC/USD", "orders": [ { "order_type": "limit", "limit_price": 30000.00, "cash_order_qty": 0.001, "conditional": { "order_type": "stop-loss-limit", "limit_price": 29000.00, "trigger_price": 29500.00 } }, { "order_type": "market", "cash_order_qty": 100.00 } ], "deadline": "2023-10-27T10:00:00.000Z", "validate": true } ``` ### Response #### Success Response (200) - **result** (object) - Contains the result of the batch order submission. - **order_batch_id** (string) - The unique identifier for the batch of orders. - **orders** (array) - A list of individual order details within the batch. - **order_id** (string) - The unique identifier for each order. - **descr** (object) - Description of the order. - **order_type** (string) - Type of the order. - **price** (string) - Limit price. - **other_params** (string) - Other parameters related to the order. - **conditionalOrder** (object) - Details of the conditional order, if applicable. - **order_id** (string) - The unique identifier for the conditional order. - **close_order_id** (string) - The unique identifier for the associated close order. #### Response Example ```json { "result": { "order_batch_id": "ob123456789", "orders": [ { "order_id": "o123456789", "descr": { "order_type": "limit", "price": "30000.00", "other_params": "..." }, "conditionalOrder": { "order_id": "co123456789", "close_order_id": "co123456789_close" } }, { "order_id": "o987654321", "descr": { "order_type": "market", "other_params": "..." } } ] }, "error": [] } ``` ``` -------------------------------- ### Subscribe to Book Channel Source: https://docs.kraken.com/api/docs/websocket-v2/book JSON request body for subscribing to the book channel for multiple currency pairs. ```json { "method": "subscribe", "params": { "channel": "book", "symbol": [ "ALGO/USD", "MATIC/USD" ] } } ``` -------------------------------- ### Batch Add Orders Request Source: https://docs.kraken.com/api/docs/websocket-v2/batch_add This JSON object demonstrates the structure for a `batch_add` request to place multiple orders simultaneously. Ensure all required parameters like `symbol`, `token`, and `orders` are correctly formatted. ```json { "method": "batch_add", "params": { "deadline": "2022-06-13T08:09:10.123456Z", "orders": [ { "limit_price": 1010.10, "order_qty": 0.123456789, "order_type": "limit", "order_userref": 1, "side": "buy" }, { "limit_price": 2020.20, "order_qty": 0.987654321, "order_type": "limit", "order_userref": 2, "side": "sell", "stp_type": "cancel_both" } ], "symbol": "BTC/USD", "token": "TxxxxxxxxxOxxxxxxxxxxKxxxxxxxExxxxxxxxN", "validate": false }, "req_id": 1234567890 } ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.