parent
973c068e96
commit
a6257ae615
|
@ -140,8 +140,11 @@ def _assert(
|
||||||
assert not bool(table.pps)
|
assert not bool(table.pps)
|
||||||
|
|
||||||
|
|
||||||
# Close position and assert empty position in pps
|
|
||||||
def _run_test_and_check(fn):
|
def _run_test_and_check(fn):
|
||||||
|
'''
|
||||||
|
Close position and assert empty position in pps
|
||||||
|
|
||||||
|
'''
|
||||||
with pytest.raises(BaseExceptionGroup) as exc_info:
|
with pytest.raises(BaseExceptionGroup) as exc_info:
|
||||||
trio.run(fn)
|
trio.run(fn)
|
||||||
|
|
||||||
|
@ -151,8 +154,14 @@ def _run_test_and_check(fn):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_buy(open_test_pikerd_and_ems: AsyncContextManager, delete_testing_dir):
|
def test_buy(
|
||||||
# Enter a trade and assert entries are made in pps and ledger files
|
open_test_pikerd_and_ems: AsyncContextManager,
|
||||||
|
delete_testing_dir
|
||||||
|
):
|
||||||
|
'''
|
||||||
|
Enter a trade and assert entries are made in pps and ledger files.
|
||||||
|
|
||||||
|
'''
|
||||||
_run_test_and_check(
|
_run_test_and_check(
|
||||||
partial(
|
partial(
|
||||||
_async_main,
|
_async_main,
|
||||||
|
@ -172,8 +181,14 @@ def test_buy(open_test_pikerd_and_ems: AsyncContextManager, delete_testing_dir):
|
||||||
)
|
)
|
||||||
|
|
||||||
|
|
||||||
def test_sell(open_test_pikerd_and_ems: AsyncContextManager, delete_testing_dir):
|
def test_sell(
|
||||||
# Sell position
|
open_test_pikerd_and_ems: AsyncContextManager,
|
||||||
|
delete_testing_dir
|
||||||
|
):
|
||||||
|
'''
|
||||||
|
Sell position ensure pps are zeroed.
|
||||||
|
|
||||||
|
'''
|
||||||
_run_test_and_check(
|
_run_test_and_check(
|
||||||
partial(
|
partial(
|
||||||
_async_main,
|
_async_main,
|
||||||
|
@ -183,7 +198,6 @@ def test_sell(open_test_pikerd_and_ems: AsyncContextManager, delete_testing_dir)
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Ensure pps are zeroed
|
|
||||||
_run_test_and_check(
|
_run_test_and_check(
|
||||||
partial(
|
partial(
|
||||||
_async_main,
|
_async_main,
|
||||||
|
@ -194,8 +208,16 @@ def test_sell(open_test_pikerd_and_ems: AsyncContextManager, delete_testing_dir)
|
||||||
|
|
||||||
|
|
||||||
@pytest.mark.skip(reason='Due to precision issues, this test will currently fail')
|
@pytest.mark.skip(reason='Due to precision issues, this test will currently fail')
|
||||||
def test_multi_sell(open_test_pikerd_and_ems: AsyncContextManager, delete_testing_dir):
|
def test_multi_sell(
|
||||||
# Make 5 market limit buy orders
|
open_test_pikerd_and_ems: AsyncContextManager,
|
||||||
|
delete_testing_dir
|
||||||
|
):
|
||||||
|
'''
|
||||||
|
Make 5 market limit buy orders and
|
||||||
|
then sell 5 slots at the same price.
|
||||||
|
Finally, assert cleared positions.
|
||||||
|
|
||||||
|
'''
|
||||||
_run_test_and_check(
|
_run_test_and_check(
|
||||||
partial(
|
partial(
|
||||||
_async_main,
|
_async_main,
|
||||||
|
@ -205,7 +227,6 @@ def test_multi_sell(open_test_pikerd_and_ems: AsyncContextManager, delete_testin
|
||||||
),
|
),
|
||||||
)
|
)
|
||||||
|
|
||||||
# Sell 5 slots at the same price, assert cleared positions
|
|
||||||
_run_test_and_check(
|
_run_test_and_check(
|
||||||
partial(
|
partial(
|
||||||
_async_main,
|
_async_main,
|
||||||
|
|
Loading…
Reference in New Issue