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
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')
def test_has_config_attribute(): c = TradingContext({ "test": True, "exchanges": {"test": True}, "actions": {"test": True}, "rewards": {"test": True}, }) assert hasattr(c, 'shared')
def get_context(): return TradingContext.get_context()
def test_init_with_kwargs(): c = TradingContext(**config) assert c.shared.get('base_instrument') == 'EURO' assert c.shared.get('products') == ['BTC', 'ETH']
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']
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']