PeakeBots Work Cancelling orders hopefully

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



0
0
0.000
2 comments
avatar

Congrats on providing Proof of Activity via your Actifit report!

You have been rewarded 47.1175 AFIT tokens for your effort in reaching 8739 activity, as well as your user rank and report quality!
You also received a 0.88% upvote via @actifit account.


Rewards Details

AFIT rewards and upvotes are based on your:
  • User rank: which depends on your delegated HP, accumulated AFIT tokens, rewarded post count, recent rewarded activity and owned AFITX.
  • Post score: which depends on your activity count, post content, post upvotes, quality comments, moderator review and user rank.

To improve your user rank, delegate more, pile up more AFIT and AFITX tokens, and post more.
To improve your post score, get to the max activity count, work on improving your post content, improve your user rank, engage with the community to get more upvotes and quality comments.

rulersig2.jpg
Chat with us on discord | Visit our website
Follow us on Twitter | Join us on Telegram
Download on playstore | Download on app store

Knowledge base:
FAQs | Whitepaper
How to signup | Maximize your rewards
Complete Actifit Tutorial
rulersig2.jpg
Support our efforts below by voting for:

0
0
0.000