POST
https://api.cryptohopper.com/v1/hopper/{id}/position/{position_id}/update
Updates the take profit, stop-loss and trailing stop-loss settings of an open position.
OAuth scope:
read manage About scopes
take_profit is applied when above 0. The stop-loss fields are applied only when stop_loss_percentage is above 0: stop_loss 1 turns stop-loss on, 0 or missing turns it off. The trailing fields are applied only when trailing_stop_loss_percentage is above 0, with trailing_stop_loss 1 or 0 in the same way. The timeout units are minutes, hours or days (default minutes). If the body contains position_ids, those positions are updated instead of the path position. auto_close and auto_close_time are read but currently have no effect. Not available for exchange arbitrage, market maker, copy and grid bots.
Example request
curl -X POST "https://api.cryptohopper.com/v1/hopper/HOPPER_ID/position/POSITION_ID/update" \
-H "access-token: YOUR_ACCESS_TOKEN" \
-H "Content-Type: application/json" \
-d '{"take_profit":4,"stop_loss":1,"stop_loss_percentage":2.5,"stop_loss_timeout_count":30,"stop_loss_timeout_val":"minutes","trailing_stop_loss":1,"trailing_stop_loss_percentage":1,"trailing_stop_loss_arm":2,"trailing_stop_loss_timeout_count":0,"trailing_stop_loss_timeout_val":"minutes"}'
const response = await fetch('https://api.cryptohopper.com/v1/hopper/HOPPER_ID/position/POSITION_ID/update', {
method: 'POST',
headers: {
"access-token": "YOUR_ACCESS_TOKEN",
"Content-Type": "application/json"
},
body: JSON.stringify({
"take_profit": 4,
"stop_loss": 1,
"stop_loss_percentage": 2.5,
"stop_loss_timeout_count": 30,
"stop_loss_timeout_val": "minutes",
"trailing_stop_loss": 1,
"trailing_stop_loss_percentage": 1,
"trailing_stop_loss_arm": 2,
"trailing_stop_loss_timeout_count": 0,
"trailing_stop_loss_timeout_val": "minutes"
})
});
const data = await response.json();
import requests
response = requests.post(
"https://api.cryptohopper.com/v1/hopper/HOPPER_ID/position/POSITION_ID/update",
headers={
"access-token": "YOUR_ACCESS_TOKEN"
},
json={
"take_profit": 4,
"stop_loss": 1,
"stop_loss_percentage": 2.5,
"stop_loss_timeout_count": 30,
"stop_loss_timeout_val": "minutes",
"trailing_stop_loss": 1,
"trailing_stop_loss_percentage": 1,
"trailing_stop_loss_arm": 2,
"trailing_stop_loss_timeout_count": 0,
"trailing_stop_loss_timeout_val": "minutes"
},
)
data = response.json()
$ch = curl_init('https://api.cryptohopper.com/v1/hopper/HOPPER_ID/position/POSITION_ID/update');
curl_setopt_array($ch, [
CURLOPT_CUSTOMREQUEST => 'POST',
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => [
'access-token: YOUR_ACCESS_TOKEN',
'Content-Type: application/json',
],
CURLOPT_POSTFIELDS => json_encode([
'take_profit' => 4,
'stop_loss' => 1,
'stop_loss_percentage' => 2.5,
'stop_loss_timeout_count' => 30,
'stop_loss_timeout_val' => 'minutes',
'trailing_stop_loss' => 1,
'trailing_stop_loss_percentage' => 1,
'trailing_stop_loss_arm' => 2,
'trailing_stop_loss_timeout_count' => 0,
'trailing_stop_loss_timeout_val' => 'minutes',
]),
]);
$data = json_decode(curl_exec($ch), true);
Parameters
Headers
| Name | Type | Required | Description |
|---|---|---|---|
access-token |
string | Required | The OAuth access token of the user. |
Path parameters
| Name | Type | Required | Description |
|---|---|---|---|
position_id |
string | Required | Open position ID. |
id |
string | Required | Hopper ID. |
Request body
| Field | Type | Required | Description |
|---|---|---|---|
take_profit | number | Optional | Minimum 0. |
stop_loss | number | Optional | Minimum 0. |
stop_loss_timeout_count | integer | Optional | Minimum 0. |
stop_loss_timeout_val | string | Optional | One of: minutes, hours, days. |
stop_loss_percentage | number | Optional | Minimum 0. |
trailing_stop_loss | number | Optional | Minimum 0. |
trailing_stop_loss_percentage | number | Optional | Minimum 0. |
trailing_stop_loss_arm | number | Optional | Minimum 0. |
auto_close | number | Optional | Minimum 0. |
auto_close_time | number | Optional | Minimum 0. |
Response
{
"data": "Position(s) config settings updated."
}