Beispiel #1
0
async def test_set_final_eval():
    try:
        currency = "BTC"
        symbol = "BTC/USDT"
        time_frame = "1h"
        producer, consumer, trader = await _get_tools()
        matrix_id = evaluators_api.create_matrix()

        await producer._set_state(currency, symbol, trading_enums.EvaluatorStates.SHORT)
        assert producer.state == trading_enums.EvaluatorStates.SHORT
        # let both other be created
        await asyncio_tools.wait_asyncio_next_cycle()
        await asyncio.create_task(_check_open_orders_count(trader, 2))  # has stop loss
        producer.final_eval = "val"
        await producer.set_final_eval(matrix_id, currency, symbol, time_frame)
        assert producer.state == trading_enums.EvaluatorStates.SHORT  # ensure did not change trading_enums.EvaluatorStates
        assert producer.final_eval == "val"  # ensure did not change trading_enums.EvaluatorStates
        await asyncio.create_task(_check_open_orders_count(trader, 2))  # ensure did not change orders
    finally:
        await _stop(trader)
Beispiel #2
0
async def test_finalize():
    try:
        currency = "BTC"
        symbol = "BTC/USDT"
        producer, consumer, trader = await _get_tools()
        matrix_id = evaluators_api.create_matrix()

        await producer.finalize(trading_api.get_exchange_name(trader.exchange_manager), matrix_id, currency, symbol)
        assert producer.final_eval == commons_constants.INIT_EVAL_NOTE

        await producer._set_state(currency, symbol, trading_enums.EvaluatorStates.SHORT)
        assert producer.state == trading_enums.EvaluatorStates.SHORT
        # let both other be created
        await asyncio_tools.wait_asyncio_next_cycle()
        await asyncio.create_task(_check_open_orders_count(trader, 2))  # has stop loss

        await producer._set_state(currency, symbol, trading_enums.EvaluatorStates.SHORT)
        await asyncio.create_task(
            _check_open_orders_count(trader, 2))  # ensure did not change orders because neutral state

    finally:
        await _stop(trader)
Beispiel #3
0
async def matrix_id():
    created_matrix_id = evaluator_api.create_matrix()
    yield created_matrix_id
    matrices.Matrices.instance().del_matrix(created_matrix_id)