DownloadKrakenData¶
Defined in dccd.continuous_dl.kraken
- class DownloadKrakenData(pair='BTC/USD', time_step=60, until=3600, span=None, checkpoint_dir=None)[source]
Bases:
ContinuousDownloaderDownload data continuously from Kraken via WebSocket v2.
- Parameters:
- pairstr
Trading pair in Kraken format (e.g. ‘BTC/USD’).
- time_stepint, optional
Seconds between data snapshots, default is 60.
- untilint, optional
Seconds to run or stop timestamp, default is 3600.
- spanint, optional
OHLCV interval in seconds; if given, also subscribes to the ohlc channel. Must be a multiple of 60. Default is None.
- Attributes:
- hoststr
WebSocket URL.
- is_connectbool
True if connected.
- tsint
Snapshot interval in seconds.
- untilint
Stop timestamp.
Methods
set_process_data(func, **kwargs)Set processing function.
set_saver(call, **kwargs)Set saver object to save data or update a database.
__call__(*args, **kwargs)Start the WebSocket stream and block until it stops.
- __call__(*args, **kwargs)
Start the WebSocket stream and block until it stops.
- Parameters:
- *args, **kwargs
Forwarded to
_connect.
- Returns:
- ContinuousDownloader
The downloader instance (for chaining).
- get_parser(key)
Get allowed data parser.
- Parameters:
- keystr
Name code of data to parse.
- Returns:
- function
The allowed function to parse this kind of data.
- Raises:
- KeyError
If key is not in the allowed parser keys.
- on_close()
On websocket close print and fire event.
- async on_error(error, *args)
On websocket error print and fire event.
- async on_message(msg)[source]
Dispatch incoming Kraken WebSocket v2 push messages.
- Parameters:
- msgdict
Kraken push message with
channelanddatafields.
- on_open(**kwargs)
On websocket open.
- Parameters:
- **kwargs
Any relevant keyword arguments to set connection.
- parser_book(msg)[source]
Parse and update the order book from a book push message.
- Parameters:
- msgdict
Full Kraken book push message (contains
typeanddata).
- parser_kline(data)[source]
Parse and store an ohlc push message.
- Parameters:
- datalist of dict
The
datafield from the Kraken ohlc push message.
- parser_trades(data)[source]
Parse and store a trade push message.
- Parameters:
- datalist of dict
The
datafield from the Kraken trade push message.
- set_book_saver(saver, process_func=<function set_marketdepth>, **kwargs)
Set saver for the order-book channel.
- Parameters:
- savercallable
Callable to persist the processed DataFrame (e.g.
IODataBase).- process_funccallable, optional
Function to convert the book dict to a DataFrame, default is
dccd.process_data.set_marketdepth.- **kwargs
Extra keyword arguments forwarded to
saveron each call.
- set_process_data(func, **kwargs)
Set processing function.
- Parameters:
- funccallable
Function to process and clean data before to be saved. Must take data in arguments and can take any optional keywords arguments, cf exemples in
dccd.process_data.- **kwargs
Any keyword arguments to be passed to func.
- set_saver(call, **kwargs)
Set saver object to save data or update a database.
- Parameters:
- callcallable
Callable object to save data or update a database. Must take data in arguments and can take any optional keywords arguments, cf exemples in
dccd.io_tools.- **kwargs
Any keyword arguments to be passed to call.
- set_trades_saver(saver, process_func=<function set_trades>, **kwargs)
Set saver for the trades channel.
- Parameters:
- savercallable
Callable to persist the processed DataFrame (e.g.
IODataBase).- process_funccallable, optional
Function to convert raw trade list to a DataFrame, default is
dccd.process_data.set_trades.- **kwargs
Extra keyword arguments forwarded to
saveron each call.
- async wait_that(is_true)
Wait before running.