
If you’ve ever tried to build a crypto trading bot that actually works without paying for APIs or centralized exchange fees, you know how difficult it is to keep it decentralized, efficient, and low-cost.
Over the last few months, I developed a suite of autonomous trading bots for Hive Engine tokens like SWAP.LTC, SWAP.USDT, SWAP.HBD, and more. These bots run in parallel and trade on the Hive blockchain, placing real buy and sell orders based on profit thresholds, volume activity, and market spreads—all while avoiding redundant orders and respecting Hive's Resource Credit (RC) limitations.
⚙️ What Powers the Bots?
At the core is a Python script called dashboard.py, which launches each bot in a separate thread:
BOT_SCRIPTS = [
("LTC", "uni_ltc.py"),
("ETH", "uni_eth.py"),
("BTC", "uni_btc.py"),
("DOGE", "uni_doge.py"),
("HBD", "uni_hbd.py"),
("BNB", "uni_bnb.py"),
("USDT", "uni_tether.py"),
]
Each coin has its own strategy script—like uni_ltc.py or uni_usdt.py—but they all share a common framework and utility modules like:
profit_strategies.py – For profit checks
fetch_market.py – For reading Hive Engine order books
place_order.py – For placing/canceling orders with Hive Key authority
🤖 How Each Bot Thinks
Every cycle (usually every 25 minutes), a bot:
Checks Hive Resource Credits (RC) – Skips if RC < 10%.
Fetches Market Orders – Pulls the highest bid and lowest ask via get_orderbook_top().
Calculates Smart Prices:
Buy just above the highest bid
Sell just below the lowest ask—or at least 1% higher than buy price
Avoids Duplicates – Skips orders if a matching one already exists.
Checks Profit Logic – Uses is_profitable_or_volume_increase() to ensure it only sells when worthwhile.
Places Orders – Uses place_order() with Hive’s active_key and custom_json.
Here’s a snippet from the uni_tether.py bot:
if force_sell_price > buy_price and sell_qty > 0:
open_orders = get_open_orders(account_name, token)
duplicate_sell = any(o.get('type') == 'sell' and float(o.get('price', 0)) == force_sell_price for o in open_orders)
if not duplicate_sell:
place_order(account_name, token, force_sell_price, sell_qty, order_type="sell", ...)
📊 Profit Strategy: Tiny Margins, Consistent Gains
All bots aim for a minimum profit of 1%. Even if the market is flat, they’ll only sell if:
Profit ≥ 1%, or
Sell volume increases (indicating upward momentum)
By using both price and volume signals, this method avoids chasing losses or panic selling.
The core math:
def calculate_min_sell_price(buy_price, min_profit_percent=0.01):
return round(buy_price * (1 + min_profit_percent), 8)
🛡️ Fail-Safes and Governance
RC Protection: If resource credits fall too low, no trades happen, preserving account health.
Error Handling: Bots won’t crash from API or network errors. They simply log issues and retry next cycle.
Gas Management: A future upgrade includes buy_peakecoin_gas() to place low-cost PeakeCoin gas orders hourly.
🚀 Launching the Bots
Instead of launching manually, I use a shell script called run_all_bots.sh:
#!/bin/bash
python3 uni_ltc.py &
python3 uni_eth.py &
python3 uni_btc.py &
This makes it simple to deploy on a Raspberry Pi or VPS in parallel.