Beispiel #1
0
    def initialize(self, properties):
        # Interactive, mobile, hipchat, database and commission middlewares
        for middleware in common_middlewares(properties, self.identity):
            self.use(middleware)
        report_mails = properties.get('reports')
        if report_mails:
            self.use(mail.Report(report_mails).send_briefing)

        long_window = int(properties.get('long_window', 30))
        short_window = int(properties.get('short_window', 0))
        if not short_window:
            short_window = int(round(
                properties.get('ma_rate', 0.5) * float(long_window), 2))
        self.threshold = properties.get('threshold', 0)

        self.add_transform(MovingAverage, 'short_mavg', ['price'],
                           window_length=short_window)

        self.add_transform(MovingAverage, 'long_mavg', ['price'],
                           window_length=long_window)

        # To keep track of whether we invested in the stock or not
        self.invested = {}
        self.short_mavgs = []
        self.long_mavgs = []
Beispiel #2
0
    def initialize(self, properties):
        # Interactive, mobile, hipchat, database and commission middlewares
        for middleware in common_middlewares(properties, self.identity):
            self.use(middleware)
        report_mails = properties.get('reports')
        if report_mails:
            self.use(mail.Report(report_mails).send_briefing)

        long_window = int(properties.get('long_window', 30))
        short_window = int(properties.get('short_window', 0))
        if not short_window:
            short_window = int(
                round(properties.get('ma_rate', 0.5) * float(long_window), 2))
        self.threshold = properties.get('threshold', 0)

        self.add_transform(MovingAverage,
                           'short_mavg', ['price'],
                           window_length=short_window)

        self.add_transform(MovingAverage,
                           'long_mavg', ['price'],
                           window_length=long_window)

        # To keep track of whether we invested in the stock or not
        self.invested = {}
        self.short_mavgs = []
        self.long_mavgs = []
Beispiel #3
0
    def initialize(self, properties):
        # Punctual buy signals, except 0 means never
        self.start_time = properties.get('start_time', 3)
        # regularly buy signals
        self.rate = properties.get('rate', -1)

        # Interactive, mobile, hipchat, database and commission middlewares
        for middleware in common_middlewares(properties, self.identity):
            self.use(middleware)
Beispiel #4
0
    def initialize(self, properties):
        # Punctual buy signals, except 0 means never
        self.start_time = properties.get('start_time', 3)
        # regularly buy signals
        self.rate = properties.get('rate', -1)

        # Interactive, mobile, hipchat, database and commission middlewares
        for middleware in common_middlewares(properties, self.identity):
            self.use(middleware)
Beispiel #5
0
 def test_full_common_middlewares(self):
     # TODO For simplicity, rethinkdb is excluded for now
     full_required = {
         'save': False,
         'interactive': True,
         'mobile': 'Nexus 5',
         'hipchat': '123456'
     }
     middlewares = utils.common_middlewares(full_required, 'whatever')
     eq_(len(middlewares), 3)
     for middleware in middlewares:
         ok_(inspect.ismethod(middleware))
Beispiel #6
0
 def test_full_common_middlewares(self):
     # TODO For simplicity, rethinkdb is excluded for now
     full_required = {
         'save': False,
         'interactive': True,
         'mobile': 'Nexus 5',
         'hipchat': '123456'
     }
     middlewares = utils.common_middlewares(full_required, 'whatever')
     eq_(len(middlewares), 3)
     for middleware in middlewares:
         ok_(inspect.ismethod(middleware))
Beispiel #7
0
    def initialize(self, properties):

        for middleware in common_middlewares(properties, self.identity):
            self.use(middleware)

        self.buy_trigger = properties.get('buy_trigger',
                                          random.randint(500, 1000) / 1000.0)
        self.sell_trigger = properties.get('sell_trigger',
                                           random.randint(0, 500) / 1000.0)

        # Makes results reproductible
        random.seed(self.identity)
Beispiel #8
0
    def initialize(self, properties):

        for middleware in common_middlewares(properties, self.identity):
            self.use(middleware)

        self.buy_trigger = properties.get(
            'buy_trigger', random.randint(500, 1000) / 1000.0)
        self.sell_trigger = properties.get(
            'sell_trigger', random.randint(0, 500) / 1000.0)

        # Makes results reproductible
        random.seed(self.identity)
