From 7de914d54c0bd44f7f083cf758587726c6691910 Mon Sep 17 00:00:00 2001 From: Tyler Goodlet Date: Mon, 10 Apr 2023 22:21:22 -0400 Subject: [PATCH] Fix bad-fqme test, adjust prices based on buy/sell --- tests/test_paper.py | 49 ++++++++++++++++++++++++++++++--------------- 1 file changed, 33 insertions(+), 16 deletions(-) diff --git a/tests/test_paper.py b/tests/test_paper.py index 0e791197..8a290f6a 100644 --- a/tests/test_paper.py +++ b/tests/test_paper.py @@ -159,20 +159,26 @@ def load_and_check_pos( yield pp -@pytest.mark.trio -async def test_ems_err_on_bad_broker( +def test_ems_err_on_bad_broker( open_test_pikerd: Services, loglevel: str, ): - try: - async with open_ems( - 'doggy.smiles', - mode='paper', - loglevel=loglevel, - ) as _: - pytest.fail('EMS is working on non-broker!?') - except ModuleNotFoundError: - pass + async def load_bad_fqme(): + try: + async with ( + open_test_pikerd() as (_, _, _, services), + + open_ems( + 'doggycoin.doggy', + mode='paper', + loglevel=loglevel, + ) as _ + ): + pytest.fail('EMS is working on non-broker!?') + except ModuleNotFoundError: + pass + + run_and_tollerate_cancels(load_bad_fqme) async def match_ppmsgs_on_ems_boot( @@ -264,12 +270,14 @@ async def submit_and_check( od: dict for od in fills: print(f'Sending order {od} for fill') + size = od['size'] sent, msgs = await order_and_and_wait_for_ppmsg( client, trades_stream, fqme, - action='buy', - size=od['size'], + action='buy' if size > 0 else 'sell', + price=100e3 if size > 0 else 0, + size=size, ) last_order: Order = sent[-1] @@ -300,7 +308,8 @@ async def submit_and_check( {'size': 0.001}, ), - # multi-partial entry and exits. + # multi-partial entry and exits from net-zero, to short and back + # to net-zero. ( # enters {'size': 0.001}, @@ -314,10 +323,18 @@ async def submit_and_check( {'size': 0.001}, {'size': 0.002}, - # exits to get back to zero. + # nearly back to zero. {'size': -0.001}, + + # switch to net-short {'size': -0.025}, {'size': -0.0195}, + + # another entry + {'size': 0.001}, + + # final cover to net-zero again. + {'size': 0.038}, ), ], ids='fills={}'.format, @@ -328,7 +345,7 @@ def test_multi_fill_positions( fills: tuple[dict], - check_cross_session: bool = True, + check_cross_session: bool = False, ) -> None: