Compare commits

..

No commits in common. "6555ccfbba46c62d6c9dd72ee984161da52a29c7" and "2bdbe0f20ee69893987d35bb8beae75e777effb2" have entirely different histories.

1 changed files with 30 additions and 14 deletions

View File

@ -58,7 +58,6 @@ from cryptofeed.symbols import Symbol
# types for managing the cb callbacks. # types for managing the cb callbacks.
# from cryptofeed.types import L1Book # from cryptofeed.types import L1Book
from .venues import ( from .venues import (
_ws_url,
MarketType, MarketType,
PAIRTYPES, PAIRTYPES,
Pair, Pair,
@ -96,6 +95,11 @@ _spawn_kwargs = {
} }
_url = 'https://www.deribit.com'
_ws_url = 'wss://www.deribit.com/ws/api/v2'
_testnet_ws_url = 'wss://test.deribit.com/ws/api/v2'
# convert datetime obj timestamp to unixtime in milliseconds # convert datetime obj timestamp to unixtime in milliseconds
def deribit_timestamp(when): def deribit_timestamp(when):
return int((when.timestamp() * 1000) + (when.microsecond / 1000)) return int((when.timestamp() * 1000) + (when.microsecond / 1000))
@ -186,22 +190,34 @@ def get_config() -> dict[str, Any]:
) )
section: dict = {} section: dict = {}
section = conf.get('deribit') section = conf.get('deribit')
if section is None:
log.warning(f'No config section found for deribit in {path}')
return {}
conf_option = section.get('option', {})
section.clear # clear the dict to reuse it
section['deribit'] = {}
section['deribit']['key_id'] = conf_option.get('api_key')
section['deribit']['key_secret'] = conf_option.get('api_secret')
section['log'] = {} section['log'] = {}
section['log']['filename'] = 'feedhandler.log' section['log']['filename'] = 'feedhandler.log'
section['log']['level'] = 'DEBUG' section['log']['level'] = 'DEBUG'
section['log']['disabled'] = True
if section is None:
log.warning(f'No config section found for deribit in {path}')
return {}
return section return section
def get_fh_config() -> dict[str, Any]:
conf_option = get_config().get('option', {})
conf_log = get_config().get('log', {})
return {
'log': {
'filename': conf_log.get('filename'),
'level': conf_log.get('level'),
'disabled': conf_log.get('disabled')
},
'deribit': {
'key_id': conf_option.get('api_key'),
'key_secret': conf_option.get('api_secret')
}
}
class Client: class Client:
@ -213,10 +229,10 @@ class Client:
) -> None: ) -> None:
self._pairs: ChainMap[str, Pair] = ChainMap() self._pairs: ChainMap[str, Pair] = ChainMap()
config = get_config().get('deribit', {}) config = get_config().get('option', {})
self._key_id = config.get('key_id') self._key_id = config.get('api_key')
self._key_secret = config.get('key_secret') self._key_secret = config.get('api_secret')
self.json_rpc = json_rpc self.json_rpc = json_rpc
@ -555,7 +571,7 @@ async def get_client(
@acm @acm
async def open_feed_handler(): async def open_feed_handler():
fh = FeedHandler(config=get_config()) fh = FeedHandler(config=get_fh_config())
yield fh yield fh
await to_asyncio.run_task(fh.stop_async) await to_asyncio.run_task(fh.stop_async)