Beispiel #9
0
    def initialize(self, properties):

        for middleware in common_middlewares(properties, self.identity):
            self.use(middleware)

        # Set Max and Min positions in security
        self.max_notional = 1000000.1
        self.min_notional = -1000000.0

        # This is the lookback window that the entire algorithm depends on
        self.refresh_period = properties.get('rate', 10)
        self.returns_transform = transforms.get_past_returns(
            refresh_period=self.refresh_period,
            window_length=properties.get('window', 40),
            compute_only_full=True)
Beispiel #10
0
    def initialize(self, properties):

        for middleware in common_middlewares(properties, self.identity):
            self.use(middleware)

        # Set Max and Min positions in security
        self.max_notional = 1000000.1
        self.min_notional = -1000000.0

        # This is the lookback window that the entire algorithm depends on
        self.refresh_period = properties.get('rate', 10)
        self.returns_transform = transforms.get_past_returns(
            refresh_period=self.refresh_period,
            window_length=properties.get('window', 40),
            compute_only_full=True)
Beispiel #11
0
    def initialize(self, properties):

        # Interactive, mobile, hipchat, database and commission middlewares
        for middleware in common_middlewares(properties, self.identity):
            self.use(middleware)

        self.rebalance_period = properties.get('rebalance_period', 5)

        self.bet_amount = self.capital_base
        self.max_notional = self.capital_base + 0.1
        self.min_notional = -self.capital_base
        self.gradient_iterations = int(properties.get('gradient_iterations',
                                                      5))
        self.calculate_theta = calculate_theta(
            refresh_period=int(properties.get('refresh', 1)),
            window_length=int(properties.get('window', 60)))
Beispiel #12
0
    def initialize(self, properties):

        # Interactive, mobile, hipchat, database and commission middlewares
        for middleware in common_middlewares(properties, self.identity):
            self.use(middleware)

        self.rebalance_period = properties.get('rebalance_period', 5)

        self.bet_amount = self.capital_base
        self.max_notional = self.capital_base + 0.1
        self.min_notional = -self.capital_base
        self.gradient_iterations = int(
            properties.get('gradient_iterations', 5))
        self.calculate_theta = calculate_theta(
            refresh_period=int(properties.get('refresh', 1)),
            window_length=int(properties.get('window', 60))
        )
Beispiel #13
0
    def initialize(self, properties):
        # Interactive, mobile, hipchat, database and commission middlewares
        for middleware in common_middlewares(properties, self.identity):
            self.use(middleware)

        report_mails = properties.get('reports')
        if report_mails:
            self.use(mail.Report(report_mails).send_briefing)

        self.buy_trigger = properties.get('buy_trigger', 30)
        self.sell_trigger = properties.get('sell_trigger', 70)
        self.period = properties.get('period', 14)

        # RSI Signal
        self.rsi = ta.RSI(timeperiod=self.period)

        # Quotes loopback for managers
        self.prices_transform = transforms.get_past_prices(
            #refresh_period=10,
            window_length=properties.get('window', 40),
            compute_only_full=properties.get('only_full'))
Beispiel #14
0
    def initialize(self, properties):
        # Interactive, mobile, hipchat, database and commission middlewares
        for middleware in common_middlewares(properties, self.identity):
            self.use(middleware)

        report_mails = properties.get('reports')
        if report_mails:
            self.use(mail.Report(report_mails).send_briefing)

        self.buy_trigger = properties.get('buy_trigger', 30)
        self.sell_trigger = properties.get('sell_trigger', 70)
        self.period = properties.get('period', 14)

        # RSI Signal
        self.rsi = ta.RSI(timeperiod=self.period)

        # Quotes loopback for managers
        self.prices_transform = transforms.get_past_prices(
            #refresh_period=10,
            window_length=properties.get('window', 40),
            compute_only_full=properties.get('only_full'))
Beispiel #15
0
 def test_empty_common_middlewares(self):
     nothing_required = {}
     middlewares = utils.common_middlewares(nothing_required, 'whatever')
     eq_(middlewares, [])
Beispiel #16
0
 def test_empty_common_middlewares(self):
     nothing_required = {}
     middlewares = utils.common_middlewares(nothing_required, 'whatever')
     eq_(middlewares, [])