Created
May 24, 2019 08:17
-
-
Save MarkoPaasila/9edd560a0577d9298b074fed70263a76 to your computer and use it in GitHub Desktop.
method to acquire more of the fee asset by buying it with base or quote
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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