Updated cancel-my-orders to use CANCEL_ALL_PERPS instruction if possible.
This commit is contained in:
parent
2abb75f20c
commit
7d0b65e926
|
@ -38,9 +38,6 @@ instruction_builder: mango.PerpMarketInstructionBuilder
|
|||
if args.dry_run:
|
||||
mango.output("Dry run - no cancellations performed.")
|
||||
else:
|
||||
instruction_builder = mango.PerpMarketInstructionBuilder(context, wallet, group, account, market)
|
||||
market_operations = mango.PerpMarketOperations(market.symbol, context, wallet, instruction_builder, account, market)
|
||||
|
||||
instruction_builder = mango.PerpMarketInstructionBuilder(context, wallet, group, account, market)
|
||||
cancel_all = instruction_builder.build_cancel_all_orders_instructions()
|
||||
|
||||
|
|
|
@ -35,7 +35,16 @@ orders = market_operations.load_my_orders()
|
|||
if len(orders) == 0:
|
||||
mango.output(f"No open orders on {market.symbol}")
|
||||
else:
|
||||
for order in orders:
|
||||
mango.output("Cancelling:", order)
|
||||
cancellation = market_operations.cancel_order(order)
|
||||
mango.output(cancellation)
|
||||
if isinstance(market_operations.market, mango.PerpMarket):
|
||||
instruction_builder = mango.PerpMarketInstructionBuilder(
|
||||
context, wallet, group, account, market_operations.market)
|
||||
cancel_all = instruction_builder.build_cancel_all_orders_instructions()
|
||||
|
||||
signers: mango.CombinableInstructions = mango.CombinableInstructions.from_wallet(wallet)
|
||||
cancel_all_signatures = (signers + cancel_all).execute(context)
|
||||
mango.output(f"Cancelling all perp orders: {cancel_all_signatures}")
|
||||
else:
|
||||
for order in orders:
|
||||
mango.output("Cancelling:", order)
|
||||
cancellation_signatures = market_operations.cancel_order(order)
|
||||
mango.output(f"Cancellation signature: {cancellation_signatures}")
|
||||
|
|
Loading…
Reference in New Issue