@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.
Files changed (35) hide show
  1. package/README.md +63 -0
  2. package/package.json +28 -0
  3. package/skills/candles-feed/SKILL.md +259 -0
  4. package/skills/candles-feed/scripts/calculate_indicator.sh +359 -0
  5. package/skills/candles-feed/scripts/get_candles.sh +158 -0
  6. package/skills/candles-feed/scripts/get_funding_rate.sh +112 -0
  7. package/skills/candles-feed/scripts/get_price.sh +86 -0
  8. package/skills/candles-feed/scripts/list_candle_connectors.sh +47 -0
  9. package/skills/executor-creator/SKILL.md +212 -0
  10. package/skills/executor-creator/scripts/clear_position.sh +54 -0
  11. package/skills/executor-creator/scripts/create_executor.sh +92 -0
  12. package/skills/executor-creator/scripts/get_executor.sh +37 -0
  13. package/skills/executor-creator/scripts/get_executor_schema.sh +37 -0
  14. package/skills/executor-creator/scripts/get_executors_summary.sh +30 -0
  15. package/skills/executor-creator/scripts/get_position.sh +44 -0
  16. package/skills/executor-creator/scripts/get_positions.sh +30 -0
  17. package/skills/executor-creator/scripts/list_executor_types.sh +30 -0
  18. package/skills/executor-creator/scripts/list_executors.sh +52 -0
  19. package/skills/executor-creator/scripts/setup_executor.sh +197 -0
  20. package/skills/executor-creator/scripts/stop_executor.sh +54 -0
  21. package/skills/hummingbot-api-setup/SKILL.md +308 -0
  22. package/skills/hummingbot-api-setup/references/original_setup.sh +628 -0
  23. package/skills/hummingbot-api-setup/scripts/check_prerequisites.sh +92 -0
  24. package/skills/hummingbot-api-setup/scripts/deploy_full_stack.sh +151 -0
  25. package/skills/hummingbot-api-setup/scripts/health_check.sh +100 -0
  26. package/skills/hummingbot-api-setup/scripts/step1_detect_system.sh +88 -0
  27. package/skills/hummingbot-api-setup/scripts/step2_check_dependencies.sh +81 -0
  28. package/skills/keys-manager/SKILL.md +132 -0
  29. package/skills/keys-manager/scripts/add_credentials.sh +106 -0
  30. package/skills/keys-manager/scripts/get_connector_config.sh +67 -0
  31. package/skills/keys-manager/scripts/list_account_credentials.sh +82 -0
  32. package/skills/keys-manager/scripts/list_connectors.sh +64 -0
  33. package/skills/keys-manager/scripts/remove_credentials.sh +79 -0
  34. package/skills/keys-manager/scripts/setup_connector.sh +214 -0
  35. package/skills.json +137 -0
@@ -0,0 +1,92 @@
1
+ #!/bin/bash
2
+ # Create and start a new executor
3
+ # Usage: ./create_executor.sh --type EXECUTOR_TYPE --config JSON [--account ACCOUNT]
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
+ EXECUTOR_TYPE=""
11
+ CONFIG=""
12
+ ACCOUNT="master_account"
13
+
14
+ # Parse arguments
15
+ while [[ $# -gt 0 ]]; do
16
+ case $1 in
17
+ --type) EXECUTOR_TYPE="$2"; shift 2 ;;
18
+ --config) CONFIG="$2"; shift 2 ;;
19
+ --account) ACCOUNT="$2"; shift 2 ;;
20
+ --connector) CONNECTOR="$2"; shift 2 ;;
21
+ --pair) PAIR="$2"; shift 2 ;;
22
+ --side) SIDE="$2"; shift 2 ;;
23
+ --amount) AMOUNT="$2"; shift 2 ;;
24
+ --stop-loss) STOP_LOSS="$2"; shift 2 ;;
25
+ --take-profit) TAKE_PROFIT="$2"; shift 2 ;;
26
+ --time-limit) TIME_LIMIT="$2"; shift 2 ;;
27
+ --entry-price) ENTRY_PRICE="$2"; shift 2 ;;
28
+ --lower-price) LOWER_PRICE="$2"; shift 2 ;;
29
+ --upper-price) UPPER_PRICE="$2"; shift 2 ;;
30
+ --levels) LEVELS="$2"; shift 2 ;;
31
+ --api-url) API_URL="$2"; shift 2 ;;
32
+ --api-user) API_USER="$2"; shift 2 ;;
33
+ --api-pass) API_PASS="$2"; shift 2 ;;
34
+ *) shift ;;
35
+ esac
36
+ done
37
+
38
+ if [ -z "$EXECUTOR_TYPE" ]; then
39
+ echo '{"error": "executor type is required. Use --type EXECUTOR_TYPE"}'
40
+ exit 1
41
+ fi
42
+
43
+ # Build config from individual params if not provided as JSON
44
+ if [ -z "$CONFIG" ]; then
45
+ CONFIG="{\"type\": \"$EXECUTOR_TYPE\""
46
+
47
+ [ -n "$CONNECTOR" ] && CONFIG+=", \"connector_name\": \"$CONNECTOR\""
48
+ [ -n "$PAIR" ] && CONFIG+=", \"trading_pair\": \"$PAIR\""
49
+ [ -n "$SIDE" ] && CONFIG+=", \"side\": \"$SIDE\""
50
+ [ -n "$AMOUNT" ] && CONFIG+=", \"amount\": $AMOUNT"
51
+ [ -n "$ENTRY_PRICE" ] && CONFIG+=", \"entry_price\": $ENTRY_PRICE"
52
+ [ -n "$STOP_LOSS" ] && CONFIG+=", \"stop_loss\": $STOP_LOSS"
53
+ [ -n "$TAKE_PROFIT" ] && CONFIG+=", \"take_profit\": $TAKE_PROFIT"
54
+ [ -n "$TIME_LIMIT" ] && CONFIG+=", \"time_limit\": $TIME_LIMIT"
55
+ [ -n "$LOWER_PRICE" ] && CONFIG+=", \"start_price\": $LOWER_PRICE"
56
+ [ -n "$UPPER_PRICE" ] && CONFIG+=", \"end_price\": $UPPER_PRICE"
57
+ [ -n "$LEVELS" ] && CONFIG+=", \"total_levels\": $LEVELS"
58
+
59
+ CONFIG+="}"
60
+ else
61
+ # Ensure type is in the config
62
+ CONFIG=$(echo "$CONFIG" | jq --arg type "$EXECUTOR_TYPE" '. + {type: $type}')
63
+ fi
64
+
65
+ # Build request
66
+ REQUEST=$(jq -n \
67
+ --argjson config "$CONFIG" \
68
+ --arg account "$ACCOUNT" \
69
+ '{executor_config: $config, account_name: $account}')
70
+
71
+ # Create executor
72
+ RESPONSE=$(curl -s -X POST \
73
+ -u "$API_USER:$API_PASS" \
74
+ -H "Content-Type: application/json" \
75
+ -d "$REQUEST" \
76
+ "$API_URL/executors")
77
+
78
+ # Check for error
79
+ if echo "$RESPONSE" | jq -e '.detail' > /dev/null 2>&1; then
80
+ echo "{\"error\": \"Failed to create executor\", \"detail\": $RESPONSE}"
81
+ exit 1
82
+ fi
83
+
84
+ cat << EOF
85
+ {
86
+ "status": "success",
87
+ "action": "executor_created",
88
+ "executor_type": "$EXECUTOR_TYPE",
89
+ "account": "$ACCOUNT",
90
+ "response": $RESPONSE
91
+ }
92
+ EOF
@@ -0,0 +1,37 @@
1
+ #!/bin/bash
2
+ # Get details for a specific executor
3
+ # Usage: ./get_executor.sh --id EXECUTOR_ID
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
+ EXECUTOR_ID=""
11
+
12
+ # Parse arguments
13
+ while [[ $# -gt 0 ]]; do
14
+ case $1 in
15
+ --id) EXECUTOR_ID="$2"; shift 2 ;;
16
+ --api-url) API_URL="$2"; shift 2 ;;
17
+ --api-user) API_USER="$2"; shift 2 ;;
18
+ --api-pass) API_PASS="$2"; shift 2 ;;
19
+ *) shift ;;
20
+ esac
21
+ done
22
+
23
+ if [ -z "$EXECUTOR_ID" ]; then
24
+ echo '{"error": "executor ID is required. Use --id EXECUTOR_ID"}'
25
+ exit 1
26
+ fi
27
+
28
+ # Fetch executor details
29
+ RESPONSE=$(curl -s -u "$API_USER:$API_PASS" "$API_URL/executors/$EXECUTOR_ID")
30
+
31
+ # Check for error
32
+ if echo "$RESPONSE" | jq -e '.detail' > /dev/null 2>&1; then
33
+ echo "{\"error\": \"Failed to get executor '$EXECUTOR_ID'\", \"detail\": $RESPONSE}"
34
+ exit 1
35
+ fi
36
+
37
+ echo "$RESPONSE" | jq '.'
@@ -0,0 +1,37 @@
1
+ #!/bin/bash
2
+ # Get configuration schema for a specific executor type
3
+ # Usage: ./get_executor_schema.sh --type EXECUTOR_TYPE
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
+ EXECUTOR_TYPE=""
11
+
12
+ # Parse arguments
13
+ while [[ $# -gt 0 ]]; do
14
+ case $1 in
15
+ --type) EXECUTOR_TYPE="$2"; shift 2 ;;
16
+ --api-url) API_URL="$2"; shift 2 ;;
17
+ --api-user) API_USER="$2"; shift 2 ;;
18
+ --api-pass) API_PASS="$2"; shift 2 ;;
19
+ *) shift ;;
20
+ esac
21
+ done
22
+
23
+ if [ -z "$EXECUTOR_TYPE" ]; then
24
+ echo '{"error": "executor type is required. Use --type EXECUTOR_TYPE"}'
25
+ exit 1
26
+ fi
27
+
28
+ # Fetch schema
29
+ RESPONSE=$(curl -s -u "$API_USER:$API_PASS" "$API_URL/executors/types/$EXECUTOR_TYPE/config")
30
+
31
+ # Check for error
32
+ if echo "$RESPONSE" | jq -e '.detail' > /dev/null 2>&1; then
33
+ echo "{\"error\": \"Failed to get schema for '$EXECUTOR_TYPE'\", \"detail\": $RESPONSE}"
34
+ exit 1
35
+ fi
36
+
37
+ echo "$RESPONSE" | jq '.'
@@ -0,0 +1,30 @@
1
+ #!/bin/bash
2
+ # Get summary statistics for all executors
3
+ # Usage: ./get_executors_summary.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) API_URL="$2"; shift 2 ;;
15
+ --api-user) API_USER="$2"; shift 2 ;;
16
+ --api-pass) API_PASS="$2"; shift 2 ;;
17
+ *) shift ;;
18
+ esac
19
+ done
20
+
21
+ # Fetch summary
22
+ RESPONSE=$(curl -s -u "$API_USER:$API_PASS" "$API_URL/executors/summary")
23
+
24
+ # Check for error
25
+ if echo "$RESPONSE" | jq -e '.detail' > /dev/null 2>&1; then
26
+ echo "{\"error\": \"Failed to get executors summary\", \"detail\": $RESPONSE}"
27
+ exit 1
28
+ fi
29
+
30
+ echo "$RESPONSE" | jq '.'
@@ -0,0 +1,44 @@
1
+ #!/bin/bash
2
+ # Get a specific held position
3
+ # Usage: ./get_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
+ # Fetch position
36
+ RESPONSE=$(curl -s -u "$API_USER:$API_PASS" "$API_URL/executors/positions/$CONNECTOR/$PAIR")
37
+
38
+ # Check for error
39
+ if echo "$RESPONSE" | jq -e '.detail' > /dev/null 2>&1; then
40
+ echo "{\"error\": \"Failed to get position for $CONNECTOR/$PAIR\", \"detail\": $RESPONSE}"
41
+ exit 1
42
+ fi
43
+
44
+ echo "$RESPONSE" | jq '.'
@@ -0,0 +1,30 @@
1
+ #!/bin/bash
2
+ # Get all held positions from stopped executors
3
+ # Usage: ./get_positions.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) API_URL="$2"; shift 2 ;;
15
+ --api-user) API_USER="$2"; shift 2 ;;
16
+ --api-pass) API_PASS="$2"; shift 2 ;;
17
+ *) shift ;;
18
+ esac
19
+ done
20
+
21
+ # Fetch positions summary
22
+ RESPONSE=$(curl -s -u "$API_USER:$API_PASS" "$API_URL/executors/positions/summary")
23
+
24
+ # Check for error
25
+ if echo "$RESPONSE" | jq -e '.detail' > /dev/null 2>&1; then
26
+ echo "{\"error\": \"Failed to get positions\", \"detail\": $RESPONSE}"
27
+ exit 1
28
+ fi
29
+
30
+ echo "$RESPONSE" | jq '.'
@@ -0,0 +1,30 @@
1
+ #!/bin/bash
2
+ # List available executor types with descriptions
3
+ # Usage: ./list_executor_types.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) API_URL="$2"; shift 2 ;;
15
+ --api-user) API_USER="$2"; shift 2 ;;
16
+ --api-pass) API_PASS="$2"; shift 2 ;;
17
+ *) shift ;;
18
+ esac
19
+ done
20
+
21
+ # Fetch executor types
22
+ RESPONSE=$(curl -s -u "$API_USER:$API_PASS" "$API_URL/executors/types/available")
23
+
24
+ # Check for error
25
+ if echo "$RESPONSE" | jq -e '.detail' > /dev/null 2>&1; then
26
+ echo "{\"error\": \"Failed to get executor types\", \"detail\": $RESPONSE}"
27
+ exit 1
28
+ fi
29
+
30
+ echo "$RESPONSE" | jq '.'
@@ -0,0 +1,52 @@
1
+ #!/bin/bash
2
+ # List executors with optional filtering
3
+ # Usage: ./list_executors.sh [--status STATUS] [--connector CONNECTOR] [--pair PAIR] [--type TYPE]
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
+ STATUS=""
11
+ CONNECTOR=""
12
+ PAIR=""
13
+ EXECUTOR_TYPE=""
14
+ LIMIT=50
15
+
16
+ # Parse arguments
17
+ while [[ $# -gt 0 ]]; do
18
+ case $1 in
19
+ --status) STATUS="$2"; shift 2 ;;
20
+ --connector) CONNECTOR="$2"; shift 2 ;;
21
+ --pair) PAIR="$2"; shift 2 ;;
22
+ --type) EXECUTOR_TYPE="$2"; shift 2 ;;
23
+ --limit) LIMIT="$2"; shift 2 ;;
24
+ --api-url) API_URL="$2"; shift 2 ;;
25
+ --api-user) API_USER="$2"; shift 2 ;;
26
+ --api-pass) API_PASS="$2"; shift 2 ;;
27
+ *) shift ;;
28
+ esac
29
+ done
30
+
31
+ # Build filter request
32
+ FILTER="{\"limit\": $LIMIT"
33
+ [ -n "$STATUS" ] && FILTER+=", \"status\": \"$STATUS\""
34
+ [ -n "$CONNECTOR" ] && FILTER+=", \"connector_names\": [\"$CONNECTOR\"]"
35
+ [ -n "$PAIR" ] && FILTER+=", \"trading_pairs\": [\"$PAIR\"]"
36
+ [ -n "$EXECUTOR_TYPE" ] && FILTER+=", \"executor_types\": [\"$EXECUTOR_TYPE\"]"
37
+ FILTER+="}"
38
+
39
+ # Search executors
40
+ RESPONSE=$(curl -s -X POST \
41
+ -u "$API_USER:$API_PASS" \
42
+ -H "Content-Type: application/json" \
43
+ -d "$FILTER" \
44
+ "$API_URL/executors/search")
45
+
46
+ # Check for error
47
+ if echo "$RESPONSE" | jq -e '.detail' > /dev/null 2>&1; then
48
+ echo "{\"error\": \"Failed to list executors\", \"detail\": $RESPONSE}"
49
+ exit 1
50
+ fi
51
+
52
+ echo "$RESPONSE" | jq '.'
@@ -0,0 +1,197 @@
1
+ #!/bin/bash
2
+ # Create executor with progressive disclosure
3
+ #
4
+ # Flow:
5
+ # 1. No parameters → List available executor types
6
+ # 2. --type only → Show config schema for that type
7
+ # 3. --type + --config → Create and start the executor
8
+ #
9
+ # Usage:
10
+ # ./setup_executor.sh # Step 1: List executor types
11
+ # ./setup_executor.sh --type position_executor # Step 2: Show config schema
12
+ # ./setup_executor.sh --type position_executor --config '{...}' # Step 3: Create executor
13
+
14
+ set -e
15
+
16
+ API_URL="${API_URL:-http://localhost:8000}"
17
+ API_USER="${API_USER:-admin}"
18
+ API_PASS="${API_PASS:-admin}"
19
+ EXECUTOR_TYPE=""
20
+ CONFIG=""
21
+ ACCOUNT="master_account"
22
+
23
+ # Parse arguments
24
+ while [[ $# -gt 0 ]]; do
25
+ case $1 in
26
+ --type) EXECUTOR_TYPE="$2"; shift 2 ;;
27
+ --config) CONFIG="$2"; shift 2 ;;
28
+ --account) ACCOUNT="$2"; shift 2 ;;
29
+ --api-url) API_URL="$2"; shift 2 ;;
30
+ --api-user) API_USER="$2"; shift 2 ;;
31
+ --api-pass) API_PASS="$2"; shift 2 ;;
32
+ *) shift ;;
33
+ esac
34
+ done
35
+
36
+ # Determine flow stage
37
+ if [ -z "$EXECUTOR_TYPE" ]; then
38
+ STAGE="list_types"
39
+ elif [ -z "$CONFIG" ]; then
40
+ STAGE="show_schema"
41
+ else
42
+ STAGE="create"
43
+ fi
44
+
45
+ case "$STAGE" in
46
+ list_types)
47
+ # Step 1: List available executor types
48
+ TYPES=$(curl -s -u "$API_USER:$API_PASS" "$API_URL/executors/types/available")
49
+
50
+ if echo "$TYPES" | jq -e '.detail' > /dev/null 2>&1; then
51
+ echo "{\"error\": \"Failed to get executor types\", \"detail\": $TYPES}"
52
+ exit 1
53
+ fi
54
+
55
+ # Get current executor summary
56
+ SUMMARY=$(curl -s -u "$API_USER:$API_PASS" "$API_URL/executors/summary")
57
+
58
+ cat << EOF
59
+ {
60
+ "action": "list_types",
61
+ "message": "Available executor types. Select one to see its configuration schema.",
62
+ "executor_types": $(echo "$TYPES" | jq '.executor_types'),
63
+ "current_summary": {
64
+ "active": $(echo "$SUMMARY" | jq '.total_active'),
65
+ "completed": $(echo "$SUMMARY" | jq '.total_completed'),
66
+ "total_pnl": $(echo "$SUMMARY" | jq '.total_pnl_quote')
67
+ },
68
+ "next_step": "Call again with --type EXECUTOR_TYPE to see the configuration schema",
69
+ "example": "./setup_executor.sh --type position_executor"
70
+ }
71
+ EOF
72
+ ;;
73
+
74
+ show_schema)
75
+ # Step 2: Show configuration schema for the executor type
76
+ SCHEMA=$(curl -s -u "$API_USER:$API_PASS" "$API_URL/executors/types/$EXECUTOR_TYPE/config")
77
+
78
+ if echo "$SCHEMA" | jq -e '.detail' > /dev/null 2>&1; then
79
+ echo "{\"error\": \"Executor type '$EXECUTOR_TYPE' not found\", \"detail\": $SCHEMA}"
80
+ exit 1
81
+ fi
82
+
83
+ # Extract required and optional fields
84
+ REQUIRED_FIELDS=$(echo "$SCHEMA" | jq '[.fields[] | select(.required == true and .default == null) | .name]')
85
+ OPTIONAL_FIELDS=$(echo "$SCHEMA" | jq '[.fields[] | select(.required != true or .default != null) | {name: .name, default: .default}]')
86
+
87
+ # Build minimal example config
88
+ EXAMPLE_CONFIG=$(echo "$SCHEMA" | jq --arg type "$EXECUTOR_TYPE" '
89
+ {type: $type} +
90
+ ([.fields[] | select(.required == true and .default == null) |
91
+ {(.name): (
92
+ if .type == "string" then "your_" + .name
93
+ elif .type == "number" then 0
94
+ elif .type == "boolean" then false
95
+ else "your_" + .name
96
+ end
97
+ )}
98
+ ] | add // {})
99
+ ')
100
+
101
+ # Build a more complete example for position_executor
102
+ if [ "$EXECUTOR_TYPE" = "position_executor" ]; then
103
+ EXAMPLE_CONFIG='{
104
+ "type": "position_executor",
105
+ "connector_name": "hyperliquid_perpetual",
106
+ "trading_pair": "BTC-USD",
107
+ "side": "BUY",
108
+ "amount": "0.001",
109
+ "triple_barrier_config": {
110
+ "stop_loss": "0.02",
111
+ "take_profit": "0.04",
112
+ "time_limit": 3600
113
+ }
114
+ }'
115
+ elif [ "$EXECUTOR_TYPE" = "grid_executor" ]; then
116
+ EXAMPLE_CONFIG='{
117
+ "type": "grid_executor",
118
+ "connector_name": "hyperliquid_perpetual",
119
+ "trading_pair": "BTC-USD",
120
+ "start_price": "80000",
121
+ "end_price": "90000",
122
+ "total_amount_quote": "1000",
123
+ "total_levels": 10,
124
+ "side": "BUY"
125
+ }'
126
+ elif [ "$EXECUTOR_TYPE" = "dca_executor" ]; then
127
+ EXAMPLE_CONFIG='{
128
+ "type": "dca_executor",
129
+ "connector_name": "hyperliquid_perpetual",
130
+ "trading_pair": "BTC-USD",
131
+ "side": "BUY",
132
+ "total_amount_quote": "1000",
133
+ "n_levels": 5,
134
+ "time_limit": 86400
135
+ }'
136
+ fi
137
+
138
+ cat << EOF
139
+ {
140
+ "action": "show_schema",
141
+ "message": "Configuration schema for $EXECUTOR_TYPE. Build your config and create the executor.",
142
+ "executor_type": "$EXECUTOR_TYPE",
143
+ "description": $(echo "$SCHEMA" | jq '.description'),
144
+ "required_fields": $REQUIRED_FIELDS,
145
+ "all_fields": $(echo "$SCHEMA" | jq '[.fields[] | {name: .name, type: .type, required: .required, default: .default, description: .description}]'),
146
+ "example_config": $EXAMPLE_CONFIG,
147
+ "next_step": "Call again with --config JSON to create the executor",
148
+ "example": "./setup_executor.sh --type $EXECUTOR_TYPE --config '\$EXAMPLE_CONFIG'"
149
+ }
150
+ EOF
151
+ ;;
152
+
153
+ create)
154
+ # Step 3: Create and start the executor
155
+
156
+ # Ensure type is in the config
157
+ CONFIG_WITH_TYPE=$(echo "$CONFIG" | jq --arg type "$EXECUTOR_TYPE" '. + {type: $type}')
158
+
159
+ # Build request
160
+ REQUEST=$(jq -n \
161
+ --argjson config "$CONFIG_WITH_TYPE" \
162
+ --arg account "$ACCOUNT" \
163
+ '{executor_config: $config, account_name: $account}')
164
+
165
+ # Create executor
166
+ RESPONSE=$(curl -s -X POST \
167
+ -u "$API_USER:$API_PASS" \
168
+ -H "Content-Type: application/json" \
169
+ -d "$REQUEST" \
170
+ "$API_URL/executors")
171
+
172
+ if echo "$RESPONSE" | jq -e '.detail' > /dev/null 2>&1; then
173
+ echo "{\"error\": \"Failed to create executor\", \"detail\": $RESPONSE}"
174
+ exit 1
175
+ fi
176
+
177
+ # Extract key info from response
178
+ EXECUTOR_ID=$(echo "$RESPONSE" | jq -r '.id // .executor_id // "unknown"')
179
+
180
+ cat << EOF
181
+ {
182
+ "action": "executor_created",
183
+ "message": "Successfully created and started $EXECUTOR_TYPE",
184
+ "executor_id": "$EXECUTOR_ID",
185
+ "executor_type": "$EXECUTOR_TYPE",
186
+ "account": "$ACCOUNT",
187
+ "config": $CONFIG_WITH_TYPE,
188
+ "response": $RESPONSE,
189
+ "next_steps": [
190
+ "Monitor with: ./get_executor.sh --id $EXECUTOR_ID",
191
+ "Stop with: ./stop_executor.sh --id $EXECUTOR_ID",
192
+ "List all: ./list_executors.sh"
193
+ ]
194
+ }
195
+ EOF
196
+ ;;
197
+ esac
@@ -0,0 +1,54 @@
1
+ #!/bin/bash
2
+ # Stop a running executor
3
+ # Usage: ./stop_executor.sh --id EXECUTOR_ID [--keep-position]
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
+ EXECUTOR_ID=""
11
+ KEEP_POSITION=false
12
+
13
+ # Parse arguments
14
+ while [[ $# -gt 0 ]]; do
15
+ case $1 in
16
+ --id) EXECUTOR_ID="$2"; shift 2 ;;
17
+ --keep-position) KEEP_POSITION=true; shift ;;
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 "$EXECUTOR_ID" ]; then
26
+ echo '{"error": "executor ID is required. Use --id EXECUTOR_ID"}'
27
+ exit 1
28
+ fi
29
+
30
+ # Build request body
31
+ REQUEST=$(jq -n --argjson keep "$KEEP_POSITION" '{keep_position: $keep}')
32
+
33
+ # Stop executor
34
+ RESPONSE=$(curl -s -X POST \
35
+ -u "$API_USER:$API_PASS" \
36
+ -H "Content-Type: application/json" \
37
+ -d "$REQUEST" \
38
+ "$API_URL/executors/$EXECUTOR_ID/stop")
39
+
40
+ # Check for error
41
+ if echo "$RESPONSE" | jq -e '.detail' > /dev/null 2>&1; then
42
+ echo "{\"error\": \"Failed to stop executor '$EXECUTOR_ID'\", \"detail\": $RESPONSE}"
43
+ exit 1
44
+ fi
45
+
46
+ cat << EOF
47
+ {
48
+ "status": "success",
49
+ "action": "executor_stopped",
50
+ "executor_id": "$EXECUTOR_ID",
51
+ "keep_position": $KEEP_POSITION,
52
+ "response": $RESPONSE
53
+ }
54
+ EOF