Trading Bot for Peakecoin.bnb

in #leofinance4 days ago

🚀 Automated Trading Bot for SWAP.BNB on Hive Engine

Trading in the world of Hive Engine is profitable, but automation is going to be crucial to staying ahead. I'm trying to create a Python-based trading bot designed for SWAP.BNB trading on Hive Engine, complete with order execution and FTP log uploads.


🛠️ Bot Overview

This trading bot automatically:
✅ Fetches the latest market data for SWAP.BNB
✅ Places buy and sell orders based on a configurable spread
✅ Uploads trade logs to an FTP server (optional)
✅ Runs continuously with a time delay between trades
✅Anything I've missed?

Below is the full Python script for the bot. 👇I'm working on each piece currently. Feel free to use this if you would like, but if there's anything wrong with what I've done. Please educate me; I do not know everything. I'm frankensteining things together at this point.


📝 Trading Bot Code

import time
import logging
from fetch_market import get_market_data
from place_order import place_order
from ftp_upload import upload_to_ftp

# Updated Bot Settings
TOKEN = "SWAP.BNB"       # Trading Token
ACCOUNT = "peakecoin.bnb" # Hive Engine Account
TRADE_AMOUNT = 5         # Number of tokens per trade (modify as needed)
SPREAD_PERCENT = 1.5     # Spread percentage (1.5% above/below market price)
SLEEP_TIME = 60          # Delay between trades (in seconds)

# Logging setup
logging.basicConfig(filename="bnb_trade_log.txt", level=logging.INFO,
                    format="%(asctime)s - %(levelname)s - %(message)s")

def trading_bot():
    """Main trading loop for executing orders on Hive Engine."""
    while True:
        try:
            market_data = get_market_data(TOKEN)
            if market_data:
                last_price = float(market_data['result'][0]['lastPrice'])
                buy_price = round(last_price * (1 - SPREAD_PERCENT / 100), 4)
                sell_price = round(last_price * (1 + SPREAD_PERCENT / 100), 4)

                logging.info(f"Market Price: {last_price} | Buy: {buy_price} | Sell: {sell_price}")

                # Place buy and sell orders
                buy_order = place_order(ACCOUNT, TOKEN, buy_price, TRADE_AMOUNT, "buy")
                sell_order = place_order(ACCOUNT, TOKEN, sell_price, TRADE_AMOUNT, "sell")

                logging.info(f"Buy Order Response: {buy_order}")
                logging.info(f"Sell Order Response: {sell_order}")

                # Upload log to FTP (Optional)
                upload_to_ftp("bnb_trade_log.txt", "bnb_trade_log.txt")

            else:
                logging.warning("No market data received.")

        except Exception as e:
            logging.error(f"Error in trading loop: {str(e)}")

        time.sleep(SLEEP_TIME)

if __name__ == "__main__":
    logging.info("Starting PeakeCoin Trading Bot for SWAP.BNB...")
    trading_bot()
Sort:  

Upvoted! Thank you for supporting witness @jswit.

Coin Marketplace

STEEM 0.14
TRX 0.23
JST 0.030
BTC 86268.53
ETH 2020.72
SBD 0.81