コード例 #1
0
ファイル: cli.py プロジェクト: tuxx42/btcbot
 def complete_set_globals(self, text, line, start_index, end_index):
     if text:
         return [
             gvar for gvar in gv.keys()
             if gvar.startswith(text)
         ]
     else:
         return list(gv.keys())
コード例 #2
0
    def depth(self, pair='btc_eur'):
        if 'depth_count' in gv.keys():
            count = int(gv['depth_count'])
        else:
            count = 20

        if not pair in self.pairs.keys():
            raise Exception('invalid pair', pair)

        try:
            s = self.api.query_public('Depth', {
                'pair': self.pairs[pair],
                'count': count
            })
        except Exception as e:
            log.exception(e)
            raise

        if s['error']:
            print("an error occured %s" % s['error'])
            raise Exception(s['error'])

        d = [depth(**v) for k, v in s['result'].items()][0]
        self.curdepth[pair] = [d, time.time()]
        return d
コード例 #3
0
ファイル: cli.py プロジェクト: tuxx42/btcbot
    def do_unset_globals(self, line):
        """unset_global <global_var> [<global_var> ... <global_var>]
        unsets a global variable"""
        for i in line.split():

            global gv
            if i in gv.keys():
                print("removing key:", i)
                del gv[i]
                self.config['global_vars'] = gv
                self.save_config()
            else:
                print("invalid key:", line)
コード例 #4
0
    def do_unset_globals(self, line):
        """unset_global <global_var> [<global_var> ... <global_var>]
        unsets a global variable"""
        for i in line.split():

            global gv
            if i in gv.keys():
                print("removing key:", i)
                del gv[i]
                self.config['global_vars'] = gv
                self.save_config()
            else:
                print("invalid key:", line)
コード例 #5
0
ファイル: cli.py プロジェクト: tuxx42/btcbot
 def do_set_globals(self, line):
     """set_global <global_var=value>
     set global variable to a new value"""
     try:
         d = dict([t.split('=') for t in shlex.split(line)])
     except Exception as e:
         print(e)
         return
     global gv
     if not d:
         self.do_show_globals('')
         return
     gv.update(d)
     self.config['global_vars'] = gv
     if "prompt" in gv.keys():
         self.prompt = gv['prompt'] + ' '
     self.save_config()
コード例 #6
0
 def do_set_globals(self, line):
     """set_global <global_var=value>
     set global variable to a new value"""
     try:
         d = dict([t.split('=') for t in shlex.split(line)])
     except Exception as e:
         print(e)
         return
     global gv
     if not d:
         self.do_show_globals('')
         return
     gv.update(d)
     self.config['global_vars'] = gv
     if "prompt" in gv.keys():
         self.prompt = gv['prompt'] + ' '
     self.save_config()
コード例 #7
0
 def depth(self, pair='btc_eur'):
     if 'depth_count' in gv.keys():
         count = int(gv['depth_count'])
     else:
         count = 20
     try:
         if pair == 'btc_ltc':
             pair = 'ltc_btc'
         s = self.api.get_param(pair, 'depth')
     except Exception as e:
         log.exception(e)
         raise Exception('could not get depth')
     d = depth(**s)
     if pair == 'ltc_btc':
         d.asks = list(map(lambda t: trade(1 / t.value, t.volume), d.asks))
         d.bids = list(map(lambda t: trade(1 / t.value, t.volume), d.bids))
     d.asks = d.asks[:count]
     d.bids = d.bids[-count:]
     btce.curdepth[pair] = [d, time.time()]
     return d
コード例 #8
0
ファイル: btce.py プロジェクト: thecao365/btcbot
 def depth(self, pair='btc_eur'):
     if 'depth_count' in gv.keys():
         count = int(gv['depth_count'])
     else:
         count = 20
     try:
         if pair == 'btc_ltc':
             pair = 'ltc_btc'
         s = self.api.get_param(pair, 'depth')
     except Exception as e:
         log.exception(e)
         raise Exception('could not get depth')
     d = depth(**s)
     if pair == 'ltc_btc':
         d.asks = list(map(lambda t: trade(1 / t.value, t.volume), d.asks))
         d.bids = list(map(lambda t: trade(1 / t.value, t.volume), d.bids))
     d.asks = d.asks[:count]
     d.bids = d.bids[-count:]
     btce.curdepth[pair] = [d, time.time()]
     return d
コード例 #9
0
ファイル: kraken.py プロジェクト: thecao365/btcbot
    def depth(self, pair='btc_eur'):
        if 'depth_count' in gv.keys():
            count = int(gv['depth_count'])
        else:
            count = 20

        if not pair in self.pairs.keys():
            raise Exception('invalid pair', pair)

        try:
            s = self.api.query_public('Depth', {'pair': self.pairs[pair],
                                                'count': count})
        except Exception as e:
            log.exception(e)
            raise

        if s['error']:
            print ("an error occured %s" % s['error'])
            raise Exception(s['error'])

        d = [depth(**v) for k, v in s['result'].items()][0]
        self.curdepth[pair] = [d, time.time()]
        return d
コード例 #10
0
ファイル: cli.py プロジェクト: tuxx42/btcbot
 def do_show_globals(self, line):
     """show_globals
     shows all global variable settings"""
     pad = max(len(x) for x in gv.keys())
     for i in sorted(gv.keys()):
         print("%*s: '%s'" % (- (pad + 3), i, gv[i]))
コード例 #11
0
 def complete_set_globals(self, text, line, start_index, end_index):
     if text:
         return [gvar for gvar in gv.keys() if gvar.startswith(text)]
     else:
         return list(gv.keys())
コード例 #12
0
 def do_show_globals(self, line):
     """show_globals
     shows all global variable settings"""
     pad = max(len(x) for x in gv.keys())
     for i in sorted(gv.keys()):
         print("%*s: '%s'" % (-(pad + 3), i, gv[i]))