Skip to content

Commit

Permalink
Merge remote-tracking branch 'thehapax/cancel-bulk-orders' into pr-70…
Browse files Browse the repository at this point in the history
…1-merge
  • Loading branch information
joelvai committed Mar 11, 2020
2 parents c16ef2b + 05b8d8e commit 6e03518
Showing 1 changed file with 39 additions and 0 deletions.
39 changes: 39 additions & 0 deletions dexbot/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,11 @@
import signal
import sys

from uptick.decorators import online
import bitshares.exceptions
import graphenecommon.exceptions
from bitshares.market import Market

from dexbot.config import Config, DEFAULT_CONFIG_FILE
from dexbot.cli_conf import SYSTEMD_SERVICE_NAME, get_whiptail, setup_systemd
from dexbot.helper import initialize_orders_log, initialize_data_folders
Expand Down Expand Up @@ -180,6 +185,40 @@ def configure(ctx):
os.system("systemctl --user start dexbot")


@main.command()
@click.option("--account", default=None)
@click.argument("market")
@click.pass_context
@online
@unlock
def cancel(ctx, market, account):
"""
Cancel Orders in Mkt, (Eg: cancel USD/BTS --account name)
:param ctx: context
:param market: market e.g. USD/BTS
:param account: name of your bitshares acct
:return: Success or Fail message
"""
try:
my_market = Market(market)
ctx.bitshares.bundle = True
my_market.cancel([
x["id"] for x in my_market.accountopenorders(account)
], account=account)
response = ctx.bitshares.txbuffer.broadcast()
log.info(response)
if response is not None:
log.info(f'Cancelled all orders on Market: {market} for account: {account}')
else:
log.info(f'No orders to cancel! {market} for account: {account}')

except bitshares.exceptions.AssetDoesNotExistsException:
log.info(f"Asset does not exist: {market}")
except graphenecommon.exceptions.AccountDoesNotExistsException:
log.info(f"Account does not exist: {account}")


def worker_job(worker, job):
return lambda x, y: worker.do_next_tick(job)

Expand Down

0 comments on commit 6e03518

Please sign in to comment.