Skip to content

Instantly share code, notes, and snippets.

Embed
What would you like to do?
method to acquire more of the fee asset by buying it with base or quote
def top_up_fee_asset(self):
if self.fee_asset['symbol'] == self.b_symbol:
if self.cancel_orders(self.own_buy_orders[-1]):
self.log.info(f"Cancelled the last buy order to get some {self.b_symbol} for fee's")
return True
elif self.fee_asset['symbol'] == self.q_symbol:
if self.cancel_orders(self.own_sell_orders[-1]):
self.log.info(f"Cancelled the last sell order to get some {self.q_symbol} for fee's")
return True
else: # Must buy fee asset. Try first with base, then with quote
temp_market = Market(self.fee_asset['symbol'] + ':' + self.b_symbol)
if temp_market.ticker()['lowestAsk']:
if temp_market.buy(temp_market.ticker()['lowestAsk'],
self.get_order_creation_fee(self.fee_asset) * 100,
account=self.account):
self.log.info(f"Sold some {self.b_symbol} for {self.fee_asset['symbol']} for fee's")
temp_market = Market(self.fee_asset['symbol'] + ':' + self.q_symbol)
if temp_market.ticker()['lowestAsk']:
if temp_market.buy(temp_market.ticker()['lowestAsk'],
self.get_order_creation_fee(self.fee_asset) * 100,
account=self.account):
self.log.info(f"Sold some {self.q_symbol} for {self.fee_asset['symbol']} for fee's")
return True
return False
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment