Le flux d'ownTrades de l'API WebSocket (https://www.kraken.com/en-gb/features/websocket-api#message-ownTrades) est un flux privé de gestion de compte fournissant en temps réel le statut de tous les ordres personnels exécutés par votre compte kraken.
Chaque transaction résultant d'un de vos ordres entraîne l'envoi d'un nouveau message via le flux d' ownTrades.
Comment s'abonner
Une fois une connexion à l'API WebSocket (https://www.kraken.com/en-gb/features/websocket-api#connectionDetails) établie, vous pouvez vous abonner au flux d'ownTrades en récupérant un Token d'authentfication (https://support.kraken.com/hc/en-us/articles/360034437672-How-to-retrieve-a-WebSocket-authentication-token-Example-code-in-Python-3) via l'endpoint REST API GetWebSocketsToken (https://www.kraken.com/features/api#ws-auth), vous permettant l'envoi d'un message d'abonnement tel que celui-ci:
{"event":"subscribe", "subscription":{"name":"ownTrades", "token":"WOg6IVQ5RfogMzkhH25WOg6IVQ5RqhP+U3ZprQVnh7f"}}
Exemple de flux
Voici un exemple de flux d'ownTrades:
{"connectionID":12678739536485265125,"event":"systemStatus","status":"online","version":"0.3.0"}{"channelName":"ownTrades","event":"subscriptionStatus","status":"subscribed","subscription":{"name":"ownTrades"}}[[{"T7YS4M-6HGBO-GDAGOY":{"cost":"70.19110","fee":"0.18250","margin":"0.00000","ordertxid":"OPJVQI-PXMPK-4WT5WP","ordertype":"market","pair":"XBT/USD","postxid":"TKH2SE-M7IF5-CFI7LT","price":"8092.20053","time":"1570270020.122169","type":"buy","vol":"0.00867392"}},{"TNN4V7-BTS6X-O3CQF3":{"cost":"54.00046","fee":"0.14040","margin":"0.00000","ordertxid":"OKIRSX-DUS37-W33QZN","ordertype":"market","pair":"XBT/USD","postxid":"TKH2SE-M7IF5-CFI7LT","price":"8090.59895","time":"1570269988.387027","type":"sell","vol":"0.00667447"}}], "ownTrades"]{"event":"heartbeat"}{"event":"heartbeat"}[[{"T7GUL2-5N7YZ-QVQDCJ":{"cost":"0.35002","fee":"0.00098","margin":"0.07000","ordertxid":"OMBOUS-KM52J-NGDZH6","ordertype":"market","pair":"ETH/USD","posstatus":"Opened","postxid":"TKH2SE-M7IF5-CFI7LT","price":"175.01000","time":"1570447638.474936","type":"buy","vol":"0.00200000"}}],"ownTrades"]{"event":"heartbeat"}{"event":"heartbeat"}[[{"TEY4EI-7WY6F-YJRXQF":{"cost":"0.35000","fee":"0.00091","margin":"0.00000","ordertxid":"OVNJYW-XAEHY-IUN4EH","ordertype":"market","pair":"ETH/USD","posstatus":"Closing","postxid":"T6KC22-6XWFG-ZWYYTG","price":"175.00000","time":"1570447652.939563","type":"sell","vol":"0.00200000"}}],"ownTrades"]{"event":"heartbeat"}{"event":"heartbeat"}
Après votre abonnement au flux d'ownTrades un message d'abonnement est reçu indiquant votre statut:
{"channelName":"ownTrades","event":"subscriptionStatus","status":"subscribed","subscription":{"name":"ownTrades"}}
suivi d'un aperçu de tous les détails des transactions récemment effectuées sur le compte:
[[{"T7YS4M-6HGBO-GDAGOY":{"cost":"70.19110","fee":"0.18250","margin":"0.00000","ordertxid":"OPJVQI-PXMPK-4WT5WP","ordertype":"market","pair":"XBT/USD","postxid":"TKH2SE-M7IF5-CFI7LT","price":"8092.20053","time":"1570270020.122169","type":"buy","vol":"0.00867392"}},{"TNN4V7-BTS6X-O3CQF3":{"cost":"54.00046","fee":"0.14040","margin":"0.00000","ordertxid":"OKIRSX-DUS37-W33QZN","ordertype":"market","pair":"XBT/USD","postxid":"TKH2SE-M7IF5-CFI7LT","price":"8090.59895","time":"1570269988.387027","type":"sell","vol":"0.00667447"}}], "ownTrades"]
Lorsque de nouvelles transactions sont effectuées, les messages reçus indiquent les détails des transactions. Les messages suivants indiquent deux transactions séparées qui ont initialement ouvert une position ETH Long sur ETHUSD et qui, peu de temps après, ont fermé la position:
[[{"T7GUL2-5N7YZ-QVQDCJ":{"cost":"0.35002","fee":"0.00098","margin":"0.07000","ordertxid":"OMBOUS-KM52J-NGDZH6","ordertype":"market","pair":"ETH/USD","posstatus":"Opened","postxid":"TKH2SE-M7IF5-CFI7LT","price":"175.01000","time":"1570447638.474936","type":"buy","vol":"0.00200000"}}],"ownTrades"]
[[{"TEY4EI-7WY6F-YJRXQF":{"cost":"0.35000","fee":"0.00091","margin":"0.00000","ordertxid":"OVNJYW-XAEHY-IUN4EH","ordertype":"market","pair":"ETH/USD","posstatus":"Closing","postxid":"T6KC22-6XWFG-ZWYYTG","price":"175.00000","time":"1570447652.939563","type":"sell","vol":"0.00200000"}}],"ownTrades"]