-
Notifications
You must be signed in to change notification settings - Fork 17
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
65 additions
and
12 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
import trio | ||
import pytest | ||
import tractor | ||
|
||
from piker import config | ||
|
||
from piker.brokers.deribit import api as deribit | ||
from piker.brokers.deribit.api import _testnet_ws_url | ||
|
||
from piker._cacheables import open_cached_client | ||
|
||
|
||
TESTNET_KEY_ID: str | None = None | ||
TESTNET_KEY_SECRET: str | None = None | ||
|
||
@pytest.mark.skipif( | ||
not TESTNET_KEY_ID or not TESTNET_KEY_SECRET, | ||
reason='configure a deribit testnet key pair before running this test' | ||
) | ||
def test_deribit_get_ticker(open_test_pikerd): | ||
|
||
async def _test_main(): | ||
async with open_test_pikerd() as _: | ||
async with open_cached_client('deribit') as client: | ||
|
||
symbols = await client.symbol_info() | ||
|
||
syms = list(symbols.keys()) | ||
sym = syms[int(len(syms) / 2)] | ||
|
||
async with deribit.maybe_open_ticker_feed(sym) as tick_stream: | ||
async for typ, msg in tick_stream: | ||
assert typ == 'ticker' | ||
assert 'open_interest' in msg['data'] | ||
break | ||
|
||
|
||
|
||
config.write({ | ||
'deribit': { | ||
'ws_url': _testnet_ws_url, | ||
'key_id': TESTNET_KEY_ID, | ||
'key_secret': TESTNET_KEY_SECRET | ||
} | ||
}) | ||
trio.run(_test_main) |