If you want to automate selling your HTN, this is a simple way to do it with bash scripts. Since bash is readily available in environments where HTN cli wallet is usable. We use cli wallet to manage sending HTN to Tradeogre. So that we don't mine there directly.
bash
installed. Linux environments usually have bash or compatible installed by default, but on Windows you need to install it with WSL. I'm not looking to do these scripts in bat.curl
installed. sudo apt install curl
jq
installed, which is bash compatible executable to parse JSON. In Ubuntu sudo apt install jq
.Then you need your miner to mine to the cli-wallet, so that the script has some funds available on the cli wallet.
Crate sell-htn.sh and copy this script to the file. Modify the configurations to your preferences.
#!/bin/bash
# Configurations
HTNWALLET="/home/user/go/bin/htnwallet" # Path to your HTND cli wallet executable.
CLI_PASSWORD="MyWalletPassword" # Your cli wallet password.
CLI_TO_INTERVAL=21600 # Interval in seconds to send HTN to TradeOgre (2 hours)
CLI_TO_QUANTITY=100000 # Amount of HTN to send
CLI_TO_ADDRESS="hoosat:qql8jh2a8pk9" # TradeOgre deposit address
SELL_INTERVAL=4320 # Interval in seconds to sell HTN on TradeOgre
SELL_QUANTITY=20000 # Quantity of HTN to sell
TRADEOGRE_API_PUBLIC="YourPublicAPIKey" # Replace with your TradeOgre public API key
TRADEOGRE_API_PRIVATE="YourPrivateAPIKey" # Replace with your TradeOgre private API key
TRADING_PAIR="HTN-USDT" # Trading pair (modifiable)
TRADEOGRE_SELL="https://tradeogre.com/api/v1/order/sell"
TRADEOGRE_ORDER_BOOK="https://tradeogre.com/api/v1/orders/$TRADING_PAIR"
# Function to send HTN to TradeOgre
send_cli_to() {
echo "Sending $CLI_TO_QUANTITY HTN to $CLI_TO_ADDRESS..."
$HTNWALLET send -v "$CLI_TO_QUANTITY" -t "$CLI_TO_ADDRESS" -p "$CLI_PASSWORD"
if [[ $? -eq 0 ]]; then
echo "HTN sent successfully."
else
echo "Error sending HTN. Check the logs or the configuration."
fi
}
# Function to get the current price from the order book
get_price_from_to() {
echo "Fetching order book for $TRADING_PAIR..."
response=$(curl -s -X GET "$TRADEOGRE_ORDER_BOOK")
if echo "$response" | grep -q "\"success\":true"; then
# Extract the lowest sell price and highest buy price
lowest_sell=$(echo "$response" | jq -r '.sell | keys_unsorted | sort | .[0]')
highest_buy=$(echo "$response" | jq -r '.buy | keys_unsorted | sort | .[-1]')
echo "Lowest sell price: $lowest_sell USDT"
echo "Highest buy price: $highest_buy USDT"
else
echo "Error fetching order book: $response"
fi
}
# Function to place a sell order on TradeOgre
sell_to() {
echo "Placing a sell order for $SELL_QUANTITY HTN..."
get_price_from_to
if [[ -z "$highest_buy" || "$highest_buy" == "null" || "$highest_buy" == "0" ]]; then
echo "Invalid highest buy price received. Cannot place sell order."
return
fi
SELL_PRICE="$highest_buy"
total_value=$(echo "$SELL_QUANTITY * $SELL_PRICE" | bc)
if (( $(echo "$total_value < 1" | bc -l) )); then
echo "Error: The total value of the order ($total_value) must be at least 1 USDT."
return
fi
response=$(curl -s -X POST "$TRADEOGRE_SELL" \
-u "$TRADEOGRE_API_PUBLIC:$TRADEOGRE_API_PRIVATE" \
-d "market=$TRADING_PAIR" \
-d "quantity=$SELL_QUANTITY" \
-d "price=$SELL_PRICE"
)
if echo "$response" | grep -q "\"success\":true"; then
echo "Sell order placed successfully: $response"
else
echo "Error placing sell order: $response"
fi
}
send_cli_to
sleep 1600
last_send_time=$(date +%s)
last_sell_time=$(date +%s)
while true; do
current_time=$(date +%s)
if (( current_time - last_send_time >= CLI_TO_INTERVAL )); then
send_cli_to
last_send_time=$current_time
fi
if (( current_time - last_sell_time >= SELL_INTERVAL )); then
sell_to
last_sell_time=$current_time
fi
sleep 1
done
Then chmod the file to be executable.
sudo chmod +x sell-htn.sh
Then run the file, once your cofigurations are right.
./sell-htn.sh
Happy automatic periodic selling..
If you need more comprehensive algorithmic crypto trading, Hoobot is available for purchase.