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())
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
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)
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()
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
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
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]))
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())
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]))