Open Source PeakeCoin Trading Bot - Cancelling Orders Update

As I've spent a ton of gosh darn hours coding the best version of this bot. It is infuriating when the best version of it you've made just doesn't work EXACTLY how I want it to be. Aggravated to keep it simple, lol.




I can not get these cancel orders to work. I keep getting the same response that there is no TX available, and then they go onto pending cancels but never cancel.

If anyone has any information on how to make a bot to cancel pending orders, I'm really having an issue. I'm at the point now that I'm not sure if I'm calling for the right cancel order. I don't know if its beem or @nectarflower, it could even be Hive Engine's API.

The bot works well, but this is bugging me.

I'm thinking of going the route of creating an entirely different 'cancel_order.py' to cancel orders upon being called for by 'peake_matic.py'. Hopefully you don't judge me for not calling some things the correct things.

peakecoin_matic.py


# Cancel the oldest order if at or above limit
ORDER_LIMIT = 100
if num_open_orders >= ORDER_LIMIT or total_open_orders >= ORDER_LIMIT:
    printc("\n[ ORDER LIMIT WARNING ]", 'yellow')
    printc(f"- Open order limit reached ({num_open_orders} for {token}, {total_open_orders} total). Cancelling oldest order...", 'yellow')
    
    if open_orders:
        oldest = min(open_orders, key=lambda o: o.get('timestamp', o.get('_id', 0)))
        order_id = oldest.get('_id')
        ...
        success, txid, error = cancel_order(account_name, order_id)
        if success:
            printc(f"✅ Cancelled order: {order_id} (TXID: {txid})", 'green')
        else:
            printc(f"❌ Failed to cancel order {order_id}: {error}", 'red')


place_order.py


# Cancel the oldest order if at or above limit
ORDER_LIMIT = 100
if num_open_orders >= ORDER_LIMIT or total_open_orders >= ORDER_LIMIT:
    printc("\n[ ORDER LIMIT WARNING ]", 'yellow')
    printc(f"- Open order limit reached ({num_open_orders} for {token}, {total_open_orders} total). Cancelling oldest order...", 'yellow')
    
    if open_orders:
        oldest = min(open_orders, key=lambda o: o.get('timestamp', o.get('_id', 0)))
        order_id = oldest.get('_id')
        ...
        success, txid, error = cancel_order(account_name, order_id)
        if success:
            printc(f"✅ Cancelled order: {order_id} (TXID: {txid})", 'green')
        else:
            printc(f"❌ Failed to cancel order {order_id}: {error}", 'red')




0
0
0.000
6 comments
avatar

Are you pulling your txid from the chain or internal memory? I still don't really understand this stuff, but I do see a ton of failed tx still like this one. So if that order is later canceled it would fail. I am guessing all the magic of the json data is done in dependencies like beem or nectar.engine.

success, txid, error = cancel_order(account_name, order_id)

is that putting the correct order type in the json sent to chain? The Docs that below is the data needed to cancel an order.

{
"contractName": "market",
"contractAction": "cancel",
"contractPayload": {
    "type": "sell",
    "id": "1b7e32719b76f07e144d15c8d3045545b896e90b"
}

}

feel free to laugh at me because I know I am still missing a ton of knowledge to make stuff work. Anyway gl, thanks for sharing again.

0
0
0.000
avatar

Trying to either cancel oldest order or least likely to trade

0
0
0.000
avatar

are you able to print the json that it spits out to send to the chain?

0
0
0.000