Ejemplo n.º 1
0
    def keyCheck(self):
        '''Verify a key and secret are found, and have API access'''
        # check valid key length
        if len(self.config.apikey) <= 43 or len(self.config.apisecret) <= 63:
            self.log.warning('API credentials too short. Exiting.')
            import sys
            sys.exit('Verify you have input API key and secret.')
        # attempt to connect with credentials
        test = api.tradeapi(self.config.apikey, self.config.apisecret)
        # store the output
        self.rights = test.poll().get('return').get('rights')
        if type(self.rights) == None:
            self.log.warning('keycheck rights are Nonetype')
            self.log.warning(self.rights)
            import sys
            sys.exit('Verify you have input API key and secret.')

        info = self.rights.get('info')
        trade = self.rights.get('trade')
        if info:
            self.log.info('API info rights enabled')
        if trade:
            self.log.info('API trade rights enabled')
        if not info:
            self.log.warning('API info rights not enabled, cannot continue.')
            import sys
            sys.exit('API info rights not enabled. Exiting.')
        if not trade:
            self.log.info('API trade rights not enabled. Trading disabled.')
Ejemplo n.º 2
0
    def keyCheck(self):
        """Verify a key and secret are found, and have API access"""
        # check valid key length
        if len(self.config.apikey) <= 43 or len(self.config.apisecret) <= 63:
            self.log.warning('API credentials too short. Exiting.')
            import sys
            sys.exit('Verify you have input API key and secret.')
        # attempt to connect with credentials
        test = api.tradeapi(self.config.apikey, self.config.apisecret)
        # store the output
        self.rights = test.poll().get('return').get('rights')
        if isinstance(self.rights, None):
            self.log.warning('keycheck rights are Nonetype')
            self.log.warning(self.rights)
            import sys
            sys.exit('Verify you have input API key and secret.')

        info = self.rights.get('info')
        trade = self.rights.get('trade')
        if info:
            self.log.info('API info rights enabled')
        if trade:
            self.log.info('API trade rights enabled')
        if not info:
            self.log.warning('API info rights not enabled, cannot continue.')
            import sys
            sys.exit('API info rights not enabled. Exiting.')
        if not trade:
            self.log.info('API trade rights not enabled. Trading disabled.')
Ejemplo n.º 3
0
 def __init__(self):
     self.log = helper.Log()
     self.config = helper.Config()
     self.tick = api.publicapi()
     self.keyCheck()
     self.tapi = api.tradeapi(self.config.apikey,self.config.apisecret)
     self.signals = signals(self.config)
     self.tradeData = self.tapi.update()
     self.tickerData = self.tick.update(self.config.pairs)
     self.standingOrders = {}
     self.last = self.tick.getLast(self.config.pair)
     self.lastID = self.tick.getLastID(self.config.pair)
     self.shortPosition = None
     self.longOn = self.config.longOn