Exemplo n.º 1
0
    def test_calculations(self):
        from aat.strategy.calculations import main
        sys.argv = [
            'aat.strategy.calculations', '--folder',
            os.path.join(os.path.dirname(__file__), '_aat_BACKTEST_test'),
            '--strategy', 'MomentumStrategy-0', '--render', 'False'
        ]

        if _in_cpp():
            # TODO
            return
        main()
Exemplo n.º 2
0
    def test_calculations(self):
        from aat.strategy.calculations import main

        sys.argv = [
            "aat.strategy.calculations",
            "--folder",
            os.path.join(os.path.dirname(__file__), "_aat_BACKTEST_test"),
            "--strategy",
            "MomentumStrategy-0",
            "--render",
            "False",
        ]

        if _in_cpp():
            # TODO
            return
        main()
Exemplo n.º 3
0
    def test_stop_order_validation(self):
        if _in_cpp():
            return

        with pytest.raises(AssertionError):
            Order(volume=0.0,
                  price=5.0,
                  side=Order.Sides.SELL,
                  exchange=ExchangeType(''),
                  order_type=Order.Types.STOP,
                  stop_target=Order(
                      volume=0.5,
                      price=5.0,
                      side=Order.Sides.SELL,
                      exchange=ExchangeType(''),
                      order_type=Order.Types.STOP,
                      instrument=_INSTRUMENT,
                  ),
                  instrument=_INSTRUMENT)
Exemplo n.º 4
0
    def test_stop_order_validation(self):
        if _in_cpp():
            return

        with pytest.raises(pydantic.ValidationError):
            Order(id=1,
                  timestamp=datetime.now(),
                  volume=0.0,
                  price=5.0,
                  side=Order.Sides.SELL,
                  exchange=ExchangeType(''),
                  order_type=Order.Types.STOP,
                  stop_target=Order(
                      id=1,
                      timestamp=datetime.now(),
                      volume=0.5,
                      price=5.0,
                      side=Order.Sides.SELL,
                      exchange=ExchangeType(''),
                      order_type=Order.Types.STOP,
                      instrument=_INSTRUMENT,
                  ),
                  instrument=_INSTRUMENT)
Exemplo n.º 5
0
from typing import Any

from aat.common import _in_cpp

try:
    from ...binding import InstrumentCpp  # type: ignore

    _CPP = _in_cpp()
except ImportError:
    InstrumentCpp = object
    _CPP = False


def _make_cpp_instrument(*args: Any, **kwargs: Any) -> InstrumentCpp:
    return InstrumentCpp(*args, **kwargs)