Forwards trades from Kraken.com to TCP port
Project description
krakenforwarder
This Python program listens to trades from Crypto-exchange platform Kraken (https://www.kraken.com) and forwards them on a TCP port so you can plug in anything, like a live algorithmic trader or a live analysis tool.
Installation
pip3 install krakenforwarder
Usage
Launch the forwarder in sub-process, then listen
import time
from multiprocessing import Process
from krakenforwarder.forwarder import KrakenForwarder
from krakenforwarder.listener import listen
from krakenforwarder.util import *
cfg_forwarders = [
{
F_PULL_PERIOD: 5, # in seconds
F_ASSET_PAIR: 'XXBTZEUR', # see https://support.kraken.com/hc/en-us/articles/360000920306-Ticker-pairs
F_TYPE: V_SPOT,
F_ZMQ_PUBLISH_PORT: 5555
},
{
F_PULL_PERIOD: 5, # in seconds
F_ASSET_PAIR: 'XETHZEUR', # see https://support.kraken.com/hc/en-us/articles/360000920306-Ticker-pairs
F_TYPE: V_SPOT,
F_ZMQ_PUBLISH_PORT: 5556
},
]
cfg_listener = {
F_KEY_ZMQ_HOSTNAME: 'localhost',
F_ZMQ_PUBLISH_PORT: [cfg[F_ZMQ_PUBLISH_PORT] for cfg in cfg_forwarders]
}
proc_forwarders = []
for cfg in cfg_forwarders:
kraken_forwarder = KrakenForwarder(cfg)
forward_process = Process(target=kraken_forwarder.forward)
proc_forwarders.append(forward_process)
for proc in proc_forwarders:
proc.start()
time.sleep(1)
for msg in listen(cfg_listener):
print(msg)
for proc in proc_forwarders:
proc.join()
This prints trades in console:
{"pair": "XXBTZEUR", "Trade": ["9388.90000", "0.01604115", 1568346002.9574, "b", "m", ""]}
{"pair": "XXBTZEUR", "Trade": ["9390.00000", "0.03569491", 1568346002.9981, "b", "m", ""]}
{"pair": "XXBTZEUR", "Trade": ["9390.00000", "0.01000000", 1568346003.0047, "b", "m", ""]}
{"pair": "XXBTZEUR", "Trade": ["9392.90000", "0.03477392", 1568346003.0213, "b", "m", ""]}
OVER
...
{"pair": "XXBTZEUR", "Trade": ["9384.50000", "0.00500000", 1568346015.5326, "s", "m", ""]}
OVER
{"pair": "XETHZEUR", "Trade": ["162.98000", "0.24458271", 1568346014.6035, "s", "m", ""]}
{"pair": "XETHZEUR", "Trade": ["162.98000", "0.00063427", 1568346014.6274, "s", "m", ""]}
{"pair": "XETHZEUR", "Trade": ["162.98000", "0.00000165", 1568346014.6296, "s", "m", ""]}
OVER
To call forward contracts, instead use
from krakenforwarder.util import *
cfg_forwarders = [
{
F_PULL_PERIOD: 5, # in seconds
F_ASSET_PAIR: 'pi_xbtusd',
F_TYPE: V_FUTURES,
# see https://support.kraken.com/hc/en-us/articles/360022839531-Tickers for possible choices
F_ZMQ_PUBLISH_PORT: 5557
},
]
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
krakenforwarder-0.8.tar.gz
(5.1 kB
view details)
Built Distribution
File details
Details for the file krakenforwarder-0.8.tar.gz
.
File metadata
- Download URL: krakenforwarder-0.8.tar.gz
- Upload date:
- Size: 5.1 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 8d71cc99ccb98c00567ef05156d0853379ff6fefb46872091c1bf386f2ef1702 |
|
MD5 | ef37edbc4ddf9c7beed1d83c14105f87 |
|
BLAKE2b-256 | a9282c05eaa82d778855136ec6bb08d15aaad9c5aec2b2d263d24b7f028cf754 |
File details
Details for the file krakenforwarder-0.8-py3-none-any.whl
.
File metadata
- Download URL: krakenforwarder-0.8-py3-none-any.whl
- Upload date:
- Size: 6.2 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/3.2.0 pkginfo/1.5.0.1 requests/2.22.0 setuptools/46.0.0.post20200309 requests-toolbelt/0.9.1 tqdm/4.42.1 CPython/3.7.6
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 555a15ed4abd0326043d75fb8d77bdecf272b2c4614f7ee551bba36da8abe492 |
|
MD5 | f423249057c037e18a03d12384444ca2 |
|
BLAKE2b-256 | e7b3ae1e2281e8c3e19b94eb8b58ee3b168351550c3460f666660e30f3a34bcb |