@hummingbot/skills 1.0.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +63 -0
- package/package.json +28 -0
- package/skills/candles-feed/SKILL.md +259 -0
- package/skills/candles-feed/scripts/calculate_indicator.sh +359 -0
- package/skills/candles-feed/scripts/get_candles.sh +158 -0
- package/skills/candles-feed/scripts/get_funding_rate.sh +112 -0
- package/skills/candles-feed/scripts/get_price.sh +86 -0
- package/skills/candles-feed/scripts/list_candle_connectors.sh +47 -0
- package/skills/executor-creator/SKILL.md +212 -0
- package/skills/executor-creator/scripts/clear_position.sh +54 -0
- package/skills/executor-creator/scripts/create_executor.sh +92 -0
- package/skills/executor-creator/scripts/get_executor.sh +37 -0
- package/skills/executor-creator/scripts/get_executor_schema.sh +37 -0
- package/skills/executor-creator/scripts/get_executors_summary.sh +30 -0
- package/skills/executor-creator/scripts/get_position.sh +44 -0
- package/skills/executor-creator/scripts/get_positions.sh +30 -0
- package/skills/executor-creator/scripts/list_executor_types.sh +30 -0
- package/skills/executor-creator/scripts/list_executors.sh +52 -0
- package/skills/executor-creator/scripts/setup_executor.sh +197 -0
- package/skills/executor-creator/scripts/stop_executor.sh +54 -0
- package/skills/hummingbot-api-setup/SKILL.md +308 -0
- package/skills/hummingbot-api-setup/references/original_setup.sh +628 -0
- package/skills/hummingbot-api-setup/scripts/check_prerequisites.sh +92 -0
- package/skills/hummingbot-api-setup/scripts/deploy_full_stack.sh +151 -0
- package/skills/hummingbot-api-setup/scripts/health_check.sh +100 -0
- package/skills/hummingbot-api-setup/scripts/step1_detect_system.sh +88 -0
- package/skills/hummingbot-api-setup/scripts/step2_check_dependencies.sh +81 -0
- package/skills/keys-manager/SKILL.md +132 -0
- package/skills/keys-manager/scripts/add_credentials.sh +106 -0
- package/skills/keys-manager/scripts/get_connector_config.sh +67 -0
- package/skills/keys-manager/scripts/list_account_credentials.sh +82 -0
- package/skills/keys-manager/scripts/list_connectors.sh +64 -0
- package/skills/keys-manager/scripts/remove_credentials.sh +79 -0
- package/skills/keys-manager/scripts/setup_connector.sh +214 -0
- package/skills.json +137 -0
|
@@ -0,0 +1,158 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Fetch candlestick (OHLCV) data for a trading pair
|
|
3
|
+
# Usage: ./get_candles.sh --connector CONNECTOR --pair TRADING_PAIR [--interval INTERVAL] [--days DAYS]
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
API_URL="${API_URL:-http://localhost:8000}"
|
|
8
|
+
API_USER="${API_USER:-admin}"
|
|
9
|
+
API_PASS="${API_PASS:-admin}"
|
|
10
|
+
CONNECTOR=""
|
|
11
|
+
TRADING_PAIR=""
|
|
12
|
+
INTERVAL="1h"
|
|
13
|
+
DAYS=30
|
|
14
|
+
|
|
15
|
+
# Parse arguments
|
|
16
|
+
while [[ $# -gt 0 ]]; do
|
|
17
|
+
case $1 in
|
|
18
|
+
--connector)
|
|
19
|
+
CONNECTOR="$2"
|
|
20
|
+
shift 2
|
|
21
|
+
;;
|
|
22
|
+
--pair)
|
|
23
|
+
TRADING_PAIR="$2"
|
|
24
|
+
shift 2
|
|
25
|
+
;;
|
|
26
|
+
--interval)
|
|
27
|
+
INTERVAL="$2"
|
|
28
|
+
shift 2
|
|
29
|
+
;;
|
|
30
|
+
--days)
|
|
31
|
+
DAYS="$2"
|
|
32
|
+
shift 2
|
|
33
|
+
;;
|
|
34
|
+
--api-url)
|
|
35
|
+
API_URL="$2"
|
|
36
|
+
shift 2
|
|
37
|
+
;;
|
|
38
|
+
--api-user)
|
|
39
|
+
API_USER="$2"
|
|
40
|
+
shift 2
|
|
41
|
+
;;
|
|
42
|
+
--api-pass)
|
|
43
|
+
API_PASS="$2"
|
|
44
|
+
shift 2
|
|
45
|
+
;;
|
|
46
|
+
*)
|
|
47
|
+
shift
|
|
48
|
+
;;
|
|
49
|
+
esac
|
|
50
|
+
done
|
|
51
|
+
|
|
52
|
+
# Validate required arguments
|
|
53
|
+
if [ -z "$CONNECTOR" ]; then
|
|
54
|
+
echo '{"error": "connector is required. Use --connector CONNECTOR_NAME"}'
|
|
55
|
+
exit 1
|
|
56
|
+
fi
|
|
57
|
+
|
|
58
|
+
if [ -z "$TRADING_PAIR" ]; then
|
|
59
|
+
echo '{"error": "trading pair is required. Use --pair TRADING_PAIR"}'
|
|
60
|
+
exit 1
|
|
61
|
+
fi
|
|
62
|
+
|
|
63
|
+
# Validate interval
|
|
64
|
+
case "$INTERVAL" in
|
|
65
|
+
1m|5m|15m|30m|1h|4h|1d|1w)
|
|
66
|
+
;;
|
|
67
|
+
*)
|
|
68
|
+
echo '{"error": "Invalid interval. Use 1m, 5m, 15m, 30m, 1h, 4h, 1d, or 1w"}'
|
|
69
|
+
exit 1
|
|
70
|
+
;;
|
|
71
|
+
esac
|
|
72
|
+
|
|
73
|
+
# Calculate max_records based on interval
|
|
74
|
+
case "$INTERVAL" in
|
|
75
|
+
*m)
|
|
76
|
+
MINUTES=${INTERVAL%m}
|
|
77
|
+
MAX_RECORDS=$((1440 * DAYS / MINUTES))
|
|
78
|
+
;;
|
|
79
|
+
*h)
|
|
80
|
+
HOURS=${INTERVAL%h}
|
|
81
|
+
MAX_RECORDS=$((24 * DAYS / HOURS))
|
|
82
|
+
;;
|
|
83
|
+
*d)
|
|
84
|
+
MAX_RECORDS=$DAYS
|
|
85
|
+
;;
|
|
86
|
+
*w)
|
|
87
|
+
MAX_RECORDS=$((DAYS / 7))
|
|
88
|
+
;;
|
|
89
|
+
esac
|
|
90
|
+
|
|
91
|
+
# Calculate timestamps for historical fetch
|
|
92
|
+
END_TIME=$(date +%s)
|
|
93
|
+
START_TIME=$((END_TIME - DAYS * 24 * 3600))
|
|
94
|
+
|
|
95
|
+
# Step 1: Fetch historical candles
|
|
96
|
+
HISTORICAL=$(curl -s -u "$API_USER:$API_PASS" \
|
|
97
|
+
-X POST "$API_URL/market-data/historical-candles" \
|
|
98
|
+
-H "Content-Type: application/json" \
|
|
99
|
+
-d "{\"connector_name\": \"$CONNECTOR\", \"trading_pair\": \"$TRADING_PAIR\", \"interval\": \"$INTERVAL\", \"start_time\": $START_TIME, \"end_time\": $END_TIME}" 2>/dev/null || echo "[]")
|
|
100
|
+
|
|
101
|
+
# Step 2: Fetch real-time candles
|
|
102
|
+
REALTIME=$(curl -s -u "$API_USER:$API_PASS" \
|
|
103
|
+
-X POST "$API_URL/market-data/candles" \
|
|
104
|
+
-H "Content-Type: application/json" \
|
|
105
|
+
-d "{\"connector_name\": \"$CONNECTOR\", \"trading_pair\": \"$TRADING_PAIR\", \"interval\": \"$INTERVAL\", \"max_records\": 100}" 2>/dev/null || echo "[]")
|
|
106
|
+
|
|
107
|
+
# Step 3: Merge and deduplicate by timestamp (real-time overrides historical)
|
|
108
|
+
CANDLES=$(echo "$HISTORICAL $REALTIME" | jq -s '.[0] + .[1] | group_by(.timestamp) | map(.[0]) | sort_by(.timestamp)')
|
|
109
|
+
|
|
110
|
+
# Check for error
|
|
111
|
+
if echo "$CANDLES" | jq -e '.detail' > /dev/null 2>&1; then
|
|
112
|
+
echo "{\"error\": \"Failed to fetch candles\", \"detail\": $CANDLES}"
|
|
113
|
+
exit 1
|
|
114
|
+
fi
|
|
115
|
+
|
|
116
|
+
# Get candle count
|
|
117
|
+
TOTAL=$(echo "$CANDLES" | jq 'length')
|
|
118
|
+
|
|
119
|
+
# Get latest candle stats
|
|
120
|
+
if [ "$TOTAL" -gt 0 ]; then
|
|
121
|
+
LATEST=$(echo "$CANDLES" | jq '.[-1]')
|
|
122
|
+
FIRST=$(echo "$CANDLES" | jq '.[0]')
|
|
123
|
+
LATEST_CLOSE=$(echo "$LATEST" | jq '.close')
|
|
124
|
+
FIRST_CLOSE=$(echo "$FIRST" | jq '.close')
|
|
125
|
+
|
|
126
|
+
# Calculate price change
|
|
127
|
+
CHANGE=$(echo "scale=4; ($LATEST_CLOSE - $FIRST_CLOSE) / $FIRST_CLOSE * 100" | bc 2>/dev/null || echo "0")
|
|
128
|
+
|
|
129
|
+
# Get high/low for period
|
|
130
|
+
HIGH=$(echo "$CANDLES" | jq '[.[].high] | max')
|
|
131
|
+
LOW=$(echo "$CANDLES" | jq '[.[].low] | min')
|
|
132
|
+
TOTAL_VOLUME=$(echo "$CANDLES" | jq '[.[].volume] | add')
|
|
133
|
+
else
|
|
134
|
+
LATEST="null"
|
|
135
|
+
CHANGE="0"
|
|
136
|
+
HIGH="0"
|
|
137
|
+
LOW="0"
|
|
138
|
+
TOTAL_VOLUME="0"
|
|
139
|
+
fi
|
|
140
|
+
|
|
141
|
+
cat << EOF
|
|
142
|
+
{
|
|
143
|
+
"connector": "$CONNECTOR",
|
|
144
|
+
"trading_pair": "$TRADING_PAIR",
|
|
145
|
+
"interval": "$INTERVAL",
|
|
146
|
+
"days": $DAYS,
|
|
147
|
+
"total_candles": $TOTAL,
|
|
148
|
+
"summary": {
|
|
149
|
+
"latest_close": $LATEST_CLOSE,
|
|
150
|
+
"period_high": $HIGH,
|
|
151
|
+
"period_low": $LOW,
|
|
152
|
+
"price_change_pct": $CHANGE,
|
|
153
|
+
"total_volume": $TOTAL_VOLUME
|
|
154
|
+
},
|
|
155
|
+
"latest_candle": $LATEST,
|
|
156
|
+
"candles": $CANDLES
|
|
157
|
+
}
|
|
158
|
+
EOF
|
|
@@ -0,0 +1,112 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Get funding rate for perpetual trading pairs
|
|
3
|
+
# Usage: ./get_funding_rate.sh --connector CONNECTOR_PERPETUAL --pair TRADING_PAIR
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
API_URL="${API_URL:-http://localhost:8000}"
|
|
8
|
+
API_USER="${API_USER:-admin}"
|
|
9
|
+
API_PASS="${API_PASS:-admin}"
|
|
10
|
+
CONNECTOR=""
|
|
11
|
+
TRADING_PAIR=""
|
|
12
|
+
|
|
13
|
+
# Parse arguments
|
|
14
|
+
while [[ $# -gt 0 ]]; do
|
|
15
|
+
case $1 in
|
|
16
|
+
--connector)
|
|
17
|
+
CONNECTOR="$2"
|
|
18
|
+
shift 2
|
|
19
|
+
;;
|
|
20
|
+
--pair)
|
|
21
|
+
TRADING_PAIR="$2"
|
|
22
|
+
shift 2
|
|
23
|
+
;;
|
|
24
|
+
--api-url)
|
|
25
|
+
API_URL="$2"
|
|
26
|
+
shift 2
|
|
27
|
+
;;
|
|
28
|
+
--api-user)
|
|
29
|
+
API_USER="$2"
|
|
30
|
+
shift 2
|
|
31
|
+
;;
|
|
32
|
+
--api-pass)
|
|
33
|
+
API_PASS="$2"
|
|
34
|
+
shift 2
|
|
35
|
+
;;
|
|
36
|
+
*)
|
|
37
|
+
shift
|
|
38
|
+
;;
|
|
39
|
+
esac
|
|
40
|
+
done
|
|
41
|
+
|
|
42
|
+
# Validate required arguments
|
|
43
|
+
if [ -z "$CONNECTOR" ]; then
|
|
44
|
+
echo '{"error": "connector is required. Use --connector CONNECTOR_NAME (must be perpetual)"}'
|
|
45
|
+
exit 1
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
if [ -z "$TRADING_PAIR" ]; then
|
|
49
|
+
echo '{"error": "trading pair is required. Use --pair TRADING_PAIR"}'
|
|
50
|
+
exit 1
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
# Check if connector is perpetual
|
|
54
|
+
if [[ "$CONNECTOR" != *"perpetual"* ]]; then
|
|
55
|
+
echo "{\"error\": \"Connector '$CONNECTOR' is not a perpetual connector. Funding rates are only available for perpetual connectors (e.g., binance_perpetual)\"}"
|
|
56
|
+
exit 1
|
|
57
|
+
fi
|
|
58
|
+
|
|
59
|
+
# Fetch funding rate (POST request with JSON body)
|
|
60
|
+
FUNDING=$(curl -s -u "$API_USER:$API_PASS" \
|
|
61
|
+
-X POST "$API_URL/market-data/funding-info" \
|
|
62
|
+
-H "Content-Type: application/json" \
|
|
63
|
+
-d "{\"connector_name\": \"$CONNECTOR\", \"trading_pair\": \"$TRADING_PAIR\"}")
|
|
64
|
+
|
|
65
|
+
# Check for error
|
|
66
|
+
if echo "$FUNDING" | jq -e '.detail' > /dev/null 2>&1; then
|
|
67
|
+
echo "{\"error\": \"Failed to fetch funding rate\", \"detail\": $FUNDING}"
|
|
68
|
+
exit 1
|
|
69
|
+
fi
|
|
70
|
+
|
|
71
|
+
# Extract and format data
|
|
72
|
+
FUNDING_RATE=$(echo "$FUNDING" | jq '.funding_rate // 0')
|
|
73
|
+
MARK_PRICE=$(echo "$FUNDING" | jq '.mark_price // 0')
|
|
74
|
+
INDEX_PRICE=$(echo "$FUNDING" | jq '.index_price // 0')
|
|
75
|
+
NEXT_FUNDING_TIME=$(echo "$FUNDING" | jq '.next_funding_time // 0')
|
|
76
|
+
|
|
77
|
+
# Calculate funding rate percentage
|
|
78
|
+
FUNDING_PCT=$(echo "scale=6; $FUNDING_RATE * 100" | bc 2>/dev/null || echo "0")
|
|
79
|
+
|
|
80
|
+
# Calculate annualized rate (3 funding periods per day * 365)
|
|
81
|
+
ANNUAL_PCT=$(echo "scale=2; $FUNDING_PCT * 3 * 365" | bc 2>/dev/null || echo "0")
|
|
82
|
+
|
|
83
|
+
# Format next funding time
|
|
84
|
+
if [ "$NEXT_FUNDING_TIME" != "0" ] && [ "$NEXT_FUNDING_TIME" != "null" ]; then
|
|
85
|
+
NEXT_TIME_STR=$(date -d "@$NEXT_FUNDING_TIME" "+%Y-%m-%d %H:%M:%S" 2>/dev/null || date -r "$NEXT_FUNDING_TIME" "+%Y-%m-%d %H:%M:%S" 2>/dev/null || echo "N/A")
|
|
86
|
+
else
|
|
87
|
+
NEXT_TIME_STR="N/A"
|
|
88
|
+
fi
|
|
89
|
+
|
|
90
|
+
# Determine sentiment
|
|
91
|
+
if (( $(echo "$FUNDING_RATE > 0.0001" | bc -l 2>/dev/null || echo 0) )); then
|
|
92
|
+
SENTIMENT="bullish (longs pay shorts)"
|
|
93
|
+
elif (( $(echo "$FUNDING_RATE < -0.0001" | bc -l 2>/dev/null || echo 0) )); then
|
|
94
|
+
SENTIMENT="bearish (shorts pay longs)"
|
|
95
|
+
else
|
|
96
|
+
SENTIMENT="neutral"
|
|
97
|
+
fi
|
|
98
|
+
|
|
99
|
+
cat << EOF
|
|
100
|
+
{
|
|
101
|
+
"connector": "$CONNECTOR",
|
|
102
|
+
"trading_pair": "$TRADING_PAIR",
|
|
103
|
+
"funding_rate": $FUNDING_RATE,
|
|
104
|
+
"funding_rate_pct": $FUNDING_PCT,
|
|
105
|
+
"annualized_rate_pct": $ANNUAL_PCT,
|
|
106
|
+
"mark_price": $MARK_PRICE,
|
|
107
|
+
"index_price": $INDEX_PRICE,
|
|
108
|
+
"next_funding_time": "$NEXT_TIME_STR",
|
|
109
|
+
"sentiment": "$SENTIMENT",
|
|
110
|
+
"interpretation": "Current funding rate of ${FUNDING_PCT}% means ${SENTIMENT}"
|
|
111
|
+
}
|
|
112
|
+
EOF
|
|
@@ -0,0 +1,86 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Get current prices for trading pairs
|
|
3
|
+
# Usage: ./get_price.sh --connector CONNECTOR --pairs "PAIR1,PAIR2"
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
API_URL="${API_URL:-http://localhost:8000}"
|
|
8
|
+
API_USER="${API_USER:-admin}"
|
|
9
|
+
API_PASS="${API_PASS:-admin}"
|
|
10
|
+
CONNECTOR=""
|
|
11
|
+
PAIRS=""
|
|
12
|
+
|
|
13
|
+
# Parse arguments
|
|
14
|
+
while [[ $# -gt 0 ]]; do
|
|
15
|
+
case $1 in
|
|
16
|
+
--connector)
|
|
17
|
+
CONNECTOR="$2"
|
|
18
|
+
shift 2
|
|
19
|
+
;;
|
|
20
|
+
--pairs)
|
|
21
|
+
PAIRS="$2"
|
|
22
|
+
shift 2
|
|
23
|
+
;;
|
|
24
|
+
--api-url)
|
|
25
|
+
API_URL="$2"
|
|
26
|
+
shift 2
|
|
27
|
+
;;
|
|
28
|
+
--api-user)
|
|
29
|
+
API_USER="$2"
|
|
30
|
+
shift 2
|
|
31
|
+
;;
|
|
32
|
+
--api-pass)
|
|
33
|
+
API_PASS="$2"
|
|
34
|
+
shift 2
|
|
35
|
+
;;
|
|
36
|
+
*)
|
|
37
|
+
shift
|
|
38
|
+
;;
|
|
39
|
+
esac
|
|
40
|
+
done
|
|
41
|
+
|
|
42
|
+
# Validate required arguments
|
|
43
|
+
if [ -z "$CONNECTOR" ]; then
|
|
44
|
+
echo '{"error": "connector is required. Use --connector CONNECTOR_NAME"}'
|
|
45
|
+
exit 1
|
|
46
|
+
fi
|
|
47
|
+
|
|
48
|
+
if [ -z "$PAIRS" ]; then
|
|
49
|
+
echo '{"error": "trading pairs are required. Use --pairs \"PAIR1,PAIR2\""}'
|
|
50
|
+
exit 1
|
|
51
|
+
fi
|
|
52
|
+
|
|
53
|
+
# Convert pairs to JSON array format
|
|
54
|
+
PAIRS_JSON=$(echo "$PAIRS" | tr ',' '\n' | jq -R . | jq -s .)
|
|
55
|
+
|
|
56
|
+
# Fetch prices (POST request with JSON body)
|
|
57
|
+
RESPONSE=$(curl -s -u "$API_USER:$API_PASS" \
|
|
58
|
+
-X POST "$API_URL/market-data/prices" \
|
|
59
|
+
-H "Content-Type: application/json" \
|
|
60
|
+
-d "{\"connector_name\": \"$CONNECTOR\", \"trading_pairs\": $PAIRS_JSON}")
|
|
61
|
+
|
|
62
|
+
# Check for error
|
|
63
|
+
if echo "$RESPONSE" | jq -e '.detail' > /dev/null 2>&1; then
|
|
64
|
+
echo "{\"error\": \"Failed to fetch prices\", \"detail\": $RESPONSE}"
|
|
65
|
+
exit 1
|
|
66
|
+
fi
|
|
67
|
+
|
|
68
|
+
# Extract prices and timestamp from response
|
|
69
|
+
PRICES=$(echo "$RESPONSE" | jq '.prices')
|
|
70
|
+
TIMESTAMP=$(echo "$RESPONSE" | jq -r '.timestamp // 0')
|
|
71
|
+
|
|
72
|
+
# Format timestamp
|
|
73
|
+
if [ "$TIMESTAMP" != "0" ] && [ "$TIMESTAMP" != "null" ]; then
|
|
74
|
+
TIME_STR=$(date -d "@${TIMESTAMP%.*}" "+%Y-%m-%d %H:%M:%S" 2>/dev/null || date -r "${TIMESTAMP%.*}" "+%Y-%m-%d %H:%M:%S" 2>/dev/null || echo "N/A")
|
|
75
|
+
else
|
|
76
|
+
TIME_STR="N/A"
|
|
77
|
+
fi
|
|
78
|
+
|
|
79
|
+
cat << EOF
|
|
80
|
+
{
|
|
81
|
+
"connector": "$CONNECTOR",
|
|
82
|
+
"prices": $PRICES,
|
|
83
|
+
"timestamp": "$TIME_STR",
|
|
84
|
+
"pairs_requested": $(echo "$PAIRS" | tr ',' '\n' | jq -R . | jq -s .)
|
|
85
|
+
}
|
|
86
|
+
EOF
|
|
@@ -0,0 +1,47 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# List connectors that support candle data
|
|
3
|
+
# Usage: ./list_candle_connectors.sh
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
API_URL="${API_URL:-http://localhost:8000}"
|
|
8
|
+
API_USER="${API_USER:-admin}"
|
|
9
|
+
API_PASS="${API_PASS:-admin}"
|
|
10
|
+
|
|
11
|
+
# Parse arguments
|
|
12
|
+
while [[ $# -gt 0 ]]; do
|
|
13
|
+
case $1 in
|
|
14
|
+
--api-url)
|
|
15
|
+
API_URL="$2"
|
|
16
|
+
shift 2
|
|
17
|
+
;;
|
|
18
|
+
--api-user)
|
|
19
|
+
API_USER="$2"
|
|
20
|
+
shift 2
|
|
21
|
+
;;
|
|
22
|
+
--api-pass)
|
|
23
|
+
API_PASS="$2"
|
|
24
|
+
shift 2
|
|
25
|
+
;;
|
|
26
|
+
*)
|
|
27
|
+
shift
|
|
28
|
+
;;
|
|
29
|
+
esac
|
|
30
|
+
done
|
|
31
|
+
|
|
32
|
+
# Get list of connectors that support candles
|
|
33
|
+
CONNECTORS=$(curl -s -u "$API_USER:$API_PASS" "$API_URL/market-data/available-candle-connectors")
|
|
34
|
+
|
|
35
|
+
# Check for error
|
|
36
|
+
if echo "$CONNECTORS" | jq -e '.detail' > /dev/null 2>&1; then
|
|
37
|
+
echo "{\"error\": \"Failed to get candle connectors\", \"detail\": $CONNECTORS}"
|
|
38
|
+
exit 1
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
cat << EOF
|
|
42
|
+
{
|
|
43
|
+
"connectors": $CONNECTORS,
|
|
44
|
+
"total": $(echo "$CONNECTORS" | jq 'length'),
|
|
45
|
+
"supported_intervals": ["1m", "5m", "15m", "30m", "1h", "4h", "1d", "1w"]
|
|
46
|
+
}
|
|
47
|
+
EOF
|
|
@@ -0,0 +1,212 @@
|
|
|
1
|
+
---
|
|
2
|
+
name: executor-creator
|
|
3
|
+
description: Create and manage Hummingbot trading executors (position, grid, DCA, TWAP) directly via API. Use this skill when the user wants to create trading positions, set up grid trading, dollar-cost averaging, or any automated trading execution.
|
|
4
|
+
license: Apache-2.0
|
|
5
|
+
---
|
|
6
|
+
|
|
7
|
+
# Hummingbot Executors Skill
|
|
8
|
+
|
|
9
|
+
This skill manages **executors** - lightweight trading components that run directly via the Hummingbot API. Executors are the recommended starting point for new users.
|
|
10
|
+
|
|
11
|
+
## Quick Start: Setup Executor (Progressive Disclosure)
|
|
12
|
+
|
|
13
|
+
The `setup_executor.sh` script guides you through creating executors step by step:
|
|
14
|
+
|
|
15
|
+
### Step 1: List Available Executor Types
|
|
16
|
+
|
|
17
|
+
```bash
|
|
18
|
+
./scripts/setup_executor.sh
|
|
19
|
+
```
|
|
20
|
+
|
|
21
|
+
Shows all executor types with descriptions and current summary.
|
|
22
|
+
|
|
23
|
+
### Step 2: Get Config Schema
|
|
24
|
+
|
|
25
|
+
```bash
|
|
26
|
+
./scripts/setup_executor.sh --type position_executor
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Shows required fields and example configuration.
|
|
30
|
+
|
|
31
|
+
### Step 3: Create Executor
|
|
32
|
+
|
|
33
|
+
```bash
|
|
34
|
+
./scripts/setup_executor.sh --type position_executor --config '{
|
|
35
|
+
"connector_name": "hyperliquid_perpetual",
|
|
36
|
+
"trading_pair": "BTC-USD",
|
|
37
|
+
"side": "BUY",
|
|
38
|
+
"amount": "0.001",
|
|
39
|
+
"triple_barrier_config": {
|
|
40
|
+
"stop_loss": "0.02",
|
|
41
|
+
"take_profit": "0.04",
|
|
42
|
+
"time_limit": 3600
|
|
43
|
+
}
|
|
44
|
+
}'
|
|
45
|
+
```
|
|
46
|
+
|
|
47
|
+
## Executor Types
|
|
48
|
+
|
|
49
|
+
### 1. Position Executor (Recommended Start)
|
|
50
|
+
|
|
51
|
+
Single position with triple barrier risk management:
|
|
52
|
+
- **Stop Loss**: Exit if price moves against you
|
|
53
|
+
- **Take Profit**: Exit when target reached
|
|
54
|
+
- **Time Limit**: Exit after duration expires
|
|
55
|
+
|
|
56
|
+
```bash
|
|
57
|
+
./scripts/setup_executor.sh --type position_executor --config '{
|
|
58
|
+
"connector_name": "hyperliquid_perpetual",
|
|
59
|
+
"trading_pair": "BTC-USD",
|
|
60
|
+
"side": "BUY",
|
|
61
|
+
"amount": "0.001",
|
|
62
|
+
"triple_barrier_config": {
|
|
63
|
+
"stop_loss": "0.02",
|
|
64
|
+
"take_profit": "0.04",
|
|
65
|
+
"time_limit": 3600
|
|
66
|
+
}
|
|
67
|
+
}'
|
|
68
|
+
```
|
|
69
|
+
|
|
70
|
+
### 2. Grid Executor
|
|
71
|
+
|
|
72
|
+
Automated grid trading with multiple buy/sell levels:
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
./scripts/setup_executor.sh --type grid_executor --config '{
|
|
76
|
+
"connector_name": "hyperliquid_perpetual",
|
|
77
|
+
"trading_pair": "BTC-USD",
|
|
78
|
+
"start_price": "80000",
|
|
79
|
+
"end_price": "90000",
|
|
80
|
+
"total_amount_quote": "1000",
|
|
81
|
+
"total_levels": 10,
|
|
82
|
+
"side": "BUY"
|
|
83
|
+
}'
|
|
84
|
+
```
|
|
85
|
+
|
|
86
|
+
### 3. DCA Executor
|
|
87
|
+
|
|
88
|
+
Dollar-cost averaging with multiple entry points:
|
|
89
|
+
|
|
90
|
+
```bash
|
|
91
|
+
./scripts/setup_executor.sh --type dca_executor --config '{
|
|
92
|
+
"connector_name": "hyperliquid_perpetual",
|
|
93
|
+
"trading_pair": "BTC-USD",
|
|
94
|
+
"side": "BUY",
|
|
95
|
+
"total_amount_quote": "1000",
|
|
96
|
+
"n_levels": 5,
|
|
97
|
+
"time_limit": 86400
|
|
98
|
+
}'
|
|
99
|
+
```
|
|
100
|
+
|
|
101
|
+
### 4. TWAP Executor
|
|
102
|
+
|
|
103
|
+
Time-weighted average price for large orders with minimal market impact.
|
|
104
|
+
|
|
105
|
+
### 5. Arbitrage Executor
|
|
106
|
+
|
|
107
|
+
Cross-exchange price arbitrage.
|
|
108
|
+
|
|
109
|
+
### 6. XEMM Executor
|
|
110
|
+
|
|
111
|
+
Cross-exchange market making.
|
|
112
|
+
|
|
113
|
+
### 7. Order Executor
|
|
114
|
+
|
|
115
|
+
Simple order execution with retry logic.
|
|
116
|
+
|
|
117
|
+
## Management Scripts
|
|
118
|
+
|
|
119
|
+
### List Active Executors
|
|
120
|
+
|
|
121
|
+
```bash
|
|
122
|
+
./scripts/list_executors.sh [--status RUNNING] [--connector hyperliquid_perpetual]
|
|
123
|
+
```
|
|
124
|
+
|
|
125
|
+
### Get Executor Details
|
|
126
|
+
|
|
127
|
+
```bash
|
|
128
|
+
./scripts/get_executor.sh --id <executor_id>
|
|
129
|
+
```
|
|
130
|
+
|
|
131
|
+
### Stop Executor
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
# Stop and close positions
|
|
135
|
+
./scripts/stop_executor.sh --id <executor_id>
|
|
136
|
+
|
|
137
|
+
# Stop but keep position open
|
|
138
|
+
./scripts/stop_executor.sh --id <executor_id> --keep-position
|
|
139
|
+
```
|
|
140
|
+
|
|
141
|
+
### Get Summary Stats
|
|
142
|
+
|
|
143
|
+
```bash
|
|
144
|
+
./scripts/get_executors_summary.sh
|
|
145
|
+
```
|
|
146
|
+
|
|
147
|
+
### Manage Held Positions
|
|
148
|
+
|
|
149
|
+
```bash
|
|
150
|
+
# List all positions from stopped executors
|
|
151
|
+
./scripts/get_positions.sh
|
|
152
|
+
|
|
153
|
+
# Get specific position
|
|
154
|
+
./scripts/get_position.sh --connector hyperliquid_perpetual --pair BTC-USD
|
|
155
|
+
|
|
156
|
+
# Clear position (after manual close)
|
|
157
|
+
./scripts/clear_position.sh --connector hyperliquid_perpetual --pair BTC-USD
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
## Position Executor Configuration
|
|
161
|
+
|
|
162
|
+
| Parameter | Type | Required | Description |
|
|
163
|
+
|-----------|------|----------|-------------|
|
|
164
|
+
| `connector_name` | string | Yes | Exchange connector |
|
|
165
|
+
| `trading_pair` | string | Yes | Trading pair |
|
|
166
|
+
| `side` | enum | Yes | BUY or SELL |
|
|
167
|
+
| `amount` | Decimal | Yes | Position size |
|
|
168
|
+
| `entry_price` | Decimal | No | Limit price (market if omitted) |
|
|
169
|
+
| `triple_barrier_config.stop_loss` | Decimal | No | Stop loss (e.g., 0.02 = 2%) |
|
|
170
|
+
| `triple_barrier_config.take_profit` | Decimal | No | Take profit percentage |
|
|
171
|
+
| `triple_barrier_config.time_limit` | int | No | Max duration in seconds |
|
|
172
|
+
| `leverage` | int | No | Leverage (default: 1) |
|
|
173
|
+
|
|
174
|
+
### Triple Barrier Explained
|
|
175
|
+
|
|
176
|
+
```
|
|
177
|
+
Take Profit (exit with gain)
|
|
178
|
+
────────────────────────
|
|
179
|
+
↑
|
|
180
|
+
Price moves up │
|
|
181
|
+
│
|
|
182
|
+
Entry ──────────────────●──────────────────── Time Limit (exit)
|
|
183
|
+
│
|
|
184
|
+
Price moves down│
|
|
185
|
+
↓
|
|
186
|
+
────────────────────────
|
|
187
|
+
Stop Loss (exit with loss)
|
|
188
|
+
```
|
|
189
|
+
|
|
190
|
+
The position exits when ANY barrier is hit first.
|
|
191
|
+
|
|
192
|
+
## API Endpoints
|
|
193
|
+
|
|
194
|
+
| Endpoint | Method | Description |
|
|
195
|
+
|----------|--------|-------------|
|
|
196
|
+
| `/executors/types/available` | GET | List executor types |
|
|
197
|
+
| `/executors/types/{type}/config` | GET | Get config schema |
|
|
198
|
+
| `/executors` | POST | Create executor |
|
|
199
|
+
| `/executors/search` | POST | List/filter executors |
|
|
200
|
+
| `/executors/summary` | GET | Get summary stats |
|
|
201
|
+
| `/executors/{id}` | GET | Get executor details |
|
|
202
|
+
| `/executors/{id}/stop` | POST | Stop executor |
|
|
203
|
+
| `/executors/positions/summary` | GET | Get held positions |
|
|
204
|
+
|
|
205
|
+
## Error Handling
|
|
206
|
+
|
|
207
|
+
| Error | Cause | Solution |
|
|
208
|
+
|-------|-------|----------|
|
|
209
|
+
| "Unknown executor type" | Invalid type | Use Step 1 to see valid types |
|
|
210
|
+
| "Insufficient balance" | Not enough funds | Reduce amount or add funds |
|
|
211
|
+
| "Invalid trading pair" | Pair not on exchange | Check exchange for valid pairs |
|
|
212
|
+
| "Connector not configured" | Missing API keys | Use keys skill to add credentials |
|
|
@@ -0,0 +1,54 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# Clear a held position (use after manually closing on exchange)
|
|
3
|
+
# Usage: ./clear_position.sh --connector CONNECTOR --pair PAIR
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
API_URL="${API_URL:-http://localhost:8000}"
|
|
8
|
+
API_USER="${API_USER:-admin}"
|
|
9
|
+
API_PASS="${API_PASS:-admin}"
|
|
10
|
+
CONNECTOR=""
|
|
11
|
+
PAIR=""
|
|
12
|
+
|
|
13
|
+
# Parse arguments
|
|
14
|
+
while [[ $# -gt 0 ]]; do
|
|
15
|
+
case $1 in
|
|
16
|
+
--connector) CONNECTOR="$2"; shift 2 ;;
|
|
17
|
+
--pair) PAIR="$2"; shift 2 ;;
|
|
18
|
+
--api-url) API_URL="$2"; shift 2 ;;
|
|
19
|
+
--api-user) API_USER="$2"; shift 2 ;;
|
|
20
|
+
--api-pass) API_PASS="$2"; shift 2 ;;
|
|
21
|
+
*) shift ;;
|
|
22
|
+
esac
|
|
23
|
+
done
|
|
24
|
+
|
|
25
|
+
if [ -z "$CONNECTOR" ]; then
|
|
26
|
+
echo '{"error": "connector is required. Use --connector CONNECTOR"}'
|
|
27
|
+
exit 1
|
|
28
|
+
fi
|
|
29
|
+
|
|
30
|
+
if [ -z "$PAIR" ]; then
|
|
31
|
+
echo '{"error": "trading pair is required. Use --pair PAIR"}'
|
|
32
|
+
exit 1
|
|
33
|
+
fi
|
|
34
|
+
|
|
35
|
+
# Clear position
|
|
36
|
+
RESPONSE=$(curl -s -X DELETE \
|
|
37
|
+
-u "$API_USER:$API_PASS" \
|
|
38
|
+
"$API_URL/executors/positions/$CONNECTOR/$PAIR")
|
|
39
|
+
|
|
40
|
+
# Check for error
|
|
41
|
+
if echo "$RESPONSE" | jq -e '.detail' > /dev/null 2>&1; then
|
|
42
|
+
echo "{\"error\": \"Failed to clear position for $CONNECTOR/$PAIR\", \"detail\": $RESPONSE}"
|
|
43
|
+
exit 1
|
|
44
|
+
fi
|
|
45
|
+
|
|
46
|
+
cat << EOF
|
|
47
|
+
{
|
|
48
|
+
"status": "success",
|
|
49
|
+
"action": "position_cleared",
|
|
50
|
+
"connector": "$CONNECTOR",
|
|
51
|
+
"trading_pair": "$PAIR",
|
|
52
|
+
"response": $RESPONSE
|
|
53
|
+
}
|
|
54
|
+
EOF
|