
This script enables automatic trading on the Hive Engine marketplace by placing buy and sell orders using the Hive Engine API. It is a crucial part of the hive_trading_bot.py
and matic_trading_bot.py
scripts, allowing seamless execution of trades.
📜 Code Overview
place_order.py
Script
import time
import requests
# Hive Engine API Endpoint
HIVE_ENGINE_API = "https://api.hive-engine.com/rpc"
def place_order(account, token, price, quantity, order_type="buy"):
"""Places a buy/sell order on Hive Engine."""
payload = {
"jsonrpc": "2.0",
"method": "find",
"params": {
"contract": "market",
"table": "orders",
"query": {
"account": account,
"symbol": token,
"price": price,
"quantity": quantity,
"type": order_type
}
},
"id": int(time.time())
}
response = requests.post(f"{HIVE_ENGINE_API}/contracts", json=payload)
return response.json()