예제 #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
예제 #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')
예제 #3
0
def test_has_config_attribute():
    c = TradingContext({
        "test": True,
        "exchanges": {"test": True},
        "actions": {"test": True},
        "rewards": {"test": True},
    })

    assert hasattr(c, 'shared')
예제 #4
0
def get_context():
    return TradingContext.get_context()
예제 #5
0
def test_init_with_kwargs():
    c = TradingContext(**config)
    assert c.shared.get('base_instrument') == 'EURO'
    assert c.shared.get('products') == ['BTC', 'ETH']
예제 #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']
예제 #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']