class PyStrategy(TradingStrategy):
    """
    A strategy which is empty and does nothing.
    """
    def __init__(self, bar_type: BarType):
        """
        Initializes a new instance of the PyStrategy class.
        """
        super().__init__(order_id_tag='001')

        self.bar_type = bar_type
        self.object_storer = ObjectStorer()

    def on_start(self):
        self.subscribe_bars(self.bar_type)

    def on_tick(self, tick):
        pass

    def on_bar(self, bar_type, bar):
        print(bar)
        self.object_storer.store_2(bar_type, bar)

    def on_instrument(self, instrument):
        pass

    def on_event(self, event):
        self.object_storer.store(event)

    def on_stop(self):
        pass

    def on_reset(self):
        pass

    def on_save(self):
        return {}

    def on_load(self, state):
        pass

    def on_dispose(self):
        pass
Exemple #2
0
class PyStrategy(TradingStrategy):
    """
    A strategy which is empty and does nothing.
    """
    def __init__(self, bar_type: BarType):
        """Initialize a new instance of the PyStrategy class."""
        super().__init__(order_id_tag="001")

        self.bar_type = bar_type
        self.object_storer = ObjectStorer()

    def on_start(self):
        self.subscribe_bars(self.bar_type)

    def on_bar(self, bar_type, bar):
        self.object_storer.store_2(bar_type, bar)

    def on_event(self, event):
        self.object_storer.store(event)