Ejemplo n.º 1
0
def test_context_creation():

    with td.TradingContext(**config) as tc1:
        assert tc1.data == config

        with td.TradingContext(**config) as tc2:
            assert TradingContext.get_context() == tc2

        assert TradingContext.get_context() == tc1
Ejemplo n.º 2
0
def test_has_config_attribute():
    c = TradingContext()

    assert hasattr(c, 'shared')
    assert hasattr(c, 'exchanges')
    assert hasattr(c, 'actions')
    assert hasattr(c, 'rewards')
    assert hasattr(c, 'features')
Ejemplo n.º 3
0
def test_has_config_attribute():
    c = TradingContext({
        "test": True,
        "exchanges": {"test": True},
        "actions": {"test": True},
        "rewards": {"test": True},
    })

    assert hasattr(c, 'shared')
Ejemplo n.º 4
0
def get_context():
    return TradingContext.get_context()
Ejemplo n.º 5
0
def test_init_with_kwargs():
    c = TradingContext(**config)
    assert c.shared.get('base_instrument') == 'EURO'
    assert c.shared.get('products') == ['BTC', 'ETH']
Ejemplo n.º 6
0
def test_init():
    c = TradingContext(base_instrument=config['base_instrument'],
                       products=config['products'])
    assert c.shared.get('base_instrument') == 'EURO'
    assert c.shared.get('products') == ['BTC', 'ETH']
Ejemplo n.º 7
0
def test_init():
    c = TradingContext({"base_instrument": config['base_instrument'],
                        "instruments": config['instruments']})
    assert c.shared.get('base_instrument') == 'EURO'
    assert c.shared.get('instruments') == ['BTC', 'ETH']