41 lines
1.7 KiB
Plaintext
Executable File
41 lines
1.7 KiB
Plaintext
Executable File
#!/usr/bin/env pyston3
|
|
|
|
import argparse
|
|
import logging
|
|
import os
|
|
import os.path
|
|
import sys
|
|
|
|
sys.path.insert(0, os.path.abspath(
|
|
os.path.join(os.path.dirname(__file__), "..")))
|
|
import mango # nopep8
|
|
|
|
parser = argparse.ArgumentParser(description="Shows all orders on a market.")
|
|
mango.ContextBuilder.add_command_line_parameters(parser)
|
|
mango.Wallet.add_command_line_parameters(parser)
|
|
parser.add_argument("--market", type=str, required=True, help="market symbol to use (e.g. ETH/USDC)")
|
|
parser.add_argument("--id", type=int,
|
|
help="order ID of the order to cancel (either --client-id must be specified, or both --id and --side must be specified")
|
|
parser.add_argument("--client-id", type=int,
|
|
help="client ID of the order to cancel (either --client-id must be specified, or both --id and --side must be specified")
|
|
parser.add_argument("--side", type=mango.Side, default=mango.Side.BUY, choices=list(mango.Side),
|
|
help="whether the order to cancel is a BUY or a SELL (either --client-id must be specified, or both --id and --side must be specified")
|
|
args = parser.parse_args()
|
|
|
|
logging.getLogger().setLevel(args.log_level)
|
|
logging.warning(mango.WARNING_DISCLAIMER_TEXT)
|
|
|
|
context = mango.ContextBuilder.from_command_line_parameters(args)
|
|
wallet = mango.Wallet.from_command_line_parameters_or_raise(args)
|
|
|
|
market_symbol = args.market.upper()
|
|
market = context.market_lookup.find_by_symbol(market_symbol)
|
|
if market is None:
|
|
raise Exception(f"Could not find market {market_symbol}")
|
|
|
|
market_operations = mango.create_market_operations(context, wallet, False, market)
|
|
|
|
order = mango.Order.from_ids(id=args.id, client_id=args.client_id, side=args.side)
|
|
cancellation = market_operations.cancel_order(order)
|
|
print(cancellation)
|