How to use the tensortrade.base.context.TradingContext function in tensortrade

To help you get started, we’ve selected a few tensortrade examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github notadamking / tensortrade / tests / tensortrade / base / test_context.py View on Github external
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']
github notadamking / tensortrade / tests / tensortrade / base / test_context.py View on Github external
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')
github notadamking / tensortrade / tests / tensortrade / base / test_context.py View on Github external
def test_init_with_kwargs():
    c = TradingContext(**config)
    assert c.shared.get('base_instrument') == 'EURO'
    assert c.shared.get('instruments') == ['BTC', 'ETH']
github notadamking / tensortrade / tensortrade / base / context.py View on Github external
def get_contexts(cls):
        if not hasattr(cls.contexts, 'stack'):
            cls.contexts.stack = [TradingContext()]

        return cls.contexts.stack
github notadamking / tensortrade / tensortrade / base / component.py View on Github external
def __call__(cls, *args, **kwargs):
        registered_name = get_registry()[cls]
        tc = TradingContext.get_context()
        data = tc.data.get(registered_name, {})
        config = {**tc.shared, **data}

        instance = cls.__new__(cls, *args, **kwargs)
        setattr(instance, 'context', Context(**config))
        instance.__init__(*args, **kwargs)

        return instance
github notadamking / tensortrade / tensortrade / base / context.py View on Github external
def from_yaml(cls, path: str):
        with open(path, "rb") as fp:
            config = yaml.load(fp, Loader=yaml.FullLoader)

        return TradingContext(**config)
github notadamking / tensortrade / tensortrade / base / context.py View on Github external
def from_json(cls, path: str):
        with open(path, "rb") as fp:
            config = json.load(fp)

        return TradingContext(**config)