def issue_trades(self): for market in self.grids: self.market[market] = { 'lowestAsk': F(self.exchange.tickerFor(market).lowestAsk), 'highestBid': F(self.exchange.tickerFor(market).highestBid), } for buysell in self.grids[market]: g = self.grids[market][buysell] if buysell in 'buy sell': try: g.place_orders(self.exchange) except (exception.NotEnoughCoin, exception.DustTrade): logging.debug( "%s grid not fully created because there was not enough coin", buysell) else: raise exception.InvalidDictionaryKey( "Key other than buy or sell: %s", buysell)
def issue_trades(self): for market in self.grids: t = self.exchange.fetchTicker(market) ask = t['ask'] bid = t['bid'] print(f"ask={ask} on {market}") self.market[market] = { 'lowestAsk': F(ask), 'highestBid': F(bid), } for buysell in self.grids[market]: g = self.grids[market][buysell] if buysell in 'buy sell': try: g.place_orders(self.exchange) except (exception.NotEnoughCoin, exception.DustTrade): logger.info( "%s grid not fully created because there was not enough coin", buysell) else: raise exception.InvalidDictionaryKey( "Key other than buy or sell: %s", buysell)
def fillAmount(self, trade_id): r = self.api.returnOrderTrades(trade_id) if isinstance(r, dict): if r.get('error'): return 0 else: raise Exception("Received dict but not error in it.") amount_filled = F(0) logging.debug("R={0}".format(pprint.pformat(r))) for v in r: logging.debug("V={0}".format(v)) amount_filled += float(v['amount']) logging.debug("amount filled = {0}".format(amount_filled)) return amount_filled
def highestBid(self): return F(self['Bid'])
def lowestAsk(self): return F(self['Ask'])
def midPoint(self): hb = self.highestBid la = self.lowestAsk logging.debug("tla {} thb {}".format(type(la), type(hb))) return (F(self.highestBid) + F(self.lowestAsk)) / 2.0
def midpoint(self, pair): pair_info = self.exchange.tickerFor(pair) logging.debug("Pair info in Midpoint = {}".format(pair_info)) return (F(pair_info.lowestAsk) + F(pair_info.highestBid)) / 2.0
def midpoint(self, market): ic(market) ticker = self.exchange.fetchTicker(market) return (F(ticker['ask']) + F(ticker['bid'])) / 2.0