PeakeBots Work Cancelling orders hopefully

@strangedad · 2025-06-18 02:11 · ['hive-193552']

PeakeCoin Cancel Orders Bot: Taking Out the Trash

Sick of your Hive Engine orderbook looking like a hoarder’s garage?
This bot runs on autopilot, nuking your oldest buy and sell orders every minute. No more ancient, half-rotten trades stinking up your account.
Plug it in, walk away, let it clean house.

If only it could cancel your bad life decisions too.


🦀



import time

from peake_ltc import HIVE_ACCOUNT as ACCOUNT, HIVE_POSTING_KEY, HIVE_ACTIVE_KEY, HIVE_NODES

from place_order import get_open_orders, cancel_order


# CONFIG

CANCEL_BUY = True

CANCEL_SELL = True

CANCEL_DELAY = 60  # seconds between cancels (increased to 60s)


# Cancel farthest (oldest/out-of-range) orders for all tokens, using keys from peake_ltc


def cancel_farthest_orders(account_name, cancel_buy=True, cancel_sell=True):

    print(f"\n--- Cancel Orders Bot (all tokens) ---")

    open_orders = get_open_orders(account_name)

    if not open_orders:

        print("No open orders found.")

        return

    buy_orders = [o for o in open_orders if o.get('type') == 'buy']

    sell_orders = [o for o in open_orders if o.get('type') == 'sell']

    print(f"Found {len(buy_orders)} buy orders and {len(sell_orders)} sell orders.")


    # Cancel the oldest buy order by timestamp if available

    if cancel_buy and buy_orders:

        if 'timestamp' in buy_orders[0]:

            oldest_buy = min(buy_orders, key=lambda o: o.get('timestamp', float('inf')))

        elif 'created' in buy_orders[0]:

            oldest_buy = min(buy_orders, key=lambda o: o.get('created', float('inf')))

        else:

            oldest_buy = min(buy_orders, key=lambda o: float(o['price']))

        order_id = oldest_buy.get('_id')

        price = oldest_buy.get('price')

        symbol = oldest_buy.get('symbol')

        ts = oldest_buy.get('timestamp', oldest_buy.get('created', 'N/A'))

        print(f"[DEBUG] Attempting to cancel OLDEST BUY order: _id={order_id}, symbol={symbol}, price={price}, timestamp={ts}")

        print(f"[DEBUG] Using account: {account_name}, active_key: {HIVE_ACTIVE_KEY[:6]}..., posting_key: {HIVE_POSTING_KEY[:6]}..., nodes: {HIVE_NODES}")

        print(f"[DEBUG] Cancel payload: {{'contractName': 'market', 'contractAction': 'cancel', 'contractPayload': {{'orderId': '{order_id}'}}}}")

        result = cancel_order(account_name, order_id, posting_key=HIVE_POSTING_KEY, active_key=HIVE_ACTIVE_KEY, nodes=HIVE_NODES)

        print(f"[DEBUG] Cancel result: {result}")

        time.sleep(CANCEL_DELAY)

    # Cancel the oldest sell order by timestamp if available

    if cancel_sell and sell_orders:

        if 'timestamp' in sell_orders[0]:

            oldest_sell = min(sell_orders, key=lambda o: o.get('timestamp', float('inf')))

        elif 'created' in sell_orders[0]:

            oldest_sell = min(sell_orders, key=lambda o: o.get('created', float('inf')))

        else:

            oldest_sell = max(sell_orders, key=lambda o: float(o['price']))

        order_id = oldest_sell.get('_id')

        price = oldest_sell.get('price')

        symbol = oldest_sell.get('symbol')

        ts = oldest_sell.get('timestamp', oldest_sell.get('created', 'N/A'))

        print(f"[DEBUG] Attempting to cancel OLDEST SELL order: _id={order_id}, symbol={symbol}, price={price}, timestamp={ts}")

        print(f"[DEBUG] Using account: {account_name}, active_key: {HIVE_ACTIVE_KEY[:6]}..., posting_key: {HIVE_POSTING_KEY[:6]}..., nodes: {HIVE_NODES}")

        print(f"[DEBUG] Cancel payload: {{'contractName': 'market', 'contractAction': 'cancel', 'contractPayload': {{'orderId': '{order_id}'}}}}")

        result = cancel_order(account_name, order_id, posting_key=HIVE_POSTING_KEY, active_key=HIVE_ACTIVE_KEY, nodes=HIVE_NODES)

        print(f"[DEBUG] Cancel result: {result}")

        time.sleep(CANCEL_DELAY)

    print("--- Cancel Orders Bot complete ---\n")


if __name__ == "__main__":

    while True:

        cancel_farthest_orders(ACCOUNT, CANCEL_BUY, CANCEL_SELL)

        time.sleep(60)  # Run every 60 seconds



This report was published via Actifit app (Android | iOS). Check out the original version here on actifit.io


16/06/2025
8739
Daily Activity

#hive-193552 #actifit #pimp #creativecoin #neoxian #palnet #waivio #utopis #archon #proofofbrain #lassecash #bilpcoin #leo #list #bee #byte # #sportstalk #movetoearn #move2earn
Payout: 0.000 HBD
Votes: 18
More interactions (upvote, reblog, reply) coming soon